From 4252806bb8591334eed559071e1abe7bd68b6a7a Mon Sep 17 00:00:00 2001 From: Ben Sherman Date: Mon, 22 Apr 2024 18:24:53 -0500 Subject: [PATCH] Refactor ext config as process inputs Signed-off-by: Ben Sherman --- modules/local/bedtools_genomecov/main.nf | 2 ++ .../local/bedtools_genomecov/nextflow.config | 8 -------- modules/local/star_align_igenomes/main.nf | 17 ++++++++++++++++ modules/nf-core/bbmap/bbsplit/main.nf | 2 ++ modules/nf-core/bbmap/bbsplit/nextflow.config | 7 ------- modules/nf-core/gffread/main.nf | 2 +- modules/nf-core/multiqc/main.nf | 4 ++++ modules/nf-core/multiqc/nextflow.config | 8 -------- modules/nf-core/preseq/lcextrap/main.nf | 2 ++ .../nf-core/preseq/lcextrap/nextflow.config | 9 --------- modules/nf-core/sortmerna/main.nf | 2 ++ modules/nf-core/sortmerna/nextflow.config | 7 ------- modules/nf-core/star/align/main.nf | 17 ++++++++++++++++ modules/nf-core/stringtie/stringtie/main.nf | 6 ++++++ .../stringtie/stringtie/nextflow.config | 12 ----------- modules/nf-core/subread/featurecounts/main.nf | 8 ++++++++ .../subread/featurecounts/nextflow.config | 13 ------------ nextflow.config | 2 ++ subworkflows/local/align_star/main.nf | 4 ++-- subworkflows/local/align_star/nextflow.config | 20 ------------------- subworkflows/local/prepare_genome/main.nf | 2 +- .../local/prepare_genome/nextflow.config | 4 ---- workflows/rnaseq/main.nf | 8 ++++++-- workflows/rnaseq/nextflow.config | 8 -------- 24 files changed, 72 insertions(+), 102 deletions(-) delete mode 100644 modules/local/bedtools_genomecov/nextflow.config delete mode 100644 modules/nf-core/bbmap/bbsplit/nextflow.config delete mode 100644 modules/nf-core/multiqc/nextflow.config delete mode 100644 modules/nf-core/preseq/lcextrap/nextflow.config delete mode 100644 modules/nf-core/sortmerna/nextflow.config delete mode 100644 modules/nf-core/stringtie/stringtie/nextflow.config delete mode 100644 modules/nf-core/subread/featurecounts/nextflow.config delete mode 100644 subworkflows/local/align_star/nextflow.config diff --git a/modules/local/bedtools_genomecov/main.nf b/modules/local/bedtools_genomecov/main.nf index 0a0fb3c8b..74d7767be 100644 --- a/modules/local/bedtools_genomecov/main.nf +++ b/modules/local/bedtools_genomecov/main.nf @@ -7,6 +7,8 @@ process BEDTOOLS_GENOMECOV { 'https://depot.galaxyproject.org/singularity/bedtools:2.30.0--hc088bd4_0' : 'biocontainers/bedtools:2.30.0--hc088bd4_0' }" + ext args: '-split -du' + input: tuple val(meta), path(bam) diff --git a/modules/local/bedtools_genomecov/nextflow.config b/modules/local/bedtools_genomecov/nextflow.config deleted file mode 100644 index f49fe8468..000000000 --- a/modules/local/bedtools_genomecov/nextflow.config +++ /dev/null @@ -1,8 +0,0 @@ - -if (!params.skip_alignment && !params.skip_bigwig) { - process { - withName: 'BEDTOOLS_GENOMECOV' { - ext.args = '-split -du' - } - } -} diff --git a/modules/local/star_align_igenomes/main.nf b/modules/local/star_align_igenomes/main.nf index b412a7e5c..47a4efc8c 100644 --- a/modules/local/star_align_igenomes/main.nf +++ b/modules/local/star_align_igenomes/main.nf @@ -7,6 +7,21 @@ process STAR_ALIGN_IGENOMES { 'https://depot.galaxyproject.org/singularity/mulled-v2-1fa26d1ce03c295fe2fdcf85831a92fbcbd7e8c2:59cdd445419f14abac76b31dd0d71217994cbcc9-0' : 'biocontainers/mulled-v2-1fa26d1ce03c295fe2fdcf85831a92fbcbd7e8c2:59cdd445419f14abac76b31dd0d71217994cbcc9-0' }" + ext args: { [ + '--quantMode TranscriptomeSAM', + '--twopassMode Basic', + '--outSAMtype BAM Unsorted', + '--readFilesCommand zcat', + '--runRNGseed 0', + '--outFilterMultimapNmax 20', + '--alignSJDBoverhangMin 1', + '--outSAMattributes NH HI AS NM MD', + '--quantTranscriptomeBan Singleend', + '--outSAMstrandField intronMotif', + save_unaligned ? '--outReadsUnmapped Fastx' : '', + extra_args ? extra_args.split("\\s(?=--)") : '' + ].flatten().unique(false).join(' ').trim() } + input: tuple val(meta), path(reads) tuple val(meta2), path(index) @@ -14,6 +29,8 @@ process STAR_ALIGN_IGENOMES { val star_ignore_sjdbgtf val seq_platform val seq_center + val save_unaligned + val extra_args output: tuple val(meta), path('*d.out.bam') , emit: bam diff --git a/modules/nf-core/bbmap/bbsplit/main.nf b/modules/nf-core/bbmap/bbsplit/main.nf index 81460019a..a5fe936ed 100644 --- a/modules/nf-core/bbmap/bbsplit/main.nf +++ b/modules/nf-core/bbmap/bbsplit/main.nf @@ -8,6 +8,8 @@ process BBMAP_BBSPLIT { 'https://depot.galaxyproject.org/singularity/bbmap:39.01--h5c4e2a8_0': 'biocontainers/bbmap:39.01--h5c4e2a8_0' }" + ext args: 'build=1 ambiguous2=all maxindel=150000' + input: tuple val(meta), path(reads) path index diff --git a/modules/nf-core/bbmap/bbsplit/nextflow.config b/modules/nf-core/bbmap/bbsplit/nextflow.config deleted file mode 100644 index 0c37662da..000000000 --- a/modules/nf-core/bbmap/bbsplit/nextflow.config +++ /dev/null @@ -1,7 +0,0 @@ -if (!params.skip_bbsplit) { - process { - withName: 'BBMAP_BBSPLIT' { - ext.args = 'build=1 ambiguous2=all maxindel=150000' - } - } -} \ No newline at end of file diff --git a/modules/nf-core/gffread/main.nf b/modules/nf-core/gffread/main.nf index d8a473e0a..dff614738 100644 --- a/modules/nf-core/gffread/main.nf +++ b/modules/nf-core/gffread/main.nf @@ -9,6 +9,7 @@ process GFFREAD { input: path gff + val args output: path "*.gtf" , emit: gtf , optional: true @@ -19,7 +20,6 @@ process GFFREAD { task.ext.when == null || task.ext.when script: - def args = task.ext.args ?: '' def prefix = task.ext.prefix ?: "${gff.baseName}" def extension = args.contains("-T") ? 'gtf' : 'gffread.gff3' """ diff --git a/modules/nf-core/multiqc/main.nf b/modules/nf-core/multiqc/main.nf index 647fbd7b2..5a7de5903 100644 --- a/modules/nf-core/multiqc/main.nf +++ b/modules/nf-core/multiqc/main.nf @@ -6,10 +6,14 @@ process MULTIQC { 'https://depot.galaxyproject.org/singularity/multiqc:1.20--pyhdfd78af_0' : 'biocontainers/multiqc:1.20--pyhdfd78af_0' }" + ext args: { multiqc_title ? "--title \"$multiqc_title\"" : '' }, + prefix: "multiqc_report" + input: path multiqc_files, stageAs: "?/*" path(multiqc_config) path(extra_multiqc_config) + path(multiqc_title) path(multiqc_logo) output: diff --git a/modules/nf-core/multiqc/nextflow.config b/modules/nf-core/multiqc/nextflow.config deleted file mode 100644 index 0f1fffdda..000000000 --- a/modules/nf-core/multiqc/nextflow.config +++ /dev/null @@ -1,8 +0,0 @@ -if (!params.skip_multiqc) { - process { - withName: 'MULTIQC' { - ext.args = { params.multiqc_title ? "--title \"$params.multiqc_title\"" : '' } - ext.prefix = "multiqc_report" - } - } -} \ No newline at end of file diff --git a/modules/nf-core/preseq/lcextrap/main.nf b/modules/nf-core/preseq/lcextrap/main.nf index e555c4b7c..5d1b196bd 100644 --- a/modules/nf-core/preseq/lcextrap/main.nf +++ b/modules/nf-core/preseq/lcextrap/main.nf @@ -8,6 +8,8 @@ process PRESEQ_LCEXTRAP { 'https://depot.galaxyproject.org/singularity/preseq:3.1.2--h445547b_2': 'biocontainers/preseq:3.1.2--h445547b_2' }" + ext args: '-verbose -bam -seed 1 -seg_len 100000000' + input: tuple val(meta), path(bam) diff --git a/modules/nf-core/preseq/lcextrap/nextflow.config b/modules/nf-core/preseq/lcextrap/nextflow.config deleted file mode 100644 index fdb888749..000000000 --- a/modules/nf-core/preseq/lcextrap/nextflow.config +++ /dev/null @@ -1,9 +0,0 @@ -if (!params.skip_alignment && !params.skip_qc) { - if (!params.skip_preseq) { - process { - withName: 'PRESEQ_LCEXTRAP' { - ext.args = '-verbose -bam -seed 1 -seg_len 100000000' - } - } - } -} \ No newline at end of file diff --git a/modules/nf-core/sortmerna/main.nf b/modules/nf-core/sortmerna/main.nf index ad7fbdadc..86dc5594e 100644 --- a/modules/nf-core/sortmerna/main.nf +++ b/modules/nf-core/sortmerna/main.nf @@ -7,6 +7,8 @@ process SORTMERNA { 'https://depot.galaxyproject.org/singularity/sortmerna:4.3.6--h9ee0642_0' : 'biocontainers/sortmerna:4.3.6--h9ee0642_0' }" + ext args: '--num_alignments 1 -v' + input: tuple val(meta), path(reads) path fastas diff --git a/modules/nf-core/sortmerna/nextflow.config b/modules/nf-core/sortmerna/nextflow.config deleted file mode 100644 index 2f60c9b7b..000000000 --- a/modules/nf-core/sortmerna/nextflow.config +++ /dev/null @@ -1,7 +0,0 @@ -if (params.remove_ribo_rna) { - process { - withName: 'SORTMERNA' { - ext.args = '--num_alignments 1 -v' - } - } -} \ No newline at end of file diff --git a/modules/nf-core/star/align/main.nf b/modules/nf-core/star/align/main.nf index 8e9c48b1c..627405634 100644 --- a/modules/nf-core/star/align/main.nf +++ b/modules/nf-core/star/align/main.nf @@ -7,6 +7,21 @@ process STAR_ALIGN { 'https://depot.galaxyproject.org/singularity/mulled-v2-1fa26d1ce03c295fe2fdcf85831a92fbcbd7e8c2:ded3841da0194af2701c780e9b3d653a85d27489-0' : 'biocontainers/mulled-v2-1fa26d1ce03c295fe2fdcf85831a92fbcbd7e8c2:ded3841da0194af2701c780e9b3d653a85d27489-0' }" + ext args: { [ + '--quantMode TranscriptomeSAM', + '--twopassMode Basic', + '--outSAMtype BAM Unsorted', + '--readFilesCommand zcat', + '--runRNGseed 0', + '--outFilterMultimapNmax 20', + '--alignSJDBoverhangMin 1', + '--outSAMattributes NH HI AS NM MD', + '--quantTranscriptomeBan Singleend', + '--outSAMstrandField intronMotif', + save_unaligned ? '--outReadsUnmapped Fastx' : '', + extra_args ? extra_args.split("\\s(?=--)") : '' + ].flatten().unique(false).join(' ').trim() } + input: tuple val(meta), path(reads, stageAs: "input*/*") tuple val(meta2), path(index) @@ -14,6 +29,8 @@ process STAR_ALIGN { val star_ignore_sjdbgtf val seq_platform val seq_center + val save_unaligned + val extra_args output: tuple val(meta), path('*Log.final.out') , emit: log_final diff --git a/modules/nf-core/stringtie/stringtie/main.nf b/modules/nf-core/stringtie/stringtie/main.nf index 022880542..a17c11a53 100644 --- a/modules/nf-core/stringtie/stringtie/main.nf +++ b/modules/nf-core/stringtie/stringtie/main.nf @@ -7,9 +7,15 @@ process STRINGTIE_STRINGTIE { 'https://depot.galaxyproject.org/singularity/stringtie:2.2.1--hecb563c_2' : 'biocontainers/stringtie:2.2.1--hecb563c_2' }" + ext args: { [ + '-v', + ignore_gtf ? '' : '-e' + ].join(' ').trim() } + input: tuple val(meta), path(bam) path annotation_gtf + val ignore_gtf output: tuple val(meta), path("*.transcripts.gtf"), emit: transcript_gtf diff --git a/modules/nf-core/stringtie/stringtie/nextflow.config b/modules/nf-core/stringtie/stringtie/nextflow.config deleted file mode 100644 index 03518ca96..000000000 --- a/modules/nf-core/stringtie/stringtie/nextflow.config +++ /dev/null @@ -1,12 +0,0 @@ -if (!params.skip_alignment) { - if (!params.skip_stringtie) { - process { - withName: 'STRINGTIE_STRINGTIE' { - ext.args = { [ - '-v', - params.stringtie_ignore_gtf ? '' : '-e' - ].join(' ').trim() } - } - } - } -} \ No newline at end of file diff --git a/modules/nf-core/subread/featurecounts/main.nf b/modules/nf-core/subread/featurecounts/main.nf index 500fc4a8a..06104aad3 100644 --- a/modules/nf-core/subread/featurecounts/main.nf +++ b/modules/nf-core/subread/featurecounts/main.nf @@ -7,8 +7,16 @@ process SUBREAD_FEATURECOUNTS { 'https://depot.galaxyproject.org/singularity/subread:2.0.1--hed695b0_0' : 'biocontainers/subread:2.0.1--hed695b0_0' }" + ext args: { [ + '-B -C', + "-g $biotype", + "-t $feature_type" + ].join(' ').trim() } + input: tuple val(meta), path(bams), path(annotation) + val biotype + val feature_type output: tuple val(meta), path("*featureCounts.txt") , emit: counts diff --git a/modules/nf-core/subread/featurecounts/nextflow.config b/modules/nf-core/subread/featurecounts/nextflow.config deleted file mode 100644 index c75038ca9..000000000 --- a/modules/nf-core/subread/featurecounts/nextflow.config +++ /dev/null @@ -1,13 +0,0 @@ -if (!params.skip_alignment && !params.skip_qc) { - if (!params.skip_biotype_qc && params.featurecounts_group_type) { - process { - withName: 'SUBREAD_FEATURECOUNTS' { - ext.args = { [ - '-B -C', - params.gencode ? "-g gene_type" : "-g $params.featurecounts_group_type", - "-t $params.featurecounts_feature_type" - ].join(' ').trim() } - } - } - } -} diff --git a/nextflow.config b/nextflow.config index 3b4823eac..287fef419 100644 --- a/nextflow.config +++ b/nextflow.config @@ -26,6 +26,8 @@ params { igenomes_base = 's3://ngi-igenomes/igenomes' igenomes_ignore = false + gffread_args = '--keep-exon-attrs -F -T' + // UMI handling with_umi = false skip_umi_extract = false diff --git a/subworkflows/local/align_star/main.nf b/subworkflows/local/align_star/main.nf index 6b6f5b783..ae88dc3a1 100644 --- a/subworkflows/local/align_star/main.nf +++ b/subworkflows/local/align_star/main.nf @@ -33,7 +33,7 @@ workflow ALIGN_STAR { ch_fastq = Channel.empty() ch_tab = Channel.empty() if (is_aws_igenome) { - STAR_ALIGN_IGENOMES ( reads, index, gtf, star_ignore_sjdbgtf, seq_platform, seq_center ) + STAR_ALIGN_IGENOMES ( reads, index, gtf, star_ignore_sjdbgtf, seq_platform, seq_center, params.save_unaligned, params.extra_star_align_args ) ch_orig_bam = STAR_ALIGN_IGENOMES.out.bam ch_log_final = STAR_ALIGN_IGENOMES.out.log_final ch_log_out = STAR_ALIGN_IGENOMES.out.log_out @@ -44,7 +44,7 @@ workflow ALIGN_STAR { ch_tab = STAR_ALIGN_IGENOMES.out.tab ch_versions = ch_versions.mix(STAR_ALIGN_IGENOMES.out.versions.first()) } else { - STAR_ALIGN ( reads, index, gtf, star_ignore_sjdbgtf, seq_platform, seq_center ) + STAR_ALIGN ( reads, index, gtf, star_ignore_sjdbgtf, seq_platform, seq_center, params.save_unaligned, params.extra_star_align_args ) ch_orig_bam = STAR_ALIGN.out.bam ch_log_final = STAR_ALIGN.out.log_final ch_log_out = STAR_ALIGN.out.log_out diff --git a/subworkflows/local/align_star/nextflow.config b/subworkflows/local/align_star/nextflow.config deleted file mode 100644 index beeadc15a..000000000 --- a/subworkflows/local/align_star/nextflow.config +++ /dev/null @@ -1,20 +0,0 @@ -if (!params.skip_alignment && params.aligner == 'star_salmon') { - process { - withName: '.*:ALIGN_STAR:STAR_ALIGN|.*:ALIGN_STAR:STAR_ALIGN_IGENOMES' { - ext.args = { [ - '--quantMode TranscriptomeSAM', - '--twopassMode Basic', - '--outSAMtype BAM Unsorted', - '--readFilesCommand zcat', - '--runRNGseed 0', - '--outFilterMultimapNmax 20', - '--alignSJDBoverhangMin 1', - '--outSAMattributes NH HI AS NM MD', - '--quantTranscriptomeBan Singleend', - '--outSAMstrandField intronMotif', - params.save_unaligned ? '--outReadsUnmapped Fastx' : '', - params.extra_star_align_args ? params.extra_star_align_args.split("\\s(?=--)") : '' - ].flatten().unique(false).join(' ').trim() } - } - } -} diff --git a/subworkflows/local/prepare_genome/main.nf b/subworkflows/local/prepare_genome/main.nf index e145a4dcc..30f9aa60f 100644 --- a/subworkflows/local/prepare_genome/main.nf +++ b/subworkflows/local/prepare_genome/main.nf @@ -90,7 +90,7 @@ workflow PREPARE_GENOME { } else { ch_gff = Channel.value(file(gff)) } - ch_gtf = GFFREAD ( ch_gff ).gtf + ch_gtf = GFFREAD ( ch_gff, params.gffread_args ?: '' ).gtf ch_versions = ch_versions.mix(GFFREAD.out.versions) } diff --git a/subworkflows/local/prepare_genome/nextflow.config b/subworkflows/local/prepare_genome/nextflow.config index 62d84f340..a3521da32 100644 --- a/subworkflows/local/prepare_genome/nextflow.config +++ b/subworkflows/local/prepare_genome/nextflow.config @@ -3,10 +3,6 @@ process { ext.args2 = '--no-same-owner' } - withName: 'GFFREAD' { - ext.args = '--keep-exon-attrs -F -T' - } - withName: 'SALMON_INDEX' { ext.args = { [ params.gencode ? '--gencode' : '', diff --git a/workflows/rnaseq/main.nf b/workflows/rnaseq/main.nf index ec38b90fb..6b0374d2b 100755 --- a/workflows/rnaseq/main.nf +++ b/workflows/rnaseq/main.nf @@ -576,7 +576,8 @@ workflow RNASEQ { if (!params.skip_alignment && !params.skip_stringtie) { STRINGTIE_STRINGTIE ( ch_genome_bam, - ch_gtf + ch_gtf, + params.stringtie_ignore_gtf ) ch_versions = ch_versions.mix(STRINGTIE_STRINGTIE.out.versions.first()) } @@ -600,7 +601,9 @@ workflow RNASEQ { .set { ch_featurecounts } SUBREAD_FEATURECOUNTS ( - ch_featurecounts + ch_featurecounts, + biotype, + params.featurecounts_feature_type ) ch_versions = ch_versions.mix(SUBREAD_FEATURECOUNTS.out.versions.first()) @@ -777,6 +780,7 @@ workflow RNASEQ { ch_multiqc_files.collect(), ch_multiqc_config.toList(), ch_multiqc_custom_config.toList(), + params.multiqc_title, ch_multiqc_logo.toList() ) ch_multiqc_report = MULTIQC.out.report diff --git a/workflows/rnaseq/nextflow.config b/workflows/rnaseq/nextflow.config index 487c172b6..263cd4b99 100644 --- a/workflows/rnaseq/nextflow.config +++ b/workflows/rnaseq/nextflow.config @@ -1,11 +1,3 @@ -includeConfig "../../modules/local/bedtools_genomecov/nextflow.config" -includeConfig "../../modules/nf-core/bbmap/bbsplit/nextflow.config" -includeConfig "../../modules/nf-core/multiqc/nextflow.config" -includeConfig "../../modules/nf-core/preseq/lcextrap/nextflow.config" -includeConfig "../../modules/nf-core/sortmerna/nextflow.config" -includeConfig "../../modules/nf-core/stringtie/stringtie/nextflow.config" -includeConfig "../../modules/nf-core/subread/featurecounts/nextflow.config" -includeConfig "../../subworkflows/local/align_star/nextflow.config" includeConfig "../../subworkflows/local/quantify_rsem/nextflow.config" includeConfig "../../subworkflows/nf-core/bam_markduplicates_picard/nextflow.config" includeConfig "../../subworkflows/nf-core/fastq_align_hisat2/nextflow.config"