diff --git a/conf/modules.config b/conf/modules.config index 7232e3f9..841826b0 100644 --- a/conf/modules.config +++ b/conf/modules.config @@ -103,13 +103,17 @@ process { withName: FASTP_SINGLE { tag = { "${meta.sample_id}_${meta.library_id}_L${meta.lane}" } - ext.args = [ - params.preprocessing_trim5p != 0 ? "--trim_front1 ${params.preprocessing_trim5p}" : "", - params.preprocessing_trim3p != 0 ? "--trim_tail1 ${params.preprocessing_trim3p}" : "", - params.preprocessing_skipadaptertrim ? "--disable_adapter_trimming" : params.preprocessing_adapterlist ? "" : params.preprocessing_adapter1 ? "--adapter_sequence ${params.preprocessing_adapter1}" : "", - "--length_required ${params.preprocessing_minlength}", - params.preprocessing_fastp_complexityfilter ? "--low_complexity_filter --complexity_threshold ${params.preprocessing_fastp_complexityfilter_threshold}" : "", - ].join(' ').trim() + ext.args = { + [ + params.preprocessing_trim5p != 0 ? "--trim_front1 ${params.preprocessing_trim5p}" : "", + params.preprocessing_trim3p != 0 ? "--trim_tail1 ${params.preprocessing_trim3p}" : "", + params.preprocessing_skipadaptertrim ? "--disable_adapter_trimming" : params.preprocessing_adapterlist ? "" : params.preprocessing_adapter1 ? "--adapter_sequence ${params.preprocessing_adapter1}" : "", + "--length_required ${params.preprocessing_minlength}", + params.preprocessing_fastp_complexityfilter ? "--low_complexity_filter --complexity_threshold ${params.preprocessing_fastp_complexityfilter_threshold}" : "", + params.preprocessing_fastp_disable_polygfilter ? "--disable_trim_poly_g" : "${meta.colour_chemistry}" == 4 ? "--trim_poly_g --poly_g_min_len ${params.preprocessing_fastp_polygfilter_minlength}" : "--disable_trim_poly_g", + params.preprocessing_fastp_polyxfilter_minlength != 0 ? "--trim_poly_x --poly_x_min_len ${params.preprocessing_fastp_polyxfilter_minlength}": "", + ].join(' ').trim() + } ext.prefix = { "${meta.sample_id}_${meta.library_id}_L${meta.lane}" } publishDir = [ [ @@ -128,15 +132,19 @@ process { withName: FASTP_PAIRED { tag = { "${meta.sample_id}_${meta.library_id}_L${meta.lane}" } - ext.args = [ - params.preprocessing_excludeunmerged ? "" : "--include_unmerged", - params.preprocessing_trim5p != 0 ? "--trim_front1 ${params.preprocessing_trim5p} --trim_front2 ${params.preprocessing_trim5p}" : "", - params.preprocessing_trim3p != 0 ? "--trim_tail1 ${params.preprocessing_trim3p} --trim_tail2 ${params.preprocessing_trim3p}" : "", - params.preprocessing_skipadaptertrim ? "--disable_adapter_trimming" : params.preprocessing_adapterlist ? "" : params.preprocessing_adapter1 ? "--adapter_sequence ${params.preprocessing_adapter1}" : "", - params.preprocessing_skipadaptertrim ? "" : params.preprocessing_adapterlist ? "" : params.preprocessing_adapter2 ? "--adapter_sequence_r2 ${params.preprocessing_adapter2}" : "", - "--length_required ${params.preprocessing_minlength}", - params.preprocessing_fastp_complexityfilter ? "--low_complexity_filter --complexity_threshold ${params.preprocessing_fastp_complexityfilter_threshold}" : "", - ].join(' ').trim() + ext.args = { + [ + params.preprocessing_excludeunmerged ? "" : "--include_unmerged", + params.preprocessing_trim5p != 0 ? "--trim_front1 ${params.preprocessing_trim5p} --trim_front2 ${params.preprocessing_trim5p}" : "", + params.preprocessing_trim3p != 0 ? "--trim_tail1 ${params.preprocessing_trim3p} --trim_tail2 ${params.preprocessing_trim3p}" : "", + params.preprocessing_skipadaptertrim ? "--disable_adapter_trimming" : params.preprocessing_adapterlist ? "" : params.preprocessing_adapter1 ? "--adapter_sequence ${params.preprocessing_adapter1}" : "", + params.preprocessing_skipadaptertrim ? "" : params.preprocessing_adapterlist ? "" : params.preprocessing_adapter2 ? "--adapter_sequence_r2 ${params.preprocessing_adapter2}" : "", + "--length_required ${params.preprocessing_minlength}", + params.preprocessing_fastp_complexityfilter ? "--low_complexity_filter --complexity_threshold ${params.preprocessing_fastp_complexityfilter_threshold}" : "", + params.preprocessing_fastp_disable_polygfilter ? "--disable_trim_poly_g" : "${meta.colour_chemistry}" == 4 ? "--trim_poly_g --poly_g_min_len ${params.preprocessing_fastp_polygfilter_minlength}" : "--disable_trim_poly_g", + params.preprocessing_fastp_polyxfilter_minlength != 0 ? "--trim_poly_x --poly_x_min_len ${params.preprocessing_fastp_polyxfilter_minlength}": "", + ].join(' ').trim() + } ext.prefix = { "${meta.sample_id}_${meta.library_id}_L${meta.lane}" } publishDir = [ [ @@ -1012,7 +1020,8 @@ process { } withName: MALTEXTRACT { - ext.args = [ + ext.args = { + [ "-f ${params.metagenomics_maltextract_filter}", "-a ${params.metagenomics_maltextract_toppercent}", "--minPI ${params.metagenomics_maltextract_minpercentidentity}", @@ -1022,8 +1031,9 @@ process { params.metagenomics_maltextract_matches ? "--matches" : "", params.metagenomics_maltextract_megansummary ? "--meganSummary" : "", params.metagenomics_maltextract_usetopalignment ? "--useTopAlignment" : "", - { meta.strandedness } == "single" ? '--singleStranded' : '', + "${meta.strandedness}" == "single" ? '--singleStranded' : '', ].join(' ').trim() + } publishDir = [ path: { "${params.outdir}/metagenomics/postprocessing/maltextract/" }, mode: params.publish_dir_mode, @@ -1097,7 +1107,7 @@ process { "--no-stats", "-y ${params.damagecalculation_yaxis}", params.damagecalculation_mapdamage_downsample == 0 ? "" : "-n ${params.damagecalculation_mapdamage_downsample} --downsample-seed=1", - { meta.strandedness } == "single" ? '--single-stranded' : '', + "${meta.strandedness}" == "single" ? '--single-stranded' : '', "-m ${params.damagecalculation_xaxis}", ].join(' ').trim() } @@ -1154,7 +1164,7 @@ process { "--seq-length=${params.damage_manipulation_rescale_seqlength}", params.damage_manipulation_rescale_length_3p == 0 ? "" : "--rescale-length-3p=${params.damage_manipulation_rescale_length_3p}", params.damage_manipulation_rescale_length_5p == 0 ? "" : "--rescale-length-5p=${params.damage_manipulation_rescale_length_5p}", - { meta.strandedness } == "single" ? '--single-stranded' : '', + "${meta.strandedness}" == "single" ? '--single-stranded' : '', ].join(' ').trim() } ext.prefix = { "${meta.sample_id}_${meta.library_id}_${meta.reference}_rescaled" } @@ -1391,7 +1401,8 @@ process { } withName: MALTEXTRACT { - ext.args = [ + ext.args = { + [ "-f ${params.metagenomics_maltextract_filter}", "-a ${params.metagenomics_maltextract_toppercent}", "--minPI ${params.metagenomics_maltextract_minpercentidentity}", @@ -1401,8 +1412,9 @@ process { params.metagenomics_maltextract_matches ? "--matches" : "", params.metagenomics_maltextract_megansummary ? "--meganSummary" : "", params.metagenomics_maltextract_usetopalignment ? "--useTopAlignment" : "", - { meta.strandedness } == "single" ? '--singleStranded' : '', + "${meta.strandedness}" == "single" ? '--singleStranded' : '', ].join(' ').trim() + } publishDir = [ [ path: { "${params.outdir}/metagenomics/maltextract/stats/" }, diff --git a/main.nf b/main.nf index c482c845..0cb00a85 100644 --- a/main.nf +++ b/main.nf @@ -15,7 +15,7 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ -include { EAGER } from './workflows/eager' +include { EAGER } from './workflows/eager' include { PIPELINE_INITIALISATION } from './subworkflows/local/utils_nfcore_eager_pipeline' include { PIPELINE_COMPLETION } from './subworkflows/local/utils_nfcore_eager_pipeline' include { getGenomeAttribute } from './subworkflows/local/utils_nfcore_eager_pipeline' diff --git a/nextflow.config b/nextflow.config index a024fae7..29438d58 100644 --- a/nextflow.config +++ b/nextflow.config @@ -97,6 +97,9 @@ params { // WARN: slightly different behaviour between fastp & adapterremoval preprocessing_trim3p = 0 // WARN: slightly different behaviour between fastp & adapterremoval + preprocessing_fastp_disable_polygfilter = false + preprocessing_fastp_polygfilter_minlength = 10 + preprocessing_fastp_polyxfilter_minlength = 0 preprocessing_fastp_complexityfilter = false preprocessing_fastp_complexityfilter_threshold = 10 preprocessing_adapterremoval_preserve5p = false diff --git a/nextflow_schema.json b/nextflow_schema.json index a1a9f6eb..2994d5de 100644 --- a/nextflow_schema.json +++ b/nextflow_schema.json @@ -408,16 +408,36 @@ "preprocessing_fastp_complexityfilter": { "type": "boolean", "description": "Specify to turn on sequence complexity filtering of reads.", - "help_text": "Performs a poly-G tail removal step in the beginning of the pipeline using fastp.\n\nThis can be useful for trimming ploy-G tails from short-fragments sequenced on two-colour Illumina chemistry such as NextSeqs or NovaSeqs (where no-fluorescence is read as a G on two-colour chemistry), which can inflate reported GC content values.\n\n> Modifies fastp parameter: `--trim_poly_g`", + "help_text": "Performs a read complexity filtering step using fastp.\n\nThis can be useful for removing highly repetitive and low-complexity reads from downstream analysis.\n\n> Modifies fastp parameter: `--low_complexity_filter`", "fa_icon": "fas fa-power-off" }, "preprocessing_fastp_complexityfilter_threshold": { "type": "integer", "default": 10, "description": "Specify the complexity threshold that must be reached or exceeded to retain reads.", - "help_text": "This option can be used to define the minimum length of a poly-G tail to begin low complexity trimming.\n\n> Modifies fastp parameter: `--poly_g_min_len`", + "help_text": "This option can be used to define the complexity of a read to be retained for downstream analysis.\n\n> Modifies fastp parameter: `--complexity_threshold`", "fa_icon": "fas fa-filter" }, + "preprocessing_fastp_disable_polygfilter": { + "type": "boolean", + "description": "Specify to disable poly-G filtering of 2 colour chemistry reads.", + "fa_icon": "fas fa-power-off", + "help_text": "This option will disable fastp-based poly-G trimming carried out by default on all 2 colour chemistry sequencing data.\n\n> Modifies fastp parameter: `--disable_trim_poly_g`" + }, + "preprocessing_fastp_polygfilter_minlength": { + "type": "integer", + "default": 10, + "description": "Specify length of poly-g min for clipping to be performed on 2 colour chemistry datasets.", + "help_text": "This option can be used to define the minimum length of a poly-G tail to begin low complexity trimming on 2 colour chemistry datasets. In short-fragments sequenced on two-colour Illumina chemistry such as NextSeqs or NovaSeqs, where no-fluorescence is read as a G on two-colour chemistry, poly-G tails can inflate reported GC content values and cause mapability issues downstream.\n\n> Modifies fastp parameter: `--poly_g_min_len`", + "fa_icon": "fas fa-ruler-horizontal" + }, + "preprocessing_fastp_polyxfilter_minlength": { + "type": "integer", + "default": 0, + "description": "Specify the complexity threshold that must be reached or exceeded to retain reads.", + "help_text": "This option can be used to define the minimum length of a poly-X (A,T,C,N) tail to begin low complexity trimming following poly-G trimming (if performed). This would be carried out on all sequencing data, regardless of the colour chemistry.\n\n> Modifies fastp parameter: `--trim_poly_x` and `--poly_x_min_len`", + "fa_icon": "fas fa-ruler-horizontal" + }, "preprocessing_adapterremoval_preserve5p": { "type": "boolean", "description": "Skip AdapterRemoval quality and N base trimming at 5 prime end.", diff --git a/subworkflows/local/preprocessing.nf b/subworkflows/local/preprocessing.nf index ea73f93a..ab03a4de 100644 --- a/subworkflows/local/preprocessing.nf +++ b/subworkflows/local/preprocessing.nf @@ -19,8 +19,8 @@ workflow PREPROCESSING { if ( params.preprocessing_tool == "fastp" ) { ch_processed_reads = PREPROCESSING_FASTP ( reads, adapterlist ).reads - ch_versions = ch_versions.mix( PREPROCESSING_FASTP.out.versions ) - ch_multiqc_files = ch_multiqc_files.mix( PREPROCESSING_FASTP.out.mqc ) + ch_versions = ch_versions.mix( PREPROCESSING_FASTP.out.versions ) + ch_multiqc_files = ch_multiqc_files.mix( PREPROCESSING_FASTP.out.mqc ) } else if ( params.preprocessing_tool == "adapterremoval" ) { ch_processed_reads = PREPROCESSING_ADAPTERREMOVAL ( reads, adapterlist ).reads ch_versions = ch_versions.mix( PREPROCESSING_ADAPTERREMOVAL.out.versions )