diff --git a/.github/workflows/test_profile.yml b/.github/workflows/test_profile.yml index 13628f1..19e2e8b 100644 --- a/.github/workflows/test_profile.yml +++ b/.github/workflows/test_profile.yml @@ -24,7 +24,7 @@ jobs: - name: Run Cecret run: | - nextflow run . -profile docker,test -c .github/workflows/github_actions.config --maxcpus 2 --medcpus 2 --cleaner 'fastp' --aligner 'minimap2' --mpileup_depth 200 --vadr false --aci false --freyja false + nextflow run . -profile docker,test -c .github/workflows/github_actions.config --maxcpus 2 --medcpus 2 --cleaner 'fastp' --aligner 'minimap2' --mpileup_depth 200 --vadr false ls cecret* diff --git a/.github/workflows/test_profile1.yml b/.github/workflows/test_profile1.yml index 2f57d30..fcee51b 100644 --- a/.github/workflows/test_profile1.yml +++ b/.github/workflows/test_profile1.yml @@ -24,7 +24,7 @@ jobs: - name: Run Cecret run: | - nextflow run . -profile docker,test1 -c .github/workflows/github_actions.config --maxcpus 2 --medcpus 2 --cleaner 'fastp' --aligner 'minimap2' --mpileup_depth 200 --vadr false --aci false --freyja false + nextflow run . -profile docker,test1 -c .github/workflows/github_actions.config --maxcpus 2 --medcpus 2 --cleaner 'fastp' --aligner 'minimap2' --mpileup_depth 200 --vadr false ls cecret* diff --git a/.github/workflows/test_profile2.yml b/.github/workflows/test_profile2.yml index 7c03535..b541c60 100644 --- a/.github/workflows/test_profile2.yml +++ b/.github/workflows/test_profile2.yml @@ -24,7 +24,7 @@ jobs: - name: Run Cecret run: | - nextflow run . -profile docker,test2 -c .github/workflows/github_actions.config --maxcpus 2 --medcpus 2 --cleaner 'fastp' --aligner 'minimap2' --mpileup_depth 200 --vadr false --aci false --freyja false + nextflow run . -profile docker,test2 -c .github/workflows/github_actions.config --maxcpus 2 --medcpus 2 --cleaner 'fastp' --aligner 'minimap2' --mpileup_depth 200 --vadr false ls cecret* diff --git a/.github/workflows/test_wastewater.yml b/.github/workflows/test_wastewater.yml index d39adf1..54ae7f7 100644 --- a/.github/workflows/test_wastewater.yml +++ b/.github/workflows/test_wastewater.yml @@ -36,5 +36,7 @@ jobs: cat cecret*/cecret_results.txt + head cecret/freyja/aggregated-freyja.tsv + - name: Clean run: rm -rf work .nextflow* \ No newline at end of file diff --git a/configs/cecret_config_template.config b/configs/cecret_config_template.config index 845cf80..9c5c257 100644 --- a/configs/cecret_config_template.config +++ b/configs/cecret_config_template.config @@ -196,7 +196,7 @@ //params.kraken2_db = false //# For process samtools_ampliconstats and samtools_plot_ampliconstats -//params.samtools_ampliconstats_options = '' +//params.samtools_ampliconstats_options = '--max-amplicon-length 3000 --max-amplicons 3000' //params.samtools_ampliconstats = true //params.samtools_plot_ampliconstats_options = '-size 1200,900 -size2 1200,900 -size3 1200,900' //params.samtools_plot_ampliconstats = true @@ -210,9 +210,8 @@ //params.freyja_aggregate = true //params.freyja_variants_options = '' //params.freyja_demix_options = '--depthcutoff 100' -//params.freyja_boot_options = '--nb 1000 --depthcutoff 100' //params.freyja_aggregate_options = '' -//params.freyja_plot_options = '--mincov 100' +//params.freyja_plot_options = '' //params.freyja_plot_filetype = 'png' //# For process nextclade diff --git a/main.nf b/main.nf index 7d87c73..e989f6b 100644 --- a/main.nf +++ b/main.nf @@ -52,6 +52,10 @@ params.bedtools_multicov_options = false if (params.bedtools_multicov_options ) { println('WARNING : params.bedtools_multicov_options no longer does anything!') } +params.freyja_boot_options = false +if (params.freyja_boot_options ) { + println('WARNING : params.freyja_boot_options no longer does anything!') +} //# Starting the workflow -------------------------------------------------------------- @@ -179,9 +183,9 @@ params.nextclade_options = '' params.nextalign_options = '--include-reference' params.freyja_variants_options = '' params.freyja_demix_options = "--depthcutoff ${params.minimum_depth}" -params.freyja_boot_options = "--nb 1000 --depthcutoff ${params.minimum_depth}" + params.freyja_aggregate_options = '' -params.freyja_plot_options = "--mincov ${params.minimum_depth}" +params.freyja_plot_options = "" params.freyja_plot_filetype = 'png' //# Specifying some species-specific params diff --git a/modules/freyja.nf b/modules/freyja.nf index a67f89b..e27bea7 100644 --- a/modules/freyja.nf +++ b/modules/freyja.nf @@ -1,7 +1,7 @@ -process freyja { +process freyja_variants { tag "${sample}" label "process_medium" - errorStrategy { task.attempt < 2 ? 'retry' : 'ignore'} + //errorStrategy { task.attempt < 2 ? 'retry' : 'ignore'} publishDir "${params.outdir}", mode: 'copy' container 'quay.io/uphl/freyja:1.4.7-2023-10-31' @@ -18,8 +18,8 @@ process freyja { tuple val(sample), file(bam), file(reference_genome) output: - path "freyja/${sample}_demix.tsv", optional: true, emit: freyja_demix - path "freyja/${sample}*", emit: files + tuple val(sample), file("freyja/${sample}_{depths,variants}.tsv"), optional: true, emit: variants + path "freyja/${sample}*", optional: true, emit: files path "logs/${task.process}/${sample}.${workflow.sessionId}.log" shell: @@ -36,17 +36,84 @@ process freyja { --depths freyja/!{sample}_depths.tsv \ --ref !{reference_genome} \ | tee -a $log + ''' +} + +process freyja_demix { + tag "${sample}" + label "process_medium" + //errorStrategy { task.attempt < 2 ? 'retry' : 'ignore'} + publishDir "${params.outdir}", mode: 'copy' + container 'quay.io/uphl/freyja:1.4.7-2023-10-31' + + //#UPHLICA maxForks 10 + //#UPHLICA pod annotation: 'scheduler.illumina.com/presetSize', value: 'standard-xlarge' + //#UPHLICA memory 60.GB + //#UPHLICA cpus 14 + //#UPHLICA time '45m' + + when: + params.freyja + + input: + tuple val(sample), file(variants) + + output: + path "freyja/${sample}_demix.tsv", optional: true, emit: demix + path "freyja/${sample}*", optional: true, emit: files + path "logs/${task.process}/${sample}.${workflow.sessionId}.log" + + shell: + ''' + mkdir -p freyja logs/!{task.process} + log=logs/!{task.process}/!{sample}.!{workflow.sessionId}.log + + date > $log + freyja --version >> $log freyja demix \ !{params.freyja_demix_options} \ - freyja/!{sample}_variants.tsv \ - freyja/!{sample}_depths.tsv \ + !{variants[1]} \ + !{variants[0]} \ --output freyja/!{sample}_demix.tsv \ | tee -a $log + ''' +} + +process freyja_boot { + tag "${sample}" + label "process_medium" + //errorStrategy { task.attempt < 2 ? 'retry' : 'ignore'} + publishDir "${params.outdir}", mode: 'copy' + container 'quay.io/uphl/freyja:1.4.7-2023-10-31' + + //#UPHLICA maxForks 10 + //#UPHLICA pod annotation: 'scheduler.illumina.com/presetSize', value: 'standard-xlarge' + //#UPHLICA memory 60.GB + //#UPHLICA cpus 14 + //#UPHLICA time '45m' + + when: + params.freyja + + input: + tuple val(sample), file(variants) + + output: + path "freyja/${sample}*", emit: files + path "logs/${task.process}/${sample}.${workflow.sessionId}.log" + + shell: + ''' + mkdir -p freyja logs/!{task.process} + log=logs/!{task.process}/!{sample}.!{workflow.sessionId}.log + + date > $log + freyja --version >> $log freyja boot !{params.freyja_boot_options} \ - freyja/!{sample}_variants.tsv \ - freyja/!{sample}_depths.tsv \ + !{variants[1]} \ + !{variants[0]} \ --nt !{task.cpus} \ --output_base freyja/!{sample}_boot.tsv \ | tee -a $log @@ -76,7 +143,7 @@ process freyja_aggregate { output: path "freyja/aggregated*", emit: files path "freyja/aggregated-freyja.tsv", emit: aggregated_freyja_file - path "freyja/*mqc.png", emit: for_multiqc + path "freyja/*mqc.png", emit: for_multiqc path "freyja/*png" path "logs/${task.process}/${task.process}.${workflow.sessionId}.log" diff --git a/nextflow.config b/nextflow.config index 795d98d..eb8d277 100644 --- a/nextflow.config +++ b/nextflow.config @@ -5,7 +5,7 @@ manifest { name = 'Cecret' author = 'Erin Young' homePage = 'https://github.com/UPHL-BioNGS/Cecret' - version = 'v3.8.20231031' + version = 'v3.9.20231102' defaultBranch = 'master' recurseSubmodules = false description = 'Reference-based consensus creation' diff --git a/nextflow_schema.json b/nextflow_schema.json index b734f3f..5c7dbdf 100644 --- a/nextflow_schema.json +++ b/nextflow_schema.json @@ -119,12 +119,6 @@ "hidden": true, "description": "Options for process" }, - "freyja_boot_options": { - "type": "string", - "hidden": true, - "default": "--nb 1000 --depthcutoff 100", - "description": "Options for process" - }, "freyja_demix_options": { "type": "string", "hidden": true, @@ -144,7 +138,6 @@ "freyja_plot_options": { "type": "string", "hidden": true, - "default": "--mincov 100", "description": "Options for process" }, "freyja_variants_options": { diff --git a/subworkflows/sarscov2.nf b/subworkflows/sarscov2.nf index d7fb996..8f9c2f1 100644 --- a/subworkflows/sarscov2.nf +++ b/subworkflows/sarscov2.nf @@ -1,4 +1,6 @@ -include { freyja; freyja_aggregate } from '../modules/freyja' addParams(params) +include { freyja_aggregate } from '../modules/freyja' addParams(params) +include { freyja_demix } from '../modules/freyja' addParams(params) +include { freyja_variants } from '../modules/freyja' addParams(params) include { pangolin } from '../modules/pangolin' addParams(params) include { nextclade } from '../modules/nextclade' addParams(params) include { nextclade_dataset as dataset } from '../modules/nextclade' addParams(params) @@ -26,8 +28,9 @@ workflow sarscov2 { } nextclade(ch_fastas.collect(), ch_dataset) - freyja(ch_bam.map{it -> tuple(it[0], it[1])}.combine(ch_reference_genome)) - freyja_aggregate(freyja.out.freyja_demix.collect(), ch_freyja_script) + freyja_variants(ch_bam.map{it -> tuple(it[0], it[1])}.combine(ch_reference_genome)) + freyja_demix(freyja_variants.out.variants) + freyja_aggregate(freyja_demix.out.demix.collect(), ch_freyja_script) emit: dataset = ch_dataset