From a764bc4807fbd7771de6868977d522bd2b7faa5e Mon Sep 17 00:00:00 2001 From: James Fellows Yates Date: Fri, 9 Sep 2022 13:57:06 +0200 Subject: [PATCH 1/4] Start works - need updated module though t have meta --- conf/modules.config | 11 +++++- modules.json | 4 +++ .../metaphlan3/mergemetaphlantables/main.nf | 33 ++++++++++++++++++ .../metaphlan3/mergemetaphlantables/meta.yml | 34 +++++++++++++++++++ .../local/standardisation_profiles.nf | 21 ++++++++++-- 5 files changed, 100 insertions(+), 3 deletions(-) create mode 100644 modules/nf-core/modules/metaphlan3/mergemetaphlantables/main.nf create mode 100644 modules/nf-core/modules/metaphlan3/mergemetaphlantables/meta.yml diff --git a/conf/modules.config b/conf/modules.config index e367a67..d4bd038 100644 --- a/conf/modules.config +++ b/conf/modules.config @@ -327,7 +327,7 @@ process { ] } - withName: METAPHLAN3 { + withName: METAPHLAN3_METAPHLAN3 { ext.args = { "${meta.db_params}" } ext.prefix = params.perform_runmerging ? { "${meta.id}-${meta.db_name}" } : { "${meta.id}-${meta.run_accession}-${meta.db_name}" } publishDir = [ @@ -337,6 +337,15 @@ process { ] } + withName: METAPHLAN3_MERGEMETAPHLANTABLES { + ext.prefix = { "${meta.id}_combined_reports" } + publishDir = [ + path: { "${params.outdir}/metaphlan3/" }, + mode: params.publish_dir_mode, + pattern: '*.{txt}' + ] + } + withName: CENTRIFUGE_CENTRIFUGE { publishDir = [ path: { "${params.outdir}/centrifuge/${meta.db_name}/" }, diff --git a/modules.json b/modules.json index 3b8cab2..cbbae85 100644 --- a/modules.json +++ b/modules.json @@ -94,6 +94,10 @@ "branch": "master", "git_sha": "2d38566eca4cc15142b2ffa7c11837569b39aece" }, + "metaphlan3/mergemetaphlantables": { + "branch": "master", + "git_sha": "940d7fe9d63962e0e2ba0987e2893fb0aff832e3" + }, "metaphlan3/metaphlan3": { "branch": "master", "git_sha": "940d7fe9d63962e0e2ba0987e2893fb0aff832e3" diff --git a/modules/nf-core/modules/metaphlan3/mergemetaphlantables/main.nf b/modules/nf-core/modules/metaphlan3/mergemetaphlantables/main.nf new file mode 100644 index 0000000..6fd05e3 --- /dev/null +++ b/modules/nf-core/modules/metaphlan3/mergemetaphlantables/main.nf @@ -0,0 +1,33 @@ +process METAPHLAN3_MERGEMETAPHLANTABLES { + label 'process_single' + + conda (params.enable_conda ? 'bioconda::metaphlan=3.0.12' : null) + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/metaphlan:3.0.12--pyhb7b1952_0' : + 'quay.io/biocontainers/metaphlan:3.0.12--pyhb7b1952_0' }" + + input: + path(profiles) + + output: + tuple path("${prefix}.txt") , emit: txt + path "versions.yml" , emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + def args = task.ext.args ?: '' + prefix = task.ext.prefix ?: "merged_abundance_table" + """ + merge_metaphlan_tables.py \\ + $args \\ + -o ${prefix}.txt \\ + ${profiles} + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + metaphlan3: \$(metaphlan --version 2>&1 | awk '{print \$3}') + END_VERSIONS + """ +} diff --git a/modules/nf-core/modules/metaphlan3/mergemetaphlantables/meta.yml b/modules/nf-core/modules/metaphlan3/mergemetaphlantables/meta.yml new file mode 100644 index 0000000..c94be25 --- /dev/null +++ b/modules/nf-core/modules/metaphlan3/mergemetaphlantables/meta.yml @@ -0,0 +1,34 @@ +name: "metaphlan3_mergemetaphlantables" +description: Merges output abundance tables from MetaPhlAn3 +keywords: + - metagenomics + - classification + - merge + - table + - profiles +tools: + - metaphlan3: + description: Identify clades (phyla to species) present in the metagenome obtained from a microbiome sample and their relative abundance + homepage: https://huttenhower.sph.harvard.edu/metaphlan/ + documentation: https://github.com/biobakery/MetaPhlAn + doi: "10.7554/eLife.65088" + licence: ["MIT License"] + +input: + - profiles: + type: file + description: List of per-sample MetaPhlAn3 taxonomic abundance tables + pattern: "*" + +output: + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" + - txt: + type: txt + description: Combined MetaPhlAn3 table + pattern: "*.txt" + +authors: + - "@jfy133" diff --git a/subworkflows/local/standardisation_profiles.nf b/subworkflows/local/standardisation_profiles.nf index 8be6020..6d404be 100644 --- a/subworkflows/local/standardisation_profiles.nf +++ b/subworkflows/local/standardisation_profiles.nf @@ -2,8 +2,9 @@ // Standardise output files e.g. aggregation // -include { KAIJU_KAIJU2TABLE } from '../../modules/nf-core/modules/kaiju/kaiju2table/main' -include { MOTUS_MERGE } from '../../modules/nf-core/modules/motus/merge/main' +include { KAIJU_KAIJU2TABLE } from '../../modules/nf-core/modules/kaiju/kaiju2table/main' +include { MOTUS_MERGE } from '../../modules/nf-core/modules/motus/merge/main' +include { METAPHLAN3_MERGEMETAPHLANTABLES } from '../../modules/nf-core/modules/metaphlan3/mergemetaphlantables/main' workflow STANDARDISATION_PROFILES { take: @@ -23,6 +24,7 @@ workflow STANDARDISATION_PROFILES { ch_input_profiles = profiles .branch { motus: it[0]['tool'] == 'motus' + metaphlan3: it[0]['tool'] == 'metaphlan3' unknown: true } @@ -58,6 +60,21 @@ workflow STANDARDISATION_PROFILES { ch_multiqc_files = ch_multiqc_files.mix( KAIJU_KAIJU2TABLE.out.summary ) ch_versions = ch_versions.mix( KAIJU_KAIJU2TABLE.out.versions ) + // MetaPhlAn3 + ch_profiles_for_metaphlan3 = ch_input_profiles.metaphlan3 + .map { [it[0]['db_name'], it[1]] } + .groupTuple() + .map { + [it[1]] + } + + METAPHLAN3_MERGEMETAPHLANTABLES ( ch_profiles_for_metaphlan3 ) + ch_standardised_tables = ch_standardised_tables.mix( METAPHLAN3_MERGEMETAPHLANTABLES.out.txt ) + ch_multiqc_files = ch_multiqc_files.mix( METAPHLAN3_MERGEMETAPHLANTABLES.out.txt ) + ch_versions = ch_versions.mix( METAPHLAN3_MERGEMETAPHLANTABLES.out.versions ) + + // mOTUs + // mOTUs has a 'single' database, and cannot create custom ones. // Therefore removing db info here, and publish merged at root mOTUs results // directory From 21ae9d85c3ca05adb2b48a72389abd4195fd21a2 Mon Sep 17 00:00:00 2001 From: James Fellows Yates Date: Thu, 15 Sep 2022 12:29:54 +0200 Subject: [PATCH 2/4] Ensure merge metaphlan3 tables happens on per database basis --- modules.json | 4 ++-- .../modules/metaphlan3/mergemetaphlantables/main.nf | 6 +++--- .../modules/metaphlan3/mergemetaphlantables/meta.yml | 10 ++++++++++ modules/nf-core/modules/metaphlan3/metaphlan3/main.nf | 2 +- modules/nf-core/modules/metaphlan3/metaphlan3/meta.yml | 2 +- subworkflows/local/profiling.nf | 8 ++++---- subworkflows/local/standardisation_profiles.nf | 2 +- 7 files changed, 22 insertions(+), 12 deletions(-) diff --git a/modules.json b/modules.json index cbbae85..7c02b3e 100644 --- a/modules.json +++ b/modules.json @@ -96,11 +96,11 @@ }, "metaphlan3/mergemetaphlantables": { "branch": "master", - "git_sha": "940d7fe9d63962e0e2ba0987e2893fb0aff832e3" + "git_sha": "36bcd675ae76a379a38165898a203f4915823f4f" }, "metaphlan3/metaphlan3": { "branch": "master", - "git_sha": "940d7fe9d63962e0e2ba0987e2893fb0aff832e3" + "git_sha": "978087354eb72ac1f6e18a3f790fad9bc4d05840" }, "minimap2/align": { "branch": "master", diff --git a/modules/nf-core/modules/metaphlan3/mergemetaphlantables/main.nf b/modules/nf-core/modules/metaphlan3/mergemetaphlantables/main.nf index 6fd05e3..7c37eca 100644 --- a/modules/nf-core/modules/metaphlan3/mergemetaphlantables/main.nf +++ b/modules/nf-core/modules/metaphlan3/mergemetaphlantables/main.nf @@ -7,10 +7,10 @@ process METAPHLAN3_MERGEMETAPHLANTABLES { 'quay.io/biocontainers/metaphlan:3.0.12--pyhb7b1952_0' }" input: - path(profiles) + tuple val(meta), path(profiles) output: - tuple path("${prefix}.txt") , emit: txt + tuple val(meta), path("${prefix}.txt") , emit: txt path "versions.yml" , emit: versions when: @@ -18,7 +18,7 @@ process METAPHLAN3_MERGEMETAPHLANTABLES { script: def args = task.ext.args ?: '' - prefix = task.ext.prefix ?: "merged_abundance_table" + prefix = task.ext.prefix ?: "${meta.id}" """ merge_metaphlan_tables.py \\ $args \\ diff --git a/modules/nf-core/modules/metaphlan3/mergemetaphlantables/meta.yml b/modules/nf-core/modules/metaphlan3/mergemetaphlantables/meta.yml index c94be25..365973e 100644 --- a/modules/nf-core/modules/metaphlan3/mergemetaphlantables/meta.yml +++ b/modules/nf-core/modules/metaphlan3/mergemetaphlantables/meta.yml @@ -15,12 +15,22 @@ tools: licence: ["MIT License"] input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] - profiles: type: file description: List of per-sample MetaPhlAn3 taxonomic abundance tables pattern: "*" output: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] - versions: type: file description: File containing software versions diff --git a/modules/nf-core/modules/metaphlan3/metaphlan3/main.nf b/modules/nf-core/modules/metaphlan3/metaphlan3/main.nf index e56f102..1453466 100644 --- a/modules/nf-core/modules/metaphlan3/metaphlan3/main.nf +++ b/modules/nf-core/modules/metaphlan3/metaphlan3/main.nf @@ -1,4 +1,4 @@ -process METAPHLAN3 { +process METAPHLAN3_METAPHLAN3 { tag "$meta.id" label 'process_high' diff --git a/modules/nf-core/modules/metaphlan3/metaphlan3/meta.yml b/modules/nf-core/modules/metaphlan3/metaphlan3/meta.yml index 093de5b..659d83a 100644 --- a/modules/nf-core/modules/metaphlan3/metaphlan3/meta.yml +++ b/modules/nf-core/modules/metaphlan3/metaphlan3/meta.yml @@ -1,4 +1,4 @@ -name: metaphlan3 +name: metaphlan3_metaphlan3 description: MetaPhlAn is a tool for profiling the composition of microbial communities from metagenomic shotgun sequencing data. keywords: - metagenomics diff --git a/subworkflows/local/profiling.nf b/subworkflows/local/profiling.nf index 37b4a2c..c2ef508 100644 --- a/subworkflows/local/profiling.nf +++ b/subworkflows/local/profiling.nf @@ -7,7 +7,7 @@ include { MEGAN_RMA2INFO as MEGAN_RMA2INFO_TSV } from '../../modules/nf-core/mo include { KRAKEN2_KRAKEN2 } from '../../modules/nf-core/modules/kraken2/kraken2/main' include { CENTRIFUGE_CENTRIFUGE } from '../../modules/nf-core/modules/centrifuge/centrifuge/main' include { CENTRIFUGE_KREPORT } from '../../modules/nf-core/modules/centrifuge/kreport/main' -include { METAPHLAN3 } from '../../modules/nf-core/modules/metaphlan3/metaphlan3/main' +include { METAPHLAN3_METAPHLAN3 } from '../../modules/nf-core/modules/metaphlan3/metaphlan3/main' include { KAIJU_KAIJU } from '../../modules/nf-core/modules/kaiju/kaiju/main' include { DIAMOND_BLASTX } from '../../modules/nf-core/modules/diamond/blastx/main' include { MOTUS_PROFILE } from '../../modules/nf-core/modules/motus/profile/main' @@ -168,9 +168,9 @@ workflow PROFILING { db: it[3] } - METAPHLAN3 ( ch_input_for_metaphlan3.reads, ch_input_for_metaphlan3.db ) - ch_versions = ch_versions.mix( METAPHLAN3.out.versions.first() ) - ch_raw_profiles = ch_raw_profiles.mix( METAPHLAN3.out.biom ) + METAPHLAN3_METAPHLAN3 ( ch_input_for_metaphlan3.reads, ch_input_for_metaphlan3.db ) + ch_versions = ch_versions.mix( METAPHLAN3_METAPHLAN3.out.versions.first() ) + ch_raw_profiles = ch_raw_profiles.mix( METAPHLAN3_METAPHLAN3.out.profile ) } diff --git a/subworkflows/local/standardisation_profiles.nf b/subworkflows/local/standardisation_profiles.nf index 6d404be..a557bff 100644 --- a/subworkflows/local/standardisation_profiles.nf +++ b/subworkflows/local/standardisation_profiles.nf @@ -65,7 +65,7 @@ workflow STANDARDISATION_PROFILES { .map { [it[0]['db_name'], it[1]] } .groupTuple() .map { - [it[1]] + [[id:it[0]], it[1]] } METAPHLAN3_MERGEMETAPHLANTABLES ( ch_profiles_for_metaphlan3 ) From 19a195ed147ce775260b86c4d939966b51b40634 Mon Sep 17 00:00:00 2001 From: James Fellows Yates Date: Thu, 15 Sep 2022 12:30:39 +0200 Subject: [PATCH 3/4] Append profiler to resulting file --- conf/modules.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/modules.config b/conf/modules.config index d4bd038..01e0e17 100644 --- a/conf/modules.config +++ b/conf/modules.config @@ -338,7 +338,7 @@ process { } withName: METAPHLAN3_MERGEMETAPHLANTABLES { - ext.prefix = { "${meta.id}_combined_reports" } + ext.prefix = { "metaphlan3_${meta.id}_combined_reports" } publishDir = [ path: { "${params.outdir}/metaphlan3/" }, mode: params.publish_dir_mode, From f43c54317ccdbb4798708b751206d59eaeeb2f02 Mon Sep 17 00:00:00 2001 From: "James A. Fellows Yates" Date: Fri, 16 Sep 2022 15:20:47 +0200 Subject: [PATCH 4/4] Update subworkflows/local/standardisation_profiles.nf Co-authored-by: Sofia Stamouli <91951607+sofstam@users.noreply.github.com> --- subworkflows/local/standardisation_profiles.nf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subworkflows/local/standardisation_profiles.nf b/subworkflows/local/standardisation_profiles.nf index f63c10a..c8c364d 100644 --- a/subworkflows/local/standardisation_profiles.nf +++ b/subworkflows/local/standardisation_profiles.nf @@ -5,7 +5,7 @@ include { KAIJU_KAIJU2TABLE } from '../../modules/nf-core/modules/kaiju/kaiju2table/main' include { KRAKENTOOLS_COMBINEKREPORTS } from '../../modules/nf-core/modules/krakentools/combinekreports/main' include { KRAKENTOOLS_COMBINEKREPORTS as KRAKENTOOLS_COMBINEKREPORTS_CENTRIFUGE } from '../../modules/nf-core/modules/krakentools/combinekreports/main' -include { METAPHLAN3_MERGEMETAPHLANTABLES } from '../../modules/nf-core/modules/metaphlan3/mergemetaphlantables/main' +include { METAPHLAN3_MERGEMETAPHLANTABLES } from '../../modules/nf-core/modules/metaphlan3/mergemetaphlantables/main' include { MOTUS_MERGE } from '../../modules/nf-core/modules/motus/merge/main' workflow STANDARDISATION_PROFILES {