Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workflow output definition #1227

Draft
wants to merge 15 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

nextflow.enable.dsl = 2
nextflow.preview.output = true

/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -164,6 +165,11 @@ workflow {
)
}

output {
directory params.outdir
mode params.publish_dir_mode
}
Comment on lines +168 to +171
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be set in nextflow.config @bentsherman?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not currently, but should be considered as a future improvement. If we don't need the target-specific config in the output block, would be better IMO to make these config settings instead of pipeline code + params.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer this as a scope in the config rather than in the main.nf.

I was also thinking to allow different modes for files matching different patterns or properties, e.g. large files are symlinked, rather than copied, but this is an extra.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that they should be config. Much less flexible for the user if you have to define a param just to make it configurable

For now you can customize things like the mode for specific targets, though that it not as granular as what you describe


/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
THE END
Expand Down
3 changes: 0 additions & 3 deletions modules/local/bedtools_genomecov/nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ if (!params.skip_alignment && !params.skip_bigwig) {
process {
withName: 'BEDTOOLS_GENOMECOV' {
ext.args = '-split -du'
publishDir = [
enabled: false
]
}
}
}
10 changes: 10 additions & 0 deletions modules/local/deseq2_qc/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ process DESEQ2_QC {
path "size_factors" , optional:true, emit: size_factors
path "versions.yml" , emit: versions

publish:
pdf >> 'deseq2'
Comment on lines +27 to +28
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was surprising to still see the publish directive in the process block. Why this way then instead of:

 output:
    path "*.pdf"                , optional:true, emit: pdf, publish: 'deseq2'

i.e. instead of making publish and extra option for the path type

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I wanted the publish definition to be in one place so that it's easier to review. But also, I think the separate publish: section will work better with static typed outputs

rdata >> 'deseq2'
pca_txt >> 'deseq2'
pca_multiqc >> 'deseq2'
dists_txt >> 'deseq2'
dists_multiqc >> 'deseq2'
log >> 'deseq2'
size_factors >> 'deseq2'

when:
task.ext.when == null || task.ext.when

Expand Down
4 changes: 4 additions & 0 deletions modules/local/dupradar/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ process DUPRADAR {
tuple val(meta), path("*_mqc.txt"), emit: multiqc
path "versions.yml" , emit: versions

publish:
pdf >> 'dupradar/'
txt >> 'dupradar/'

when:
task.ext.when == null || task.ext.when

Expand Down
35 changes: 0 additions & 35 deletions modules/local/dupradar/nextflow.config

This file was deleted.

3 changes: 3 additions & 0 deletions modules/local/multiqc_custom_biotype/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ process MULTIQC_CUSTOM_BIOTYPE {
tuple val(meta), path("*.tsv"), emit: tsv
path "versions.yml" , emit: versions

publish:
tsv >> 'featurecounts/'

when:
task.ext.when == null || task.ext.when

Expand Down
13 changes: 0 additions & 13 deletions modules/local/multiqc_custom_biotype/nextflow.config

This file was deleted.

13 changes: 0 additions & 13 deletions modules/nf-core/bbmap/bbsplit/nextflow.config

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions modules/nf-core/cat/fastq/main.nf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 0 additions & 9 deletions modules/nf-core/cat/fastq/nextflow.config

This file was deleted.

5 changes: 5 additions & 0 deletions modules/nf-core/multiqc/main.nf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions modules/nf-core/multiqc/nextflow.config

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions modules/nf-core/preseq/lcextrap/main.nf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions modules/nf-core/preseq/lcextrap/nextflow.config

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions modules/nf-core/qualimap/rnaseq/main.nf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 0 additions & 13 deletions modules/nf-core/qualimap/rnaseq/nextflow.config

This file was deleted.

4 changes: 4 additions & 0 deletions modules/nf-core/sortmerna/main.nf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 0 additions & 13 deletions modules/nf-core/sortmerna/nextflow.config

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions modules/nf-core/stringtie/stringtie/main.nf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions modules/nf-core/stringtie/stringtie/nextflow.config

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions modules/nf-core/subread/featurecounts/main.nf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 0 additions & 13 deletions modules/nf-core/subread/featurecounts/nextflow.config

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 0 additions & 9 deletions nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,6 @@ params {

}

// Default publishing logic for pipeline
process {
publishDir = [
path: { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" },
mode: params.publish_dir_mode,
saveAs: { filename -> filename.equals('versions.yml') ? null : filename }
]
}

// Load base.config by default for all pipelines
includeConfig 'conf/base.config'

Expand Down
10 changes: 10 additions & 0 deletions subworkflows/local/align_star/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ workflow ALIGN_STAR {
BAM_SORT_STATS_SAMTOOLS ( ch_orig_bam, fasta )
ch_versions = ch_versions.mix(BAM_SORT_STATS_SAMTOOLS.out.versions)

publish:
ch_orig_bam >> (params.save_align_intermeds || params.save_umi_intermeds ? 'star_salmon/' : null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine for specific pipelines, but makes module reusability across pipelines more cumbersome. If we need to have ternary operators in every nf-core module to control whether an output is published, this would make the pipeline schema, potentially huge.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, I cut some corners here by not passing the params as workflow inputs. In the final implementation I would do that so that you can choose whether to expose it as a param in your own pipeline

ch_log_final >> 'star_salmon/log/'
ch_log_out >> 'star_salmon/log/'
ch_log_progress >> 'star_salmon/log/'
ch_bam_sorted >> (params.save_align_intermeds || params.save_umi_intermeds ? 'star_salmon/' : null)
ch_bam_transcript >> (params.save_align_intermeds || params.save_umi_intermeds ? 'star_salmon/' : null)
ch_fastq >> (params.save_unaligned ? 'star_salmon/unmapped/' : null)
ch_tab >> 'star_salmon/log/'

emit:
orig_bam = ch_orig_bam // channel: [ val(meta), bam ]
log_final = ch_log_final // channel: [ val(meta), log_final ]
Expand Down
19 changes: 0 additions & 19 deletions subworkflows/local/align_star/nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,6 @@ if (!params.skip_alignment && params.aligner == 'star_salmon') {
params.save_unaligned ? '--outReadsUnmapped Fastx' : '',
params.extra_star_align_args ? params.extra_star_align_args.split("\\s(?=--)") : ''
].flatten().unique(false).join(' ').trim() }
publishDir = [
[
path: { "${params.outdir}/${params.aligner}/log" },
mode: params.publish_dir_mode,
pattern: '*.{out,tab}'
],
[
path: { params.save_align_intermeds ? "${params.outdir}/${params.aligner}" : params.outdir },
mode: params.publish_dir_mode,
pattern: '*.bam',
saveAs: { params.save_align_intermeds ? it : null }
],
[
path: { params.save_unaligned ? "${params.outdir}/${params.aligner}/unmapped" : params.outdir },
mode: params.publish_dir_mode,
pattern: '*.fastq.gz',
saveAs: { params.save_unaligned ? it : null }
]
]
}
}
}
Loading