From f4e816404940e2b49018cd4c73da0ab3723979ed Mon Sep 17 00:00:00 2001 From: bjlang <> Date: Wed, 23 Oct 2024 19:05:11 +0200 Subject: [PATCH 1/4] Move pathway related logic out of differential and correlation SWF --- subworkflows/local/correlation/main.nf | 24 +++++------------ subworkflows/local/differential/main.nf | 35 ++++++++----------------- subworkflows/local/experimental/main.nf | 31 +++++++++++++++------- 3 files changed, 40 insertions(+), 50 deletions(-) diff --git a/subworkflows/local/correlation/main.nf b/subworkflows/local/correlation/main.nf index cc742e63..f7e2d85a 100644 --- a/subworkflows/local/correlation/main.nf +++ b/subworkflows/local/correlation/main.nf @@ -3,16 +3,9 @@ // include {PROPR_PROPR as PROPR} from "../../../modules/local/propr/propr/main.nf" -def correct_meta_data = { meta, data, pathway -> - def meta_clone = meta.clone() + pathway - meta_clone.remove('cor_method') - meta_clone.remove('args_cor') - return [meta_clone, data] -} - workflow CORRELATION { take: - ch_tools // [ pathway_name, correlation_map ] + ch_tools // [ correlation_map ] with the keys: cor_method, args_cor ch_counts main: @@ -24,7 +17,7 @@ workflow CORRELATION { // branch tools to select the correct correlation analysis method ch_tools .branch { - propr: it[1]["cor_method"] == "propr" + propr: it["cor_method"] == "propr" } .set { ch_tools_single } @@ -34,18 +27,15 @@ workflow CORRELATION { ch_counts .combine(ch_tools_single.propr) - .multiMap { - metacounts, counts, pathway, metatools -> + .map { + metacounts, counts, metatools -> input: [ metacounts+metatools, counts ] - pathway: [ metacounts+metatools, pathway ] } .set { ch_counts_propr } - PROPR(ch_counts_propr.input.unique()) - ch_matrix = PROPR.out.matrix - .join(ch_counts_propr.pathway).map(correct_meta_data).mix(ch_matrix) - ch_adjacency = PROPR.out.adjacency - .join(ch_counts_propr.pathway).map(correct_meta_data).mix(ch_adjacency) + PROPR(ch_counts_propr.unique()) + ch_matrix = PROPR.out.matrix.mix(ch_matrix) + ch_adjacency = PROPR.out.adjacency.mix(ch_adjacency) // TODO: divide propr module into cor, propr, pcor, pcorbshrink, etc. diff --git a/subworkflows/local/differential/main.nf b/subworkflows/local/differential/main.nf index 2cc67427..111d686d 100644 --- a/subworkflows/local/differential/main.nf +++ b/subworkflows/local/differential/main.nf @@ -4,16 +4,9 @@ include { PROPR_PROPD as PROPD } from "../../../modules/local/propr/propd/main.nf" include { DESEQ2_DIFFERENTIAL } from '../../../modules/nf-core/deseq2/differential/main' -def correct_meta_data = { meta, data, pathway -> - def meta_clone = meta.clone() + pathway - meta_clone.remove('diff_method') - meta_clone.remove('args_diff') - return [meta_clone, data] -} - workflow DIFFERENTIAL { take: - ch_tools // [ pathway_name, differential_map ] + ch_tools // [ differential_map ] with the keys: diff_method, args_diff ch_counts ch_samplesheet ch_contrasts // [meta, contrast_variable, reference, target] @@ -30,8 +23,8 @@ workflow DIFFERENTIAL { // branch tools to select the correct differential analysis method ch_tools .branch { - propd: it[1]["diff_method"] == "propd" - deseq2: it[1]["diff_method"] == "deseq2" + propd: it["diff_method"] == "propd" + deseq2: it["diff_method"] == "deseq2" } .set { ch_tools_single } @@ -43,25 +36,19 @@ workflow DIFFERENTIAL { .join(ch_samplesheet) .combine(ch_contrasts) .combine(ch_tools_single.propd) - .multiMap { - meta_data, counts, samplesheet, meta_contrast, contrast_variable, reference, target, pathway, meta_tools -> + .map { + meta_data, counts, samplesheet, meta_contrast, contrast_variable, reference, target, meta_tools -> def meta = meta_data.clone() + ['contrast': meta_contrast.id] + meta_tools.clone() input: [ meta, counts, samplesheet, contrast_variable, reference, target ] - pathway: [ meta, pathway ] } .set { ch_propd } - PROPD(ch_propd.input.unique()) - ch_results_pairwise = PROPD.out.results - .join(ch_propd.pathway).map(correct_meta_data).mix(ch_results_pairwise) - ch_results_pairwise_filtered = PROPD.out.results_filtered - .join(ch_propd.pathway).map(correct_meta_data).mix(ch_results_pairwise_filtered) - ch_results_genewise = PROPD.out.connectivity - .join(ch_propd.pathway).map(correct_meta_data).mix(ch_results_genewise) - ch_results_genewise_filtered = PROPD.out.hub_genes - .join(ch_propd.pathway).map(correct_meta_data).mix(ch_results_genewise_filtered) - ch_adjacency = PROPD.out.adjacency - .join(ch_propd.pathway).map(correct_meta_data).mix(ch_adjacency) + PROPD(ch_propd.unique()) + ch_results_pairwise = PROPD.out.results.mix(ch_results_pairwise) + ch_results_pairwise_filtered = PROPD.out.results_filtered.mix(ch_results_pairwise_filtered) + ch_results_genewise = PROPD.out.connectivity.mix(ch_results_genewise) + ch_results_genewise_filtered = PROPD.out.hub_genes.mix(ch_results_genewise_filtered) + ch_adjacency = PROPD.out.adjacency.mix(ch_adjacency) // ---------------------------------------------------- // Perform differential analysis with DESeq2 diff --git a/subworkflows/local/experimental/main.nf b/subworkflows/local/experimental/main.nf index 5376b592..640f6412 100644 --- a/subworkflows/local/experimental/main.nf +++ b/subworkflows/local/experimental/main.nf @@ -5,6 +5,19 @@ include { DIFFERENTIAL } from '../differential/main.nf' include { CORRELATION } from '../correlation/main.nf' include { ENRICHMENT } from '../enrichment/main.nf' +def postprocess_subworkflow_output( ch_results, ch_tools_args ) { + // 1) join results with pathway data + // 2) clean up meta data by removing tool arguments and adding pathway name + return ch_results + .combine(ch_tools_args) + .filter{ meta, data, pathway, arg_map -> meta.subMap(arg_map.keySet()) == arg_map } + .map{ meta, data, pathway, arg_map -> + def meta_clone = meta.clone() + pathway + meta_clone.removeAll{it.key in arg_map.keySet()} + return [meta_clone, data] + } +} + workflow EXPERIMENTAL { take: ch_contrasts // [ meta, contrast_variable, reference, target ] @@ -39,27 +52,27 @@ workflow EXPERIMENTAL { // ---------------------------------------------------- DIFFERENTIAL( - ch_tools.diff, + ch_tools.diff.map{ it[1] }, ch_counts, ch_samplesheet, ch_contrasts ) - ch_results_pairwise = ch_results_pairwise.mix(DIFFERENTIAL.out.results_pairwise) - ch_results_pairwise_filtered = ch_results_pairwise_filtered.mix(DIFFERENTIAL.out.results_pairwise_filtered) - ch_results_genewise = ch_results_genewise.mix(DIFFERENTIAL.out.results_genewise) - ch_results_genewise_filtered = ch_results_genewise_filtered.mix(DIFFERENTIAL.out.results_genewise_filtered) - ch_adjacency = ch_adjacency.mix(DIFFERENTIAL.out.adjacency) + ch_results_pairwise = postprocess_subworkflow_output(DIFFERENTIAL.out.results_pairwise,ch_tools.diff).mix(ch_results_pairwise) + ch_results_pairwise_filtered = postprocess_subworkflow_output(DIFFERENTIAL.out.results_pairwise_filtered,ch_tools.diff).mix(ch_results_pairwise_filtered) + ch_results_genewise = postprocess_subworkflow_output(DIFFERENTIAL.out.results_genewise,ch_tools.diff).mix(ch_results_genewise) + ch_results_genewise_filtered = postprocess_subworkflow_output(DIFFERENTIAL.out.results_genewise_filtered,ch_tools.diff).mix(ch_results_genewise_filtered) + ch_adjacency = postprocess_subworkflow_output(DIFFERENTIAL.out.adjacency,ch_tools.diff).mix(ch_adjacency) // ---------------------------------------------------- // CORRELATION ANALYSIS BLOCK // ---------------------------------------------------- CORRELATION( - ch_tools.corr, + ch_tools.corr.map{ it[1] }, ch_counts ) - ch_matrix = ch_matrix.mix(CORRELATION.out.matrix) - ch_adjacency = ch_adjacency.mix(CORRELATION.out.adjacency) + ch_matrix = postprocess_subworkflow_output(CORRELATION.out.matrix,ch_tools.corr).mix(ch_matrix) + ch_adjacency = postprocess_subworkflow_output(CORRELATION.out.adjacency,ch_tools.corr).mix(ch_adjacency) // ---------------------------------------------------- // FUNCTIONAL ENRICHMENT BLOCK From 94d3c8e7e48b0ad9e4c892f4078f0a20e809e980 Mon Sep 17 00:00:00 2001 From: bjlang <> Date: Tue, 29 Oct 2024 16:56:29 +0100 Subject: [PATCH 2/4] Once more reorganize the pathway logic --- conf/modules.config | 20 +------ subworkflows/local/correlation/main.nf | 20 ++----- subworkflows/local/differential/main.nf | 23 ++++---- subworkflows/local/enrichment/main.nf | 33 +++++------ subworkflows/local/experimental/main.nf | 77 ++++++++++++++++--------- 5 files changed, 85 insertions(+), 88 deletions(-) diff --git a/conf/modules.config b/conf/modules.config index a0f8c56f..1bb43755 100644 --- a/conf/modules.config +++ b/conf/modules.config @@ -507,10 +507,7 @@ process { "--number_of_cutoffs ${params.propr_ncutoffs}" ].join(' ').trim() } publishDir = [ - path: { - meta.args_cor ? "${params.outdir}/correlation_analysis/propr-${meta.args_cor.replace('--','').replace(' ', '_')}" : - "${params.outdir}/correlation_analysis/propr" - }, + path: { "${params.outdir}/correlation_analysis/propr-${meta.pathway_name ?: params.pathway}" }, mode: params.publish_dir_mode, saveAs: { filename -> filename.equals('versions.yml') ? null : filename } ] @@ -534,10 +531,7 @@ process { "--weighted_degree ${params.propd_weighted_degree}" ].join(' ').trim() } publishDir = [ - path: { - meta.args_diff ? "${params.outdir}/differential_analysis/propd-${meta.args_diff.replace('--','').replace(' ', '_')}/${meta.contrast}" : - "${params.outdir}/differential_analysis/propd/${meta.contrast}" - }, + path: { "${params.outdir}/differential_analysis/propr-${meta.pathway_name ?: params.pathway}" }, mode: params.publish_dir_mode, saveAs: { filename -> filename.equals('versions.yml') ? null : filename } ] @@ -555,15 +549,7 @@ process { "--permutation ${params.grea_permutation}" ].join(' ').trim() } publishDir = [ - path: { - meta.args_enr ? "${params.outdir}/enrichment_analysis/grea-${meta.args_enr.replace('--','').replace(' ', '_')}" : - "${params.outdir}/enrichment_analysis/grea" - }, - mode: params.publish_dir_mode, - saveAs: { filename -> filename.equals('versions.yml') ? null : filename } - ] - publishDir = [ - path: { "${params.outdir}/enrichment_analysis/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" }, + path: { "${params.outdir}/enrichment_analysis/propr-${meta.pathway_name ?: params.pathway}" }, mode: params.publish_dir_mode, saveAs: { filename -> filename.equals('versions.yml') ? null : filename } ] diff --git a/subworkflows/local/correlation/main.nf b/subworkflows/local/correlation/main.nf index f7e2d85a..d62f435f 100644 --- a/subworkflows/local/correlation/main.nf +++ b/subworkflows/local/correlation/main.nf @@ -5,8 +5,7 @@ include {PROPR_PROPR as PROPR} from "../../../modules/local/propr/propr/main.nf" workflow CORRELATION { take: - ch_tools // [ correlation_map ] with the keys: cor_method, args_cor - ch_counts + ch_counts // [ meta, counts] with meta keys: method, args_cor main: @@ -15,25 +14,16 @@ workflow CORRELATION { ch_adjacency = Channel.empty() // branch tools to select the correct correlation analysis method - ch_tools + ch_counts .branch { - propr: it["cor_method"] == "propr" + propr: it[0]["method"] == "propr" } - .set { ch_tools_single } + .set { ch_counts } // ---------------------------------------------------- // Perform correlation analysis with propr // ---------------------------------------------------- - - ch_counts - .combine(ch_tools_single.propr) - .map { - metacounts, counts, metatools -> - input: [ metacounts+metatools, counts ] - } - .set { ch_counts_propr } - - PROPR(ch_counts_propr.unique()) + PROPR(ch_counts.propr.unique()) ch_matrix = PROPR.out.matrix.mix(ch_matrix) ch_adjacency = PROPR.out.adjacency.mix(ch_adjacency) diff --git a/subworkflows/local/differential/main.nf b/subworkflows/local/differential/main.nf index 111d686d..b497a664 100644 --- a/subworkflows/local/differential/main.nf +++ b/subworkflows/local/differential/main.nf @@ -6,8 +6,7 @@ include { DESEQ2_DIFFERENTIAL } from '../../../modules/nf-core/deseq2/different workflow DIFFERENTIAL { take: - ch_tools // [ differential_map ] with the keys: diff_method, args_diff - ch_counts + ch_counts // [ meta, counts] with meta keys: method, args_diff ch_samplesheet ch_contrasts // [meta, contrast_variable, reference, target] @@ -21,25 +20,25 @@ workflow DIFFERENTIAL { ch_adjacency = Channel.empty() // branch tools to select the correct differential analysis method - ch_tools + ch_counts .branch { - propd: it["diff_method"] == "propd" - deseq2: it["diff_method"] == "deseq2" + propd: it[0]["method"] == "propd" + deseq2: it[0]["method"] == "deseq2" } - .set { ch_tools_single } + .set { ch_counts } // ---------------------------------------------------- // Perform differential analysis with propd // ---------------------------------------------------- - ch_counts - .join(ch_samplesheet) + ch_counts.propd + .combine(ch_samplesheet) + .filter{ meta_counts, counts, meta_samplesheet, samplesheet -> meta_counts.subMap(meta_samplesheet.keySet()) == meta_samplesheet } .combine(ch_contrasts) - .combine(ch_tools_single.propd) .map { - meta_data, counts, samplesheet, meta_contrast, contrast_variable, reference, target, meta_tools -> - def meta = meta_data.clone() + ['contrast': meta_contrast.id] + meta_tools.clone() - input: [ meta, counts, samplesheet, contrast_variable, reference, target ] + meta_data, counts, meta_samplesheet, samplesheet, meta_contrast, contrast_variable, reference, target -> + def meta = meta_data.clone() + ['contrast': meta_contrast.id] + return [ meta, counts, samplesheet, contrast_variable, reference, target ] } .set { ch_propd } diff --git a/subworkflows/local/enrichment/main.nf b/subworkflows/local/enrichment/main.nf index 936ddfcc..54609af1 100644 --- a/subworkflows/local/enrichment/main.nf +++ b/subworkflows/local/enrichment/main.nf @@ -6,7 +6,6 @@ include { PROPR_GREA as GREA } from "../../../modules/local/propr/grea/main.nf" workflow ENRICHMENT { take: - ch_tools // [ pathway_name, enrichment_map ] ch_counts ch_results_genewise ch_results_genewise_filtered @@ -17,6 +16,14 @@ workflow ENRICHMENT { // initialize empty results channels ch_enriched = Channel.empty() + ch_gmt = Channel.empty() + + ch_adjacency + .branch { + grea: it[0]["method"] == "grea" + gsea: it[0]["method"] == "gsea" + } + .set { ch_adjacency } // ---------------------------------------------------- // Construct gene set database @@ -24,28 +31,20 @@ workflow ENRICHMENT { // TODO this should be optional, only run when there is no gene set data provided by user + // empty counts channel of ch_adjacency is empty to skip unnecessary MYGENE computations + ch_counts + .combine(ch_adjacency.grea) + .map{ meta_counts, counts, meta_adjacency, adjacency -> [meta_counts, counts]} + .unique() + .set{ch_counts} + MYGENE(ch_counts.take(1)) // only one data is provided to this pipeline ch_gmt = MYGENE.out.gmt // ---------------------------------------------------- // Perform enrichment analysis with GREA // ---------------------------------------------------- - - ch_adjacency - .map { meta, matrix -> [meta.subMap(["pathway_name"]), meta, matrix] } - .join(ch_tools, by: [0]) - .map { - pathway_name, meta, matrix, meta_tools -> - def new_meta = meta.clone() + meta_tools.clone() - [ new_meta, matrix ] - } - .branch { - grea: it[0]["enr_method"] == "grea" - gsea: it[0]["enr_method"] == "gsea" - } - .set { ch_adjacency } - - GREA(ch_adjacency.grea, ch_gmt.collect()) + GREA(ch_adjacency.grea.unique(), ch_gmt.collect()) ch_enriched = ch_enriched.mix(GREA.out.results) // ---------------------------------------------------- diff --git a/subworkflows/local/experimental/main.nf b/subworkflows/local/experimental/main.nf index 640f6412..0679ab6c 100644 --- a/subworkflows/local/experimental/main.nf +++ b/subworkflows/local/experimental/main.nf @@ -5,15 +5,24 @@ include { DIFFERENTIAL } from '../differential/main.nf' include { CORRELATION } from '../correlation/main.nf' include { ENRICHMENT } from '../enrichment/main.nf' -def postprocess_subworkflow_output( ch_results, ch_tools_args ) { - // 1) join results with pathway data - // 2) clean up meta data by removing tool arguments and adding pathway name - return ch_results +def preprocess_subworkflow_output( ch_input, ch_tools_args, method_field_name) { + // add method arguments to channel meta + return ch_input .combine(ch_tools_args) - .filter{ meta, data, pathway, arg_map -> meta.subMap(arg_map.keySet()) == arg_map } - .map{ meta, data, pathway, arg_map -> - def meta_clone = meta.clone() + pathway - meta_clone.removeAll{it.key in arg_map.keySet()} + .filter{ meta, input, pathway, arg_maps -> meta["pathway_name"] ? meta["pathway_name"] == pathway["pathway_name"] : true } + .map{ meta, input, pathway, arg_map -> + def meta_clone = meta.clone() + pathway + arg_map.clone() + meta_clone["method"] = meta_clone.remove(method_field_name) + return [meta_clone, input] + } +} + +def postprocess_subworkflow_output( ch_results, field_name ) { + // clean up meta data by removing tool arguments + return ch_results + .map{ meta, data -> + def meta_clone = meta.clone() + meta_clone.removeAll{it.key in field_name} return [meta_clone, data] } } @@ -28,16 +37,17 @@ workflow EXPERIMENTAL { main: // split toolsheet into channels - ch_tools + ch_tools.count() + .combine(ch_tools) .multiMap{ - pathway_name, differential_map, correlation_map, enrichment_map -> + n, pathway, differential_map, correlation_map, enrichment_map -> + def pathway_name = n == 1 ? ["pathway_name":""] : pathway diff: [ pathway_name, differential_map ] corr: [ pathway_name, correlation_map ] enr: [ pathway_name, enrichment_map ] } .set{ ch_tools } - // initialize empty results channels ch_results_pairwise = Channel.empty() // differential results for pairwise analysis - it should be a table ch_results_pairwise_filtered = Channel.empty() // differential results for pairwise analysis - filtered - it should be a table @@ -51,39 +61,52 @@ workflow EXPERIMENTAL { // DIFFERENTIAL ANALYSIS BLOCK // ---------------------------------------------------- + preprocess_subworkflow_output(ch_counts, ch_tools.diff, "diff_method") + .set{ ch_counts_diff } + ch_counts_diff.view{"diff: "+it} DIFFERENTIAL( - ch_tools.diff.map{ it[1] }, - ch_counts, + ch_counts_diff, ch_samplesheet, ch_contrasts ) - ch_results_pairwise = postprocess_subworkflow_output(DIFFERENTIAL.out.results_pairwise,ch_tools.diff).mix(ch_results_pairwise) - ch_results_pairwise_filtered = postprocess_subworkflow_output(DIFFERENTIAL.out.results_pairwise_filtered,ch_tools.diff).mix(ch_results_pairwise_filtered) - ch_results_genewise = postprocess_subworkflow_output(DIFFERENTIAL.out.results_genewise,ch_tools.diff).mix(ch_results_genewise) - ch_results_genewise_filtered = postprocess_subworkflow_output(DIFFERENTIAL.out.results_genewise_filtered,ch_tools.diff).mix(ch_results_genewise_filtered) - ch_adjacency = postprocess_subworkflow_output(DIFFERENTIAL.out.adjacency,ch_tools.diff).mix(ch_adjacency) + ch_results_pairwise = postprocess_subworkflow_output(DIFFERENTIAL.out.results_pairwise,["method", "args_diff"]).mix(ch_results_pairwise) + ch_results_pairwise_filtered = postprocess_subworkflow_output(DIFFERENTIAL.out.results_pairwise_filtered,["method", "args_diff"]).mix(ch_results_pairwise_filtered) + ch_results_genewise = postprocess_subworkflow_output(DIFFERENTIAL.out.results_genewise,["method", "args_diff"]).mix(ch_results_genewise) + ch_results_genewise_filtered = postprocess_subworkflow_output(DIFFERENTIAL.out.results_genewise_filtered,["method", "args_diff"]).mix(ch_results_genewise_filtered) + ch_adjacency = postprocess_subworkflow_output(DIFFERENTIAL.out.adjacency,["method", "args_diff"]).mix(ch_adjacency) // ---------------------------------------------------- // CORRELATION ANALYSIS BLOCK // ---------------------------------------------------- + preprocess_subworkflow_output(ch_counts, ch_tools.corr, "cor_method") + .set{ ch_counts_corr } + ch_counts_corr.view{"corr: "+it} + CORRELATION( - ch_tools.corr.map{ it[1] }, - ch_counts + ch_counts_corr ) - ch_matrix = postprocess_subworkflow_output(CORRELATION.out.matrix,ch_tools.corr).mix(ch_matrix) - ch_adjacency = postprocess_subworkflow_output(CORRELATION.out.adjacency,ch_tools.corr).mix(ch_adjacency) + ch_matrix = postprocess_subworkflow_output(CORRELATION.out.matrix,["method", "args_cor"]).mix(ch_matrix) + ch_adjacency = postprocess_subworkflow_output(CORRELATION.out.adjacency,["method", "args_cor"]).mix(ch_adjacency) // ---------------------------------------------------- // FUNCTIONAL ENRICHMENT BLOCK // ---------------------------------------------------- + preprocess_subworkflow_output(ch_counts, ch_tools.enr, "enr_method") + .set{ ch_counts_enr } + preprocess_subworkflow_output(ch_results_genewise, ch_tools.enr, "enr_method") + .set{ ch_results_genewise_enr } + preprocess_subworkflow_output(ch_results_genewise_filtered, ch_tools.enr, "enr_method") + .set{ ch_results_genewise_filtered_enr } + preprocess_subworkflow_output(ch_adjacency, ch_tools.enr, "enr_method") + .set{ ch_adjacency_enr } + ENRICHMENT( - ch_tools.enr, - ch_counts, - ch_results_genewise, - ch_results_genewise_filtered, - ch_adjacency + ch_counts_enr, + ch_results_genewise_enr, + ch_results_genewise_filtered_enr, + ch_adjacency_enr ) ch_enriched = ch_enriched.mix(ENRICHMENT.out.enriched) From f7c5c773135b750c9b60674c43d10022a64d399a Mon Sep 17 00:00:00 2001 From: bjlang <> Date: Tue, 29 Oct 2024 18:35:24 +0100 Subject: [PATCH 3/4] Adapt Limma call --- subworkflows/local/differential/main.nf | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/subworkflows/local/differential/main.nf b/subworkflows/local/differential/main.nf index 799c372b..95679387 100644 --- a/subworkflows/local/differential/main.nf +++ b/subworkflows/local/differential/main.nf @@ -84,17 +84,16 @@ workflow DIFFERENTIAL { // combine the input channels with the tools information // in this way, limma will only be run if the user have specified it, as informed by ch_tools - ch_counts - .join(ch_samplesheet) + ch_counts.limma + .combine(ch_samplesheet) + .filter{ meta_counts, counts, meta_samplesheet, samplesheet -> meta_counts.subMap(meta_samplesheet.keySet()) == meta_samplesheet } .combine(ch_contrasts) - .combine(ch_tools_single.limma) .unique() .multiMap { - meta_data, counts, samplesheet, meta_contrast, contrast_variable, reference, target, pathway, meta_tools -> - def meta = meta_data.clone() + meta_contrast.clone() + meta_tools.clone() + meta_data, counts, meta_samplesheet, samplesheet, meta_contrast, contrast_variable, reference, target -> + def meta = meta_data.clone() + meta_contrast.clone() input1: [ meta, contrast_variable, reference, target ] input2: [ meta, samplesheet, counts ] - pathway: [ meta, pathway ] } .set { ch_limma } @@ -113,10 +112,8 @@ workflow DIFFERENTIAL { ) // collect results - ch_results_genewise = LIMMA_DIFFERENTIAL.out.results - .join(ch_limma.pathway).map(correct_meta_data).mix(ch_results_genewise) - ch_results_genewise_filtered = FILTER_DIFFTABLE_LIMMA.out.filtered - .join(ch_limma.pathway).map(correct_meta_data).mix(ch_results_genewise_filtered) + ch_results_genewise = LIMMA_DIFFERENTIAL.out.results.mix(ch_results_genewise) + ch_results_genewise_filtered = FILTER_DIFFTABLE_LIMMA.out.filtered.mix(ch_results_genewise_filtered) emit: results_pairwise = ch_results_pairwise From 953eb5188ddd0dd3e2bcc40a9f835b3f2c6cd941 Mon Sep 17 00:00:00 2001 From: bjlang <> Date: Wed, 30 Oct 2024 12:15:10 +0100 Subject: [PATCH 4/4] Implement review comments --- subworkflows/local/enrichment/main.nf | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/subworkflows/local/enrichment/main.nf b/subworkflows/local/enrichment/main.nf index 47e5045d..50736a62 100644 --- a/subworkflows/local/enrichment/main.nf +++ b/subworkflows/local/enrichment/main.nf @@ -22,7 +22,6 @@ workflow ENRICHMENT { ch_adjacency .branch { grea: it[0]["method"] == "grea" - gsea: it[0]["method"] == "gsea" } .set { ch_adjacency } @@ -32,13 +31,6 @@ workflow ENRICHMENT { // TODO this should be optional, only run when there is no gene set data provided by user - // empty counts channel of ch_adjacency is empty to skip unnecessary MYGENE computations - ch_counts - .combine(ch_adjacency.grea) - .map{ meta_counts, counts, meta_adjacency, adjacency -> [meta_counts, counts]} - .unique() - .set{ch_counts} - MYGENE(ch_counts.take(1)) // only one data is provided to this pipeline ch_gmt = MYGENE.out.gmt @@ -72,7 +64,7 @@ workflow ENRICHMENT { ch_background = Channel.from(file(params.gprofiler2_background_file, checkIfExists: true)) } - // rearrage channel for GPROFILER2_GOST process + // rearrange channel for GPROFILER2_GOST process ch_gmt = ch_gmt.map { meta, gmt -> gmt } ch_results_genewise_filtered