Skip to content

Commit fcf1b9b

Browse files
committed
Workflow outputs (third preview)
Signed-off-by: Ben Sherman <[email protected]>
1 parent 86165b8 commit fcf1b9b

File tree

9 files changed

+86
-64
lines changed

9 files changed

+86
-64
lines changed

bin/fastqc.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
2-
sample_id="$1"
2+
id="$1"
33
reads="$2"
44

5-
mkdir fastqc_${sample_id}_logs
6-
fastqc -o fastqc_${sample_id}_logs -f fastq -q ${reads}
5+
mkdir fastqc_${id}_logs
6+
fastqc -o fastqc_${id}_logs -f fastq -q ${reads}

data/allreads.csv

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
gut,https://raw.githubusercontent.com/nextflow-io/rnaseq-nf/refs/heads/master/data/ggal/ggal_gut_1.fq,https://raw.githubusercontent.com/nextflow-io/rnaseq-nf/refs/heads/master/data/ggal/ggal_gut_2.fq
2+
liver,https://raw.githubusercontent.com/nextflow-io/rnaseq-nf/refs/heads/master/data/ggal/ggal_liver_1.fq,https://raw.githubusercontent.com/nextflow-io/rnaseq-nf/refs/heads/master/data/ggal/ggal_liver_2.fq
3+
lung,https://raw.githubusercontent.com/nextflow-io/rnaseq-nf/refs/heads/master/data/ggal/ggal_lung_1.fq,https://raw.githubusercontent.com/nextflow-io/rnaseq-nf/refs/heads/master/data/ggal/ggal_lung_2.fq
4+
spleen,https://raw.githubusercontent.com/nextflow-io/rnaseq-nf/refs/heads/master/data/ggal/ggal_spleen_1.fq,https://raw.githubusercontent.com/nextflow-io/rnaseq-nf/refs/heads/master/data/ggal/ggal_spleen_2.fq

data/gut.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
gut,https://raw.githubusercontent.com/nextflow-io/rnaseq-nf/refs/heads/master/data/ggal/ggal_gut_1.fq,https://raw.githubusercontent.com/nextflow-io/rnaseq-nf/refs/heads/master/data/ggal/ggal_gut_2.fq

main.nf

Lines changed: 48 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,17 @@
44
* Proof of concept of a RNAseq pipeline implemented with Nextflow
55
*/
66

7+
nextflow.preview.output = true
78

89
/*
910
* Default pipeline parameters. They can be overriden on the command line eg.
10-
* given `params.foo` specify on the run command line `--foo some_value`.
11+
* given `params.reads` specify on the run command line `--reads some_value`.
1112
*/
1213

13-
params.reads = "$baseDir/data/ggal/ggal_gut_{1,2}.fq"
14-
params.transcriptome = "$baseDir/data/ggal/ggal_1_48850000_49020000.Ggal71.500bpflank.fa"
14+
params.reads = null
15+
params.transcriptome = null
1516
params.outdir = "results"
16-
params.multiqc = "$baseDir/multiqc"
17+
params.multiqc = "$projectDir/multiqc"
1718

1819

1920
// import modules
@@ -24,16 +25,48 @@ include { MULTIQC } from './modules/multiqc'
2425
* main script flow
2526
*/
2627
workflow {
28+
main:
29+
log.info """\
30+
R N A S E Q - N F P I P E L I N E
31+
===================================
32+
transcriptome: ${params.transcriptome}
33+
reads : ${params.reads}
34+
outdir : ${params.outdir}
35+
""".stripIndent()
2736

28-
log.info """\
29-
R N A S E Q - N F P I P E L I N E
30-
===================================
31-
transcriptome: ${params.transcriptome}
32-
reads : ${params.reads}
33-
outdir : ${params.outdir}
34-
"""
35-
36-
read_pairs_ch = channel.fromFilePairs( params.reads, checkIfExists: true )
37-
RNASEQ( params.transcriptome, read_pairs_ch )
38-
MULTIQC( RNASEQ.out, params.multiqc )
37+
inputs_ch = channel.fromPath(params.reads)
38+
.splitCsv()
39+
.map { id, fastq_1, fastq_2 ->
40+
tuple(id, file(fastq_1, checkIfExists: true), file(fastq_2, checkIfExists: true))
41+
}
42+
43+
samples_ch = RNASEQ( params.transcriptome, inputs_ch )
44+
.map { id, fastqc, quant ->
45+
[id: id, fastqc: fastqc, quant: quant]
46+
}
47+
48+
multiqc_files_ch = samples_ch
49+
.flatMap { sample -> [sample.fastqc, sample.quant] }
50+
.collect()
51+
multiqc_report = MULTIQC( multiqc_files_ch, params.multiqc )
52+
53+
publish:
54+
samples = samples_ch
55+
multiqc_report = multiqc_report
56+
}
57+
58+
output {
59+
samples {
60+
path { sample ->
61+
sample.fastqc >> "fastqc/${sample.id}"
62+
sample.quant >> "quant/${sample.id}"
63+
}
64+
index {
65+
path 'samples.csv'
66+
header true
67+
}
68+
}
69+
70+
multiqc_report {
71+
}
3972
}

modules/fastqc/main.nf

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
params.outdir = 'results'
21

32
process FASTQC {
4-
tag "FASTQC on $sample_id"
3+
tag "$id"
54
conda 'bioconda::fastqc=0.12.1'
6-
publishDir params.outdir, mode:'copy'
75

86
input:
9-
tuple val(sample_id), path(reads)
7+
tuple val(id), path(fastq_1), path(fastq_2)
108

119
output:
12-
path "fastqc_${sample_id}_logs", emit: logs
10+
tuple val(id), path("fastqc_${id}_logs")
1311

1412
script:
1513
"""
16-
fastqc.sh "$sample_id" "$reads"
14+
fastqc.sh "$id" "$fastq_1 $fastq_2"
1715
"""
1816
}

modules/multiqc/main.nf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
params.outdir = 'results'
21

32
process MULTIQC {
43
conda 'bioconda::multiqc=1.27.1'
5-
publishDir params.outdir, mode:'copy'
64

75
input:
86
path '*'

modules/quant/main.nf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11

22
process QUANT {
3-
tag "$pair_id"
3+
tag "$id"
44
conda 'bioconda::salmon=1.10.3'
55

66
input:
7-
path index
8-
tuple val(pair_id), path(reads)
7+
path index
8+
tuple val(id), path(fastq_1), path(fastq_2)
99

1010
output:
11-
path pair_id
11+
tuple val(id), path("quant_${id}")
1212

1313
script:
1414
"""
15-
salmon quant --threads $task.cpus --libType=U -i $index -1 ${reads[0]} -2 ${reads[1]} -o $pair_id
15+
salmon quant --threads $task.cpus --libType=U -i $index -1 ${fastq_1} -2 ${fastq_2} -o quant_$id
1616
"""
1717
}

modules/rnaseq.nf

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
params.outdir = 'results'
21

32
include { INDEX } from './index'
43
include { QUANT } from './quant'
54
include { FASTQC } from './fastqc'
65

76
workflow RNASEQ {
8-
take:
7+
take:
98
transcriptome
10-
read_pairs_ch
11-
12-
main:
13-
INDEX(transcriptome)
14-
FASTQC(read_pairs_ch)
15-
QUANT(INDEX.out, read_pairs_ch)
9+
samples_ch
1610

17-
emit:
18-
QUANT.out | concat(FASTQC.out) | collect
11+
main:
12+
index = INDEX(transcriptome)
13+
fastqc_ch = FASTQC(samples_ch)
14+
quant_ch = QUANT(index, samples_ch)
15+
samples_ch = fastqc_ch.join(quant_ch)
16+
17+
emit:
18+
samples_ch
1919
}

nextflow.config

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,20 @@ manifest {
1717
}
1818

1919
/*
20-
* default params
20+
* params for default test data
2121
*/
2222

23-
params.outdir = "results"
24-
params.reads = "${projectDir}/data/ggal/ggal_gut_{1,2}.fq"
25-
params.transcriptome = "${projectDir}/data/ggal/ggal_1_48850000_49020000.Ggal71.500bpflank.fa"
26-
params.multiqc = "${projectDir}/multiqc"
23+
params.reads = "${projectDir}/data/gut.csv"
24+
params.transcriptome = "https://raw.githubusercontent.com/nextflow-io/rnaseq-nf/refs/heads/master/data/ggal/ggal_1_48850000_49020000.Ggal71.500bpflank.fa"
2725

2826
/*
29-
* defines execution profiles for different environments
27+
* publish settings
28+
*/
29+
30+
workflow.output.mode = 'copy'
31+
32+
/*
33+
* execution profiles for different environments
3034
*/
3135

3236
profiles {
@@ -35,7 +39,7 @@ profiles {
3539
}
3640

3741
'all-reads' {
38-
params.reads = "${projectDir}/data/ggal/ggal_*_{1,2}.fq"
42+
params.reads = "${projectDir}/data/allreads.csv"
3943
}
4044

4145
'arm64' {
@@ -84,8 +88,6 @@ profiles {
8488
}
8589

8690
'batch' {
87-
params.reads = 's3://rnaseq-nf/data/ggal/lung_{1,2}.fq'
88-
params.transcriptome = 's3://rnaseq-nf/data/ggal/transcript.fa'
8991
process.container = 'docker.io/nextflow/rnaseq-nf:v1.3.1'
9092
process.executor = 'awsbatch'
9193
process.queue = 'nextflow-ci'
@@ -94,15 +96,7 @@ profiles {
9496
aws.batch.cliPath = '/home/ec2-user/miniconda/bin/aws'
9597
}
9698

97-
's3-data' {
98-
process.container = 'docker.io/nextflow/rnaseq-nf:v1.3.1'
99-
params.reads = 's3://rnaseq-nf/data/ggal/lung_{1,2}.fq'
100-
params.transcriptome = 's3://rnaseq-nf/data/ggal/transcript.fa'
101-
}
102-
10399
'google-batch' {
104-
params.transcriptome = 'gs://rnaseq-nf/data/ggal/transcript.fa'
105-
params.reads = 'gs://rnaseq-nf/data/ggal/gut_{1,2}.fq'
106100
params.multiqc = 'gs://rnaseq-nf/multiqc'
107101
process.executor = 'google-batch'
108102
process.container = 'docker.io/nextflow/rnaseq-nf:v1.3.1'
@@ -113,12 +107,6 @@ profiles {
113107
google.region = 'europe-west2'
114108
}
115109

116-
'gs-data' {
117-
process.container = 'docker.io/nextflow/rnaseq-nf:v1.3.1'
118-
params.transcriptome = 'gs://rnaseq-nf/data/ggal/transcript.fa'
119-
params.reads = 'gs://rnaseq-nf/data/ggal/gut_{1,2}.fq'
120-
}
121-
122110
'azure-batch' {
123111
process.container = 'docker.io/nextflow/rnaseq-nf:v1.3.1'
124112
workDir = 'az://nf-scratch/work'

0 commit comments

Comments
 (0)