diff --git a/conf/modules.config b/conf/modules.config index 2ea2f1f..c20f50a 100644 --- a/conf/modules.config +++ b/conf/modules.config @@ -293,7 +293,16 @@ process { ] } - withName: KRONA_IMPORTKRAKEN { + withName: KRAKENTOOLS_KREPORT2KRONA { + ext.prefix = params.perform_runmerging ? { "${meta.id}-${meta.db_name}" } : { "${meta.id}-${meta.run_accession}-${meta.db_name}" } + } + + withName: KRONA_KRAKENCLEANUP { + ext.prefix = params.perform_runmerging ? { "${meta.id}-${meta.db_name}" } : { "${meta.id}-${meta.run_accession}-${meta.db_name}" } + } + + withName: KRONA_KTIMPORTTEXT { + ext.prefix = { "${meta.tool}-${meta.db_name}" } publishDir = [ path: { "${params.outdir}/krona" }, mode: params.publish_dir_mode, diff --git a/subworkflows/local/postprocessing_krona.nf b/subworkflows/local/postprocessing_krona.nf new file mode 100644 index 0000000..0ef4f88 --- /dev/null +++ b/subworkflows/local/postprocessing_krona.nf @@ -0,0 +1,66 @@ +// +// Remove host reads via alignment and export off-target reads +// + +include { KRAKENTOOLS_KREPORT2KRONA } from '../../modules/nf-core/modules/krakentools/kreport2krona/main' +include { KRONA_CLEANUP as KRONA_KRAKENCLEANUP } from '../../modules/local/krona_cleanup' +include { KRONA_KTIMPORTTEXT } from '../../modules/nf-core/modules/krona/ktimporttext/main' +include { CENTRIFUGE_KREPORT } from '../../modules/nf-core/modules/centrifuge/kreport/main' + +workflow POSTPROCESSING_KRONA { + take: + krona_input + databases + + main: + ch_versions = Channel.empty() + ch_input_for_ktimporttext = Channel.empty() + + ch_files_for_krona = krona_input + .branch { + // malt: + kraken2: it[0]['tool'] == 'kraken2' + centrifuge: it[0]['tool'] == 'centrifuge' + //metaphlan3: + //kaiju: + //diamond: + } + + ch_databases = databases + .branch{ + centrifuge: it[0]['tool'] == 'centrifuge' + } + + // TODO PUSH BACK CENTRIFUGE_KREPORT TO PROFILING.NF WHERE DATABASE ALREADY IS? + ch_input_for_centrifuge_kreport = ch_files_for_krona.centrifuge + .dump(tag: "db_for_kreport_pre") + .join(ch_databases, by: 0) + .dump(tag: "db_for_kreport_post") + + + // Kraken + KRAKENTOOLS_KREPORT2KRONA ( ch_files_for_krona.kraken2 ) + KRONA_KRAKENCLEANUP ( KRAKENTOOLS_KREPORT2KRONA.out.txt ) + ch_kraken_for_krona = KRONA_KRAKENCLEANUP.out.txt + .map{ + [[id: it[0].tool + "-" + it[0].db_name, db_name: it[0].db_name, tool: it[0].tool ], it[1]] + } + .groupTuple() + ch_input_for_ktimporttext = ch_input_for_ktimporttext.mix( ch_kraken_for_krona ) + ch_versions = ch_versions.mix( KRAKENTOOLS_KREPORT2KRONA.out.versions.first() ) + ch_versions = ch_versions.mix( KRONA_KRAKENCLEANUP.out.versions.first() ) + + + KRONA_KTIMPORTTEXT (ch_input_for_ktimporttext) + + + ch_versions = ch_versions.mix( KRONA_KTIMPORTTEXT.out.versions.first() ) + + // Centrifuge + //CENTRIFUGE_KREPORT (krona_input.centrifuge, ch_input_for_centrifuge.db) + // ch_versions = ch_versions.mix( /CENTRIFUGE_KREPORT.out.versions.first() ) + + emit: + versions = ch_versions // channel: [ versions.yml ] +} + diff --git a/subworkflows/local/profiling.nf b/subworkflows/local/profiling.nf index bba8af9..f3b31e8 100644 --- a/subworkflows/local/profiling.nf +++ b/subworkflows/local/profiling.nf @@ -5,11 +5,7 @@ include { MALT_RUN } from '../../modules/nf-core/modules/malt/run/main' include { MEGAN_RMA2INFO } from '../../modules/nf-core/modules/megan/rma2info/main' include { KRAKEN2_KRAKEN2 } from '../../modules/nf-core/modules/kraken2/kraken2/main' -include { KRAKENTOOLS_KREPORT2KRONA } from '../../modules/nf-core/modules/krakentools/kreport2krona/main' -include { KRONA_CLEANUP as KRONA_KRAKENCLEANUP } from '../../modules/local/krona_cleanup' -include { KRONA_KTIMPORTTEXT as KRONA_IMPORTKRAKEN } from '../../modules/nf-core/modules/krona/ktimporttext/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/main' include { KAIJU_KAIJU } from '../../modules/nf-core/modules/kaiju/kaiju/main' include { KAIJU_KAIJU2TABLE } from '../../modules/nf-core/modules/kaiju/kaiju2table/main' @@ -24,8 +20,8 @@ workflow PROFILING { main: ch_versions = Channel.empty() ch_multiqc_files = Channel.empty() - ch_raw_profiles = Channel.empty() - ch_visualizations = Channel.empty() + ch_raw_profiles = Channel.empty() + ch_output_for_krona = Channel.empty() /* COMBINE READS WITH POSSIBLE DATABASES @@ -128,17 +124,11 @@ workflow PROFILING { } KRAKEN2_KRAKEN2 ( ch_input_for_kraken2.reads, ch_input_for_kraken2.db, params.kraken2_save_reads, params.kraken2_save_readclassification ) - KRAKENTOOLS_KREPORT2KRONA ( KRAKEN2_KRAKEN2.out.report ) - KRONA_KRAKENCLEANUP ( KRAKENTOOLS_KREPORT2KRONA.out.txt ) - KRONA_IMPORTKRAKEN( KRONA_KRAKENCLEANUP.out.txt.map{[[id: it[0].db_name], it[1]]}.groupTuple() ) - ch_multiqc_files = ch_multiqc_files.mix( KRAKEN2_KRAKEN2.out.report.collect{it[1]}.ifEmpty([]) ) - ch_visualizations = ch_visualizations.mix( KRONA_IMPORTKRAKEN.out.html ) - ch_versions = ch_versions.mix( KRAKEN2_KRAKEN2.out.versions.first() ) - ch_versions = ch_versions.mix( KRAKENTOOLS_KREPORT2KRONA.out.versions.first() ) - ch_versions = ch_versions.mix( KRONA_KRAKENCLEANUP.out.versions.first() ) - ch_versions = ch_versions.mix( KRONA_IMPORTKRAKEN.out.versions.first() ) - ch_raw_profiles = ch_raw_profiles.mix( KRAKEN2_KRAKEN2.out.report ) + ch_multiqc_files = ch_multiqc_files.mix( KRAKEN2_KRAKEN2.out.report.collect{it[1]}.ifEmpty([]) ) + ch_output_for_krona = ch_output_for_krona.mix( KRAKEN2_KRAKEN2.out.report ) + ch_versions = ch_versions.mix( KRAKEN2_KRAKEN2.out.versions.first() ) + ch_raw_profiles = ch_raw_profiles.mix( KRAKEN2_KRAKEN2.out.report ) } @@ -156,9 +146,11 @@ workflow PROFILING { } CENTRIFUGE_CENTRIFUGE ( ch_input_for_centrifuge.reads, ch_input_for_centrifuge.db, params.centrifuge_save_reads, params.centrifuge_save_reads, params.centrifuge_save_reads ) - CENTRIFUGE_KREPORT (CENTRIFUGE_CENTRIFUGE.out.results, ch_input_for_centrifuge.db) - ch_versions = ch_versions.mix( CENTRIFUGE_CENTRIFUGE.out.versions.first() ) - ch_raw_profiles = ch_raw_profiles.mix( CENTRIFUGE_KREPORT.out.kreport ) + // TODO PUSH BACK CENTRIFUGE_KREPORT HERE WHERE DATABASE ALREADY IS? + + ch_output_for_krona = ch_output_for_krona.mix( CENTRIFUGE_CENTRIFUGE.out.report ) + ch_versions = ch_versions.mix( CENTRIFUGE_CENTRIFUGE.out.versions.first() ) + ch_raw_profiles = ch_raw_profiles.mix( CENTRIFUGE_CENTRIFUGE.out.report ) } @@ -221,5 +213,5 @@ workflow PROFILING { profiles = ch_raw_profiles // channel: [ val(meta), [ reads ] ] - should be text files or biom versions = ch_versions // channel: [ versions.yml ] mqc = ch_multiqc_files - visualizations = ch_visualizations + krona = ch_output_for_krona } diff --git a/workflows/taxprofiler.nf b/workflows/taxprofiler.nf index f29a366..71e78af 100644 --- a/workflows/taxprofiler.nf +++ b/workflows/taxprofiler.nf @@ -62,6 +62,7 @@ include { SHORTREAD_HOSTREMOVAL } from '../subworkflows/local/shortread_ include { LONGREAD_HOSTREMOVAL } from '../subworkflows/local/longread_hostremoval' include { SHORTREAD_COMPLEXITYFILTERING } from '../subworkflows/local/shortread_complexityfiltering' include { PROFILING } from '../subworkflows/local/profiling' +include { POSTPROCESSING_KRONA } from '../subworkflows/local/postprocessing_krona' /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -209,6 +210,13 @@ workflow TAXPROFILER { PROFILING ( ch_reads_runmerged, DB_CHECK.out.dbs ) ch_versions = ch_versions.mix( PROFILING.out.versions ) + /* + SUBWORKFLOW: KRONA VISUALISATION + */ + POSTPROCESSING_KRONA ( PROFILING.out.krona, DB_CHECK.out.dbs ) + ch_versions = ch_versions.mix( POSTPROCESSING_KRONA.out.versions ) + + /* MODULE: MultiQC */