Skip to content

Commit 74c1c82

Browse files
pinin4fjordsclaude
andcommitted
demo: Convert workflow outputs to use Nextflow record types
Demonstrates how record types (nextflow-io/nextflow#6679) would simplify the workflow outputs pattern by replacing groups of related tuple-based channels with single record-typed channels. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 55a7ab0 commit 74c1c82

38 files changed

Lines changed: 1158 additions & 1366 deletions

File tree

main.nf

Lines changed: 93 additions & 143 deletions
Large diffs are not rendered by default.

modules/local/deseq2_qc/main.nf

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
nextflow.preview.types = true
2+
3+
record DeSeq2Result {
4+
pdf: Path?
5+
rdata: Path?
6+
pca_txt: Path?
7+
pca_multiqc: Path?
8+
dists_txt: Path?
9+
dists_multiqc: Path?
10+
log: Path?
11+
size_factors: Path?
12+
}
13+
114
process DESEQ2_QC {
215
label "process_medium"
316

@@ -9,20 +22,23 @@ process DESEQ2_QC {
922
'community.wave.seqera.io/library/r-base_r-optparse_r-ggplot2_r-rcolorbrewer_pruned:9e75394d0bc21987' }"
1023

1124
input:
12-
path counts
13-
path pca_header_multiqc
14-
path clustering_header_multiqc
25+
counts: Path
26+
pca_header_multiqc: Path
27+
clustering_header_multiqc: Path
1528

1629
output:
17-
path "*.pdf" , optional:true, emit: pdf
18-
path "*.RData" , optional:true, emit: rdata
19-
path "*pca.vals.txt" , optional:true, emit: pca_txt
20-
path "*pca.vals_mqc.tsv" , optional:true, emit: pca_multiqc
21-
path "*sample.dists.txt" , optional:true, emit: dists_txt
22-
path "*sample.dists_mqc.tsv", optional:true, emit: dists_multiqc
23-
path "*.log" , optional:true, emit: log
24-
path "size_factors" , optional:true, emit: size_factors
25-
path "versions.yml" , emit: versions
30+
record(
31+
pdf: file("*.pdf", optional: true),
32+
rdata: file("*.RData", optional: true),
33+
pca_txt: file("*pca.vals.txt", optional: true),
34+
pca_multiqc: file("*pca.vals_mqc.tsv", optional: true),
35+
dists_txt: file("*sample.dists.txt", optional: true),
36+
dists_multiqc: file("*sample.dists_mqc.tsv", optional: true),
37+
log: file("*.log", optional: true),
38+
size_factors: file("size_factors", optional: true)
39+
)
40+
tuple val("${task.process}"), val('r-base'), eval('echo $(R --version 2>&1) | sed "s/^.*R version //; s/ .*$//"'), topic: versions
41+
tuple val("${task.process}"), val('bioconductor-deseq2'), eval('Rscript -e "library(DESeq2); cat(as.character(packageVersion(\'DESeq2\')))"'), topic: versions
2642

2743
when:
2844
task.ext.when == null || task.ext.when
@@ -54,12 +70,6 @@ process DESEQ2_QC {
5470
cat clustering_header.tmp *.sample.dists.txt > ${label_lower}.sample.dists_mqc.tsv
5571
rm clustering_header.tmp
5672
fi
57-
58-
cat <<-END_VERSIONS > versions.yml
59-
"${task.process}":
60-
r-base: \$(echo \$(R --version 2>&1) | sed 's/^.*R version //; s/ .*\$//')
61-
bioconductor-deseq2: \$(Rscript -e "library(DESeq2); cat(as.character(packageVersion('DESeq2')))")
62-
END_VERSIONS
6373
"""
6474

6575
stub:
@@ -81,11 +91,5 @@ process DESEQ2_QC {
8191
do
8292
touch size_factors/\${i}.size_factors.RData
8393
done
84-
85-
cat <<-END_VERSIONS >versions.yml
86-
"${task.process}":
87-
r-base: \$(echo \$(R --version 2>&1) | sed 's/^.*R version //; s/ .*\$//')
88-
bioconductor-deseq2: \$(Rscript -e "library(DESeq2); cat(as.character(packageVersion('DESeq2')))")
89-
END_VERSIONS
9094
"""
9195
}

modules/local/rsem_merge_counts/main.nf

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
nextflow.preview.types = true
2+
3+
record RsemMergedResult {
4+
counts_gene: Path
5+
tpm_gene: Path
6+
counts_transcript: Path
7+
tpm_transcript: Path
8+
genes_long: Path
9+
isoforms_long: Path
10+
}
11+
112
process RSEM_MERGE_COUNTS {
213
label "process_medium"
314

@@ -7,17 +18,19 @@ process RSEM_MERGE_COUNTS {
718
'nf-core/ubuntu:20.04' }"
819

920
input:
10-
path ('genes/*')
11-
path ('isoforms/*')
21+
genes: Path // path ('genes/*')
22+
isoforms: Path // path ('isoforms/*')
1223

1324
output:
14-
path "rsem.merged.gene_counts.tsv" , emit: counts_gene
15-
path "rsem.merged.gene_tpm.tsv" , emit: tpm_gene
16-
path "rsem.merged.transcript_counts.tsv", emit: counts_transcript
17-
path "rsem.merged.transcript_tpm.tsv" , emit: tpm_transcript
18-
path "rsem.merged.genes_long.tsv" , emit: genes_long
19-
path "rsem.merged.isoforms_long.tsv" , emit: isoforms_long
20-
path "versions.yml" , emit: versions
25+
record(
26+
counts_gene: file("rsem.merged.gene_counts.tsv"),
27+
tpm_gene: file("rsem.merged.gene_tpm.tsv"),
28+
counts_transcript: file("rsem.merged.transcript_counts.tsv"),
29+
tpm_transcript: file("rsem.merged.transcript_tpm.tsv"),
30+
genes_long: file("rsem.merged.genes_long.tsv"),
31+
isoforms_long: file("rsem.merged.isoforms_long.tsv")
32+
)
33+
tuple val("${task.process}"), val('sed'), eval('echo $(sed --version 2>&1) | sed "s/^.*GNU sed) //; s/ .*$//"'), topic: versions
2134

2235
when:
2336
task.ext.when == null || task.ext.when
@@ -62,11 +75,6 @@ process RSEM_MERGE_COUNTS {
6275
samplename=`basename \$fileid | sed s/\\.isoforms.results\$//g`
6376
tail -n+2 \$fileid | awk -v sample=\$samplename 'BEGIN{OFS="\t"}{print sample,\$1,\$2,\$3,\$4,\$5,\$6,\$7,\$8}' >> rsem.merged.isoforms_long.tsv
6477
done
65-
66-
cat <<-END_VERSIONS > versions.yml
67-
"${task.process}":
68-
sed: \$(echo \$(sed --version 2>&1) | sed 's/^.*GNU sed) //; s/ .*\$//')
69-
END_VERSIONS
7078
"""
7179

7280
stub:
@@ -77,10 +85,5 @@ process RSEM_MERGE_COUNTS {
7785
touch rsem.merged.transcript_tpm.tsv
7886
touch rsem.merged.genes_long.tsv
7987
touch rsem.merged.isoforms_long.tsv
80-
81-
cat <<-END_VERSIONS > versions.yml
82-
"${task.process}":
83-
sed: \$(echo \$(sed --version 2>&1) | sed 's/^.*GNU sed) //; s/ .*\$//')
84-
END_VERSIONS
8588
"""
8689
}

modules/local/star_align_igenomes/main.nf

Lines changed: 54 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
nextflow.preview.types = true
2+
3+
// Uses the same record type as STAR_ALIGN
4+
record StarAlignResult {
5+
meta: Map
6+
bam: Path?
7+
bam_sorted: Path?
8+
bam_sorted_aligned: Path?
9+
bam_transcript: Path?
10+
bam_unsorted: Path?
11+
log_final: Path
12+
log_out: Path
13+
log_progress: Path
14+
fastq: Path?
15+
tab: Path?
16+
spl_junc_tab: Path?
17+
read_per_gene_tab: Path?
18+
junction: Path?
19+
sam: Path?
20+
wig: Path?
21+
bedgraph: Path?
22+
}
23+
124
process STAR_ALIGN_IGENOMES {
225
tag "$meta.id"
326
label 'process_high'
@@ -8,27 +31,39 @@ process STAR_ALIGN_IGENOMES {
831
'community.wave.seqera.io/library/star_samtools_gawk:79ca42311e583cdc' }"
932

1033
input:
11-
tuple val(meta), path(reads, stageAs: "input*/*")
12-
tuple val(meta2), path(index)
13-
tuple val(meta3), path(gtf)
14-
val star_ignore_sjdbgtf
15-
val seq_platform
16-
val seq_center
34+
(meta: Map, reads: Path): Record
35+
(meta2: Map, index: Path): Record
1736

18-
output:
19-
tuple val(meta), path('*Log.final.out') , emit: log_final
20-
tuple val(meta), path('*Log.out') , emit: log_out
21-
tuple val(meta), path('*Log.progress.out'), emit: log_progress
22-
path "versions.yml" , emit: versions
37+
stage:
38+
stageAs(reads, 'input*/*')
39+
(meta3: Map, gtf: Path): Record
40+
star_ignore_sjdbgtf: String?
41+
seq_platform: String?
42+
seq_center: String?
2343

24-
tuple val(meta), path('*d.out.bam') , optional:true, emit: bam
25-
tuple val(meta), path('*sortedByCoord.out.bam') , optional:true, emit: bam_sorted
26-
tuple val(meta), path('*toTranscriptome.out.bam'), optional:true, emit: bam_transcript
27-
tuple val(meta), path('*Aligned.unsort.out.bam') , optional:true, emit: bam_unsorted
28-
tuple val(meta), path('*fastq.gz') , optional:true, emit: fastq
29-
tuple val(meta), path('*.tab') , optional:true, emit: tab
30-
tuple val(meta), path('*.out.junction') , optional:true, emit: junction
31-
tuple val(meta), path('*.out.sam') , optional:true, emit: sam
44+
output:
45+
record(
46+
meta: meta,
47+
bam: file('*d.out.bam', optional: true),
48+
bam_sorted: file('*sortedByCoord.out.bam', optional: true),
49+
bam_sorted_aligned: file("*.Aligned.sortedByCoord.out.bam", optional: true),
50+
bam_transcript: file('*toTranscriptome.out.bam', optional: true),
51+
bam_unsorted: file('*Aligned.unsort.out.bam', optional: true),
52+
log_final: file('*Log.final.out'),
53+
log_out: file('*Log.out'),
54+
log_progress: file('*Log.progress.out'),
55+
fastq: file('*fastq.gz', optional: true),
56+
tab: file('*.tab', optional: true),
57+
spl_junc_tab: file('*.SJ.out.tab', optional: true),
58+
read_per_gene_tab: file('*.ReadsPerGene.out.tab', optional: true),
59+
junction: file('*.out.junction', optional: true),
60+
sam: file('*.out.sam', optional: true),
61+
wig: file('*.wig', optional: true),
62+
bedgraph: file('*.bg', optional: true)
63+
)
64+
tuple val("${task.process}"), val('star'), eval('STAR --version | sed -e "s/STAR_//g"'), topic: versions
65+
tuple val("${task.process}"), val('samtools'), eval('echo $(samtools --version 2>&1) | sed "s/^.*samtools //; s/Using.*$//"'), topic: versions
66+
tuple val("${task.process}"), val('gawk'), eval('echo $(gawk --version 2>&1) | sed "s/^.*GNU Awk //; s/, .*$//"'), topic: versions
3267

3368
when:
3469
task.ext.when == null || task.ext.when
@@ -65,13 +100,6 @@ process STAR_ALIGN_IGENOMES {
65100
mv ${prefix}.Unmapped.out.mate2 ${prefix}.unmapped_2.fastq
66101
gzip ${prefix}.unmapped_2.fastq
67102
fi
68-
69-
cat <<-END_VERSIONS > versions.yml
70-
"${task.process}":
71-
star: \$(STAR --version | sed -e "s/STAR_//g")
72-
samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
73-
gawk: \$(echo \$(gawk --version 2>&1) | sed 's/^.*GNU Awk //; s/, .*\$//')
74-
END_VERSIONS
75103
"""
76104

77105
stub:
@@ -94,12 +122,5 @@ process STAR_ALIGN_IGENOMES {
94122
touch ${prefix}.out.sam
95123
touch ${prefix}.Signal.UniqueMultiple.str1.out.wig
96124
touch ${prefix}.Signal.UniqueMultiple.str1.out.bg
97-
98-
cat <<-END_VERSIONS > versions.yml
99-
"${task.process}":
100-
star: \$(STAR --version | sed -e "s/STAR_//g")
101-
samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
102-
gawk: \$(echo \$(gawk --version 2>&1) | sed 's/^.*GNU Awk //; s/, .*\$//')
103-
END_VERSIONS
104125
"""
105126
}

modules/nf-core/dupradar/main.nf

Lines changed: 26 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

modules/nf-core/dupradar/templates/dupradar.r

Lines changed: 0 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)