From ef5d433f3281efa8733d4188105845b81ccd2458 Mon Sep 17 00:00:00 2001 From: maxibor Date: Wed, 14 Jun 2023 18:35:30 +0200 Subject: [PATCH 1/7] fix Genome binning is performed on uncorrected contigs when selecting the ancient DNA subworkflow #449 --- subworkflows/local/binning_refinement.nf | 10 +--------- workflows/mag.nf | 9 ++++++++- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/subworkflows/local/binning_refinement.nf b/subworkflows/local/binning_refinement.nf index de6a3429..09eb72a9 100644 --- a/subworkflows/local/binning_refinement.nf +++ b/subworkflows/local/binning_refinement.nf @@ -22,7 +22,7 @@ def getColNo(filename) { workflow BINNING_REFINEMENT { take: - contigs + ch_contigs_for_dastool // channel: [ val(meta), path(contigs) ] bins // channel: [ val(meta), path(bins) ] depths reads @@ -30,14 +30,6 @@ workflow BINNING_REFINEMENT { main: ch_versions = Channel.empty() - // Drop unnecessary files - ch_contigs_for_dastool = contigs - .map { - meta, assembly, bams, bais -> - def meta_new = meta.clone() - [ meta_new, assembly ] - } - ch_bins_for_fastatocontig2bin = RENAME_PREDASTOOL(bins).renamed_bins .branch { metabat2: it[0]['binner'] == 'MetaBAT2' diff --git a/workflows/mag.nf b/workflows/mag.nf index ad9a01c6..a086dc43 100644 --- a/workflows/mag.nf +++ b/workflows/mag.nf @@ -581,7 +581,14 @@ workflow MAG { // If any two of the binners are both skipped at once, do not run because DAS_Tool needs at least one if ( params.refine_bins_dastool ) { - BINNING_REFINEMENT ( BINNING_PREPARATION.out.grouped_mappings, BINNING.out.bins, BINNING.out.metabat2depths, ch_short_reads ) + if (params.ancient_dna) { + contigs_ch = ANCIENT_DNA_ASSEMLY_VALIDATION.out.contigs_recalled + } else { + contigs_ch = BINNING_PREPARATION.out.grouped_mappings + .map{ meta, contigs, bam, bai -> [ meta, contigs ] } + } + + BINNING_REFINEMENT ( contigs_ch, BINNING.out.bins, BINNING.out.metabat2depths, ch_short_reads ) ch_versions = ch_versions.mix(BINNING_REFINEMENT.out.versions) if ( params.postbinning_input == 'raw_bins_only' ) { From b744d272d9699113f8f7795624a63bb85980e640 Mon Sep 17 00:00:00 2001 From: "James A. Fellows Yates" Date: Thu, 15 Jun 2023 12:26:05 +0200 Subject: [PATCH 2/7] Apply suggestions from code review --- workflows/mag.nf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workflows/mag.nf b/workflows/mag.nf index a086dc43..fead93e6 100644 --- a/workflows/mag.nf +++ b/workflows/mag.nf @@ -582,7 +582,7 @@ workflow MAG { if ( params.refine_bins_dastool ) { if (params.ancient_dna) { - contigs_ch = ANCIENT_DNA_ASSEMLY_VALIDATION.out.contigs_recalled + contigs_ch = ANCIENT_DNA_ASSEMBLY_VALIDATION.out.contigs_recalled } else { contigs_ch = BINNING_PREPARATION.out.grouped_mappings .map{ meta, contigs, bam, bai -> [ meta, contigs ] } From 9b619ad1b644efd6e616e0cc7ec738355ea6fe15 Mon Sep 17 00:00:00 2001 From: "James A. Fellows Yates" Date: Thu, 15 Jun 2023 16:33:10 +0200 Subject: [PATCH 3/7] Update workflows/mag.nf Co-authored-by: Daniel Straub <42973691+d4straub@users.noreply.github.com> --- workflows/mag.nf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/workflows/mag.nf b/workflows/mag.nf index fead93e6..95960665 100644 --- a/workflows/mag.nf +++ b/workflows/mag.nf @@ -582,13 +582,13 @@ workflow MAG { if ( params.refine_bins_dastool ) { if (params.ancient_dna) { - contigs_ch = ANCIENT_DNA_ASSEMBLY_VALIDATION.out.contigs_recalled + ch_contigs_for_binrefinement = ANCIENT_DNA_ASSEMBLY_VALIDATION.out.contigs_recalled } else { - contigs_ch = BINNING_PREPARATION.out.grouped_mappings + ch_contigs_for_binrefinement = BINNING_PREPARATION.out.grouped_mappings .map{ meta, contigs, bam, bai -> [ meta, contigs ] } } - BINNING_REFINEMENT ( contigs_ch, BINNING.out.bins, BINNING.out.metabat2depths, ch_short_reads ) + BINNING_REFINEMENT ( ch_contigs_for_binrefinement, BINNING.out.bins, BINNING.out.metabat2depths, ch_short_reads ) ch_versions = ch_versions.mix(BINNING_REFINEMENT.out.versions) if ( params.postbinning_input == 'raw_bins_only' ) { From 2af6cffd9cb2c60114795e0274310fc31f747a7e Mon Sep 17 00:00:00 2001 From: Maxime Borry Date: Mon, 19 Jun 2023 09:07:10 +0000 Subject: [PATCH 4/7] bump version and update changelog --- CHANGELOG.md | 6 ++++++ nextflow.config | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 15ce37a3..fffd1e0c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## v2.3.1 - [2023-06-19] + +### `Fixed` + +- [#458](https://github.com/nf-core/mag/pull/458) - Correct the major issue of binning refinement being performed on uncorrected contigs instead of aDNA consensus recalled contigs (issue [#449](https://github.com/nf-core/mag/issues/449)) + ## v2.3.0 - [2023/03/02] ### `Added` diff --git a/nextflow.config b/nextflow.config index eaec54b3..17d3cb72 100644 --- a/nextflow.config +++ b/nextflow.config @@ -308,7 +308,7 @@ manifest { description = """Assembly, binning and annotation of metagenomes""" mainScript = 'main.nf' nextflowVersion = '!>=22.10.1' - version = '2.3.0' + version = '2.3.1' doi = '10.1093/nargab/lqac007' } From fd826ba361bb6b68e5474e8df9e1e17d7cde1f81 Mon Sep 17 00:00:00 2001 From: "James A. Fellows Yates" Date: Mon, 19 Jun 2023 11:11:14 +0200 Subject: [PATCH 5/7] Apply suggestions from code review --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fffd1e0c..c7ed67fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### `Fixed` -- [#458](https://github.com/nf-core/mag/pull/458) - Correct the major issue of binning refinement being performed on uncorrected contigs instead of aDNA consensus recalled contigs (issue [#449](https://github.com/nf-core/mag/issues/449)) +- [#458](https://github.com/nf-core/mag/pull/458) - Correct the major issue in ancient DNA workflow of binning refinement being performed on uncorrected contigs instead of aDNA consensus recalled contigs (issue [#449](https://github.com/nf-core/mag/issues/449)) ## v2.3.0 - [2023/03/02] From 35d9489c6cdbd3a33f778ea86bb3d4b828446396 Mon Sep 17 00:00:00 2001 From: Maxime Borry Date: Mon, 19 Jun 2023 09:25:42 +0000 Subject: [PATCH 6/7] integrated changes of #449 into this PR --- CHANGELOG.md | 1 + conf/modules.config | 12 +++++++++--- docs/output.md | 10 +++++----- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c7ed67fc..9ba5c314 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### `Fixed` - [#458](https://github.com/nf-core/mag/pull/458) - Correct the major issue in ancient DNA workflow of binning refinement being performed on uncorrected contigs instead of aDNA consensus recalled contigs (issue [#449](https://github.com/nf-core/mag/issues/449)) +- [#449](https://github.com/nf-core/mag/pull/447) - Fix results file overwriting in Ancient DNA workflow (reported by @alexhbnr, fix by @jfy133, and integrated by @maxibor in [#458](https://github.com/nf-core/mag/pull/458) ) ## v2.3.0 - [2023/03/02] diff --git a/conf/modules.config b/conf/modules.config index 63a68fed..51d7cfd9 100644 --- a/conf/modules.config +++ b/conf/modules.config @@ -455,6 +455,7 @@ process { } withName: FREEBAYES { + ext.prefix = { "${meta.assembler}-${meta.id}" } ext.args = "-p ${params.freebayes_ploidy} -q ${params.freebayes_min_basequality} -F ${params.freebayes_minallelefreq}" publishDir = [ path: { "${params.outdir}/Ancient_DNA/variant_calling/freebayes" }, @@ -464,8 +465,8 @@ process { } withName: BCFTOOLS_VIEW { + ext.prefix = { "${meta.assembler}-${meta.id}.filtered" } ext.args = "-v snps,mnps -i 'QUAL>=${params.bcftools_view_high_variant_quality} || (QUAL>=${params.bcftools_view_medium_variant_quality} && FORMAT/AO>=${params.bcftools_view_minimal_allelesupport})'" - ext.prefix = { "${meta.id}.filtered" } publishDir = [ path: { "${params.outdir}/Ancient_DNA/variant_calling/filtered" }, mode: params.publish_dir_mode, @@ -474,6 +475,7 @@ process { } withName: BCFTOOLS_CONSENSUS { + ext.prefix = { "${meta.assembler}-${meta.id}" } publishDir = [ path: {"${params.outdir}/Ancient_DNA/variant_calling/consensus" }, mode: params.publish_dir_mode, @@ -482,6 +484,7 @@ process { } withName: BCFTOOLS_INDEX { + ext.prefix = { "${meta.assembler}-${meta.id}" } ext.args = "-t" publishDir = [ path: {"${params.outdir}/Ancient_DNA/variant_calling/index" }, @@ -491,21 +494,24 @@ process { } withName: PYDAMAGE_ANALYZE { + ext.prefix = { "${meta.assembler}-${meta.id}" } publishDir = [ - path: {"${params.outdir}/Ancient_DNA/pydamage/analyze/${meta.id}" }, + path: {"${params.outdir}/Ancient_DNA/pydamage/analyze/" }, mode: params.publish_dir_mode ] } withName: PYDAMAGE_FILTER { + ext.prefix = { "${meta.assembler}-${meta.id}" } ext.args = "-t ${params.pydamage_accuracy}" publishDir = [ - path: {"${params.outdir}/Ancient_DNA/pydamage/filter/${meta.id}" }, + path: {"${params.outdir}/Ancient_DNA/pydamage/filter/" }, mode: params.publish_dir_mode ] } withName: SAMTOOLS_FAIDX { + ext.prefix = { "${meta.assembler}-${meta.id}" } publishDir = [ path: {"${params.outdir}/Ancient_DNA/samtools/faidx" }, mode: params.publish_dir_mode, diff --git a/docs/output.md b/docs/output.md index 987a92bd..301dc6ad 100644 --- a/docs/output.md +++ b/docs/output.md @@ -602,9 +602,9 @@ Optional, only running when parameter `-profile ancient_dna` is specified. Output files - `Ancient_DNA/pydamage/analyze` - - `[sample/group]/pydamage_results/pydamage_results.csv`: PyDamage raw result tabular file in `.csv` format. Format described here: [pydamage.readthedocs.io/en/0.62/output.html](https://pydamage.readthedocs.io/en/0.62/output.html) + - `[assembler]_[sample/group]/pydamage_results/pydamage_results.csv`: PyDamage raw result tabular file in `.csv` format. Format described here: [pydamage.readthedocs.io/en/0.62/output.html](https://pydamage.readthedocs.io/en/0.62/output.html) - `Ancient_DNA/pydamage/filter` - - `[sample/group]/pydamage_results/pydamage_results.csv`: PyDamage filtered result tabular file in `.csv` format. Format described here: [pydamage.readthedocs.io/en/0.62/output.html](https://pydamage.readthedocs.io/en/0.62/output.html) + - `[assembler]_[sample/group]/pydamage_results/pydamage_results.csv`: PyDamage filtered result tabular file in `.csv` format. Format described here: [pydamage.readthedocs.io/en/0.62/output.html](https://pydamage.readthedocs.io/en/0.62/output.html) @@ -616,11 +616,11 @@ Because of aDNA damage, _de novo_ assemblers sometimes struggle to call a correc Output files - `variant_calling/consensus` - - `[sample/group].fa`: contigs sequence with re-called consensus from read-to-contig alignment + - `[assembler]_[sample/group].fa`: contigs sequence with re-called consensus from read-to-contig alignment - `variant_calling/unfiltered` - - `[sample/group].vcf.gz`: raw variant calls of the reads aligned back to the contigs. + - `[assembler]_[sample/group].vcf.gz`: raw variant calls of the reads aligned back to the contigs. - `variant_calling/filtered` - - `[sample/group].filtered.vcf.gz`: quality filtered variant calls of the reads aligned back to the contigs. + - `[assembler]_[sample/group].filtered.vcf.gz`: quality filtered variant calls of the reads aligned back to the contigs. From 9f86e7d2a6f7ef238ca8210e83d393c0cbdc4823 Mon Sep 17 00:00:00 2001 From: Maxime Borry Date: Mon, 19 Jun 2023 09:27:59 +0000 Subject: [PATCH 7/7] 451 not 449 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ba5c314..e046411a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### `Fixed` - [#458](https://github.com/nf-core/mag/pull/458) - Correct the major issue in ancient DNA workflow of binning refinement being performed on uncorrected contigs instead of aDNA consensus recalled contigs (issue [#449](https://github.com/nf-core/mag/issues/449)) -- [#449](https://github.com/nf-core/mag/pull/447) - Fix results file overwriting in Ancient DNA workflow (reported by @alexhbnr, fix by @jfy133, and integrated by @maxibor in [#458](https://github.com/nf-core/mag/pull/458) ) +- [#451](https://github.com/nf-core/mag/pull/451) - Fix results file overwriting in Ancient DNA workflow (reported by @alexhbnr, fix by @jfy133, and integrated by @maxibor in [#458](https://github.com/nf-core/mag/pull/458) ) ## v2.3.0 - [2023/03/02]