Skip to content

Commit f0f4e2d

Browse files
committed
Update workflow params/outputs, use process name as operator closure
Signed-off-by: Ben Sherman <[email protected]>
1 parent 4ea7375 commit f0f4e2d

File tree

6 files changed

+57
-69
lines changed

6 files changed

+57
-69
lines changed

main.nf

Lines changed: 28 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,14 @@ include { MULTIQC } from './modules/multiqc'
1818
* `params.reads` can be specified as `--reads '...'`.
1919
*/
2020
params {
21-
reads: String {
22-
description 'The input read-pair files'
23-
faIcon 'fas fa-folder-open'
24-
defaultValue "${projectDir}/data/ggal/ggal_gut_{1,2}.fq"
25-
}
21+
// The input read-pair files
22+
reads: String = "${projectDir}/data/ggal/ggal_gut_{1,2}.fq"
2623

27-
transcriptome: Path {
28-
description 'The input transcriptome file'
29-
faIcon 'fas fa-folder-open'
30-
defaultValue "${projectDir}/data/ggal/ggal_1_48850000_49020000.Ggal71.500bpflank.fa"
31-
}
24+
// The input transcriptome file
25+
transcriptome: Path = "${projectDir}/data/ggal/ggal_1_48850000_49020000.Ggal71.500bpflank.fa"
3226

33-
multiqc: Path {
34-
description 'Directory containing multiqc configuration'
35-
faIcon 'fas fa-folder-open'
36-
defaultValue "${projectDir}/multiqc"
37-
}
27+
// Directory containing multiqc configuration
28+
multiqc: Path = "${projectDir}/multiqc"
3829
}
3930

4031
/*
@@ -43,36 +34,34 @@ params {
4334
workflow {
4435
main:
4536
log.info """\
46-
R N A S E Q - N F P I P E L I N E
47-
===================================
48-
transcriptome: ${params.transcriptome}
49-
reads : ${params.reads}
50-
outdir : ${workflow.outputDir}
37+
R N A S E Q - N F P I P E L I N E
38+
===================================
39+
transcriptome: ${params.transcriptome}
40+
reads : ${params.reads}
41+
outdir : ${workflow.outputDir}
5142
""".stripIndent()
5243

53-
def pairs = Channel.fromFilePairs(params.reads).map { (id, reads) ->
54-
new FastqPair(id, reads[0], reads[1])
55-
} // Channel<FastqPair>
56-
57-
def (index, samples) = RNASEQ(pairs, params.transcriptome)
58-
// NamedTuple(index: Path, samples: Channel<Sample>)
44+
pairs = Channel.fromFilePairs(params.reads).map { (id, reads) ->
45+
[id: id, fastq_1: reads[0], fastq_2: reads[1]]
46+
}
5947

60-
def multiqc_files = samples
61-
.scatter { s -> [ s.fastqc, s.quant ] } // Channel<Path>
62-
.collect() // Bag<Path> (future)
48+
rnaseq = RNASEQ(pairs, params.transcriptome)
6349

64-
def summary = MULTIQC( multiqc_files, params.multiqc ) // Path (future)
50+
multiqc_files = rnaseq.samples
51+
.scatter { s -> [ s.fastqc, s.quant ] }
52+
.collect()
6553

66-
workflow.onComplete {
67-
log.info ( workflow.success
68-
? "\nDone! Open the following report in your browser --> ${workflow.outputDir}/multiqc_report.html\n"
69-
: "Oops .. something went wrong" )
70-
}
54+
summary = MULTIQC(multiqc_files, params.multiqc)
7155

7256
publish:
73-
index >> 'index'
74-
samples >> 'samples'
75-
summary >> 'summary'
57+
index = rnaseq.index
58+
samples = rnaseq.samples
59+
summary = summary
60+
61+
onComplete:
62+
log.info ( workflow.success
63+
? "\nDone! Open the following report in your browser --> ${workflow.outputDir}/multiqc_report.html\n"
64+
: "Oops .. something went wrong" )
7665
}
7766

7867
/*
@@ -83,7 +72,7 @@ output {
8372
path '.'
8473
}
8574

86-
samples: Sample {
75+
samples: Channel<Sample> {
8776
path { sample -> sample.id }
8877
index {
8978
path 'samples.json'

modules/fastqc/main.nf

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11

22
process FASTQC {
3-
tag "FASTQC on $sample_id"
3+
tag "FASTQC on $id"
44
conda 'bioconda::fastqc=0.12.1'
55

66
input:
7-
sample_id : String
8-
fastq_1 : Path
9-
fastq_2 : Path
7+
id : String
8+
fastq_1 : Path
9+
fastq_2 : Path
10+
11+
output:
12+
id : String = id
13+
quant : Path = file("fastqc_${id}_logs")
1014

1115
script:
1216
"""
13-
fastqc.sh $sample_id "$fastq_1 $fastq_2"
17+
fastqc.sh $id "$fastq_1 $fastq_2"
1418
"""
15-
16-
output:
17-
file("fastqc_${sample_id}_logs")
1819
}

modules/index/main.nf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ process INDEX {
66
input:
77
transcriptome : Path
88

9+
output:
10+
file('index')
11+
912
script:
1013
"""
1114
salmon index --threads $task.cpus -t $transcriptome -i index
1215
"""
13-
14-
output:
15-
file('index')
1616
}

modules/multiqc/main.nf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ process MULTIQC {
66
inputs : Bag<Path>
77
config : Path
88

9+
output:
10+
file('multiqc_report.html')
11+
912
script:
1013
"""
1114
cp $config/* .
1215
echo "custom_logo: \$PWD/logo.png" >> multiqc_config.yaml
1316
multiqc -o multiqc_report.html .
1417
"""
15-
16-
output:
17-
file('multiqc_report.html')
1818
}

modules/quant/main.nf

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11

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

66
input:
7-
index : Path
8-
sample_id : String
9-
fastq_1 : Path
10-
fastq_2 : Path
7+
index : Path
8+
id : String
9+
fastq_1 : Path
10+
fastq_2 : Path
11+
12+
output:
13+
id : String = id
14+
quant : Path = file("quant_${id}")
1115

1216
script:
1317
"""
14-
salmon quant --threads $task.cpus --libType=U -i $index -1 ${fastq_1} -2 ${fastq_2} -o quant_${sample_id}
18+
salmon quant --threads $task.cpus --libType=U -i $index -1 ${fastq_1} -2 ${fastq_2} -o quant_${id}
1519
"""
16-
17-
output:
18-
file("quant_${sample_id}")
1920
}

modules/rnaseq.nf

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,10 @@ workflow RNASEQ {
88
transcriptome : Path
99

1010
main:
11-
def index = INDEX( transcriptome ) // Path (future)
12-
13-
def samples = pairs.map { (id, fastq_1, fastq_2) ->
14-
def fastqc = FASTQC(id, fastq_1, fastq_2)
15-
def quant = QUANT(index, id, fastq_1, fastq_2)
16-
new Sample(id, fastqc, quant)
17-
} // Channel<Sample>
11+
index = INDEX(transcriptome)
12+
fastqc = pairs.map(FASTQC)
13+
quant = pairs.map(QUANT, index: index)
14+
samples = fastqc.join(quant, 'id')
1815

1916
emit:
2017
index : Path

0 commit comments

Comments
 (0)