From 2b977a47af8a319f6ef6e7b918e7bb64babbaa04 Mon Sep 17 00:00:00 2001 From: Suzanne Jin Date: Thu, 16 Jan 2025 12:24:18 +0100 Subject: [PATCH] update NORM meta in abundance_differential_filter (#7302) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * modified abundance_differential_filter to use meta_exp in deseq_norm and limma_norm, and updated test snapshots * update snapshot * update snapshot * revert order to call modules * revert test name * update snapshot * update snapshot * fix bug related to norm_inputs * avoid running multiple times NORM unecessarily by using unique(). Updated snapshots * remove view() * add back norm_inputs to avoid repeated computation of all the contrasts * distinguish contrasts_for_diff and contrasts_for_norm * remove unique() * add view to check everything is right * update view * update view * remerge criteria but with def meta at the beginning * remove view. bug fixed. --------- Co-authored-by: Matthias Hörtenhuber --- .../abundance_differential_filter/main.nf | 27 +-- .../abundance_differential_filter/meta.yml | 2 +- .../tests/deseq2_basic.config | 8 +- .../tests/deseq2_limmavoom_basic.config | 6 +- .../tests/deseq2_limmavoom_propd_basic.config | 6 +- .../tests/main.nf.test | 4 +- .../tests/main.nf.test.snap | 160 ++++++------------ 7 files changed, 83 insertions(+), 130 deletions(-) diff --git a/subworkflows/nf-core/abundance_differential_filter/main.nf b/subworkflows/nf-core/abundance_differential_filter/main.nf index 4930b708b55..8c11efa55eb 100644 --- a/subworkflows/nf-core/abundance_differential_filter/main.nf +++ b/subworkflows/nf-core/abundance_differential_filter/main.nf @@ -31,15 +31,16 @@ workflow ABUNDANCE_DIFFERENTIAL_FILTER { // Set up how the channels crossed below will be used to generate channels for processing def criteria = multiMapCriteria { meta_input, abundance, analysis_method, fc_threshold, stat_threshold, meta_exp, samplesheet, meta_contrasts, variable, reference, target -> + def meta_for_diff = mergeMaps(meta_contrasts, meta_input) + [ 'method': analysis_method ] + def meta_input_new = meta_input + [ 'method': analysis_method ] samples_and_matrix: - meta_map = meta_input + [ 'method': analysis_method ] - [meta_map, samplesheet, abundance] - contrasts: - meta_map = mergeMaps(meta_contrasts, meta_input) + [ 'method': analysis_method ] - [ meta_map, variable, reference, target ] + [ meta_input_new, samplesheet, abundance ] + contrasts_for_diff: + [ meta_for_diff, variable, reference, target ] filter_params: - meta_map = mergeMaps(meta_contrasts, meta_input) + [ 'method': analysis_method ] - [meta_map, [ 'fc_threshold': fc_threshold, 'stat_threshold': stat_threshold ]] + [ meta_for_diff, [ 'fc_threshold': fc_threshold, 'stat_threshold': stat_threshold ]] + contrasts_for_norm: + [ meta_input_new, variable, reference, target ] } // For DIFFERENTIAL modules we need to cross the things we're iterating so we @@ -70,13 +71,13 @@ workflow ABUNDANCE_DIFFERENTIAL_FILTER { // LIMMA_NORM directly. It internally runs normalization + DE analysis. LIMMA_NORM( - norm_inputs.contrasts.filter{it[0].method == 'limma'}.first(), + norm_inputs.contrasts_for_norm.filter{it[0].method == 'limma'}, norm_inputs.samples_and_matrix.filter{it[0].method == 'limma'} ) LIMMA_DIFFERENTIAL( - inputs.contrasts.filter{it[0].method == 'limma'}, - inputs.samples_and_matrix.filter { it[0].method == 'limma' } + inputs.contrasts_for_diff.filter{ it[0].method == 'limma' }, + inputs.samples_and_matrix.filter{ it[0].method == 'limma' } ) // ---------------------------------------------------- @@ -91,14 +92,14 @@ workflow ABUNDANCE_DIFFERENTIAL_FILTER { // DESEQ2_NORM directly. It internally runs normalization + DE analysis. DESEQ2_NORM( - norm_inputs.contrasts.filter{it[0].method == 'deseq2'}.first(), + norm_inputs.contrasts_for_norm.filter{it[0].method == 'deseq2'}, norm_inputs.samples_and_matrix.filter{it[0].method == 'deseq2'}, ch_control_features.first(), ch_transcript_lengths.first() ) DESEQ2_DIFFERENTIAL( - inputs.contrasts.filter{it[0].method == 'deseq2'}, + inputs.contrasts_for_diff.filter{it[0].method == 'deseq2'}, inputs.samples_and_matrix.filter{it[0].method == 'deseq2'}, ch_control_features.first(), ch_transcript_lengths.first() @@ -112,7 +113,7 @@ workflow ABUNDANCE_DIFFERENTIAL_FILTER { // not produce a normalized matrix. PROPR_PROPD( - inputs.contrasts.filter{it[0].method == 'propd'}, + inputs.contrasts_for_diff.filter{it[0].method == 'propd'}, inputs.samples_and_matrix.filter { it[0].method == 'propd' } ) diff --git a/subworkflows/nf-core/abundance_differential_filter/meta.yml b/subworkflows/nf-core/abundance_differential_filter/meta.yml index 509520f3ec3..cc22f805353 100644 --- a/subworkflows/nf-core/abundance_differential_filter/meta.yml +++ b/subworkflows/nf-core/abundance_differential_filter/meta.yml @@ -133,7 +133,7 @@ output: authors: - "@pinin4fjords" - "@bjlang" - - "@araiz2001" + - "@caraiz2001" - "@suzannejin" maintainers: - "@pinin4fjords" diff --git a/subworkflows/nf-core/abundance_differential_filter/tests/deseq2_basic.config b/subworkflows/nf-core/abundance_differential_filter/tests/deseq2_basic.config index 508fa04aedc..d6918e56f6a 100644 --- a/subworkflows/nf-core/abundance_differential_filter/tests/deseq2_basic.config +++ b/subworkflows/nf-core/abundance_differential_filter/tests/deseq2_basic.config @@ -1,10 +1,14 @@ process { withName: 'DESEQ2_DIFFERENTIAL' { - ext.args = { "--round_digits 5 --blocking_variables $meta.blocking --vs_method rlog" } + ext.args = { [ + "--round_digits 5", + "--vs_method rlog", + (meta.blocking == null) ? "" : "--blocking_variables $meta.blocking" + ].join(' ').trim() } ext.prefix = { "${meta.id}_${meta.method}" } } withName: 'DESEQ2_NORM' { - ext.prefix = { "${meta.id}_${meta.method}_voom_norm" } + ext.prefix = { "${meta.id}_${meta.method}_norm" } } } diff --git a/subworkflows/nf-core/abundance_differential_filter/tests/deseq2_limmavoom_basic.config b/subworkflows/nf-core/abundance_differential_filter/tests/deseq2_limmavoom_basic.config index a2b6e9efbd9..14fcfefa6dd 100644 --- a/subworkflows/nf-core/abundance_differential_filter/tests/deseq2_limmavoom_basic.config +++ b/subworkflows/nf-core/abundance_differential_filter/tests/deseq2_limmavoom_basic.config @@ -1,6 +1,10 @@ process { withName: 'DESEQ2_DIFFERENTIAL' { - ext.args = { "--round_digits 5 --blocking_variables $meta.blocking --vs_method rlog" } + ext.args = { [ + "--round_digits 5", + "--vs_method rlog", + (meta.blocking == null) ? "" : "--blocking_variables $meta.blocking" + ].join(' ').trim() } ext.prefix = { "${meta.id}_${meta.method}" } } diff --git a/subworkflows/nf-core/abundance_differential_filter/tests/deseq2_limmavoom_propd_basic.config b/subworkflows/nf-core/abundance_differential_filter/tests/deseq2_limmavoom_propd_basic.config index 8bd211bad64..dda5df4bcd4 100644 --- a/subworkflows/nf-core/abundance_differential_filter/tests/deseq2_limmavoom_propd_basic.config +++ b/subworkflows/nf-core/abundance_differential_filter/tests/deseq2_limmavoom_propd_basic.config @@ -1,6 +1,10 @@ process { withName: 'DESEQ2_DIFFERENTIAL' { - ext.args = { "--round_digits 5 --blocking_variables $meta.blocking --vs_method rlog" } + ext.args = { [ + "--round_digits 5", + "--vs_method rlog", + (meta.blocking == null) ? "" : "--blocking_variables $meta.blocking" + ].join(' ').trim() } ext.prefix = { "${meta.id}_${meta.method}" } } diff --git a/subworkflows/nf-core/abundance_differential_filter/tests/main.nf.test b/subworkflows/nf-core/abundance_differential_filter/tests/main.nf.test index 8cbb8cf8767..500a2e800fe 100644 --- a/subworkflows/nf-core/abundance_differential_filter/tests/main.nf.test +++ b/subworkflows/nf-core/abundance_differential_filter/tests/main.nf.test @@ -16,7 +16,7 @@ nextflow_workflow { test("deseq2 - mouse - basic") { config './deseq2_basic.config' - tag "deseq2" + tag "deseq2_basic" when { workflow { @@ -74,7 +74,7 @@ nextflow_workflow { test("limma - basic - microarray") { config './limma_basic_microarray.config' - tag "limma" + tag "limma_basic_microarray" setup { run("UNTAR") { diff --git a/subworkflows/nf-core/abundance_differential_filter/tests/main.nf.test.snap b/subworkflows/nf-core/abundance_differential_filter/tests/main.nf.test.snap index dba530f24eb..6795359ae88 100644 --- a/subworkflows/nf-core/abundance_differential_filter/tests/main.nf.test.snap +++ b/subworkflows/nf-core/abundance_differential_filter/tests/main.nf.test.snap @@ -28,7 +28,7 @@ ] ], [ - + ], [ [ @@ -48,9 +48,9 @@ ], "meta": { "nf-test": "0.9.2", - "nextflow": "24.10.2" + "nextflow": "24.10.3" }, - "timestamp": "2024-12-07T16:33:03.091762783" + "timestamp": "2025-01-14T16:51:17.162826924" }, "deseq2 and limma - mouse - basic": { "content": [ @@ -157,38 +157,26 @@ [ [ { - "id": "treatment_mCherry_hND6__test", - "variable": "treatment", - "reference": "mCherry", - "target": "hND6", - "blocking": "", + "id": "test", "method": "deseq2" }, - "treatment_mCherry_hND6__test_deseq2_norm.normalised_counts.tsv:md5,46ab7200c626649ab6256ed797ef5071" + "test_deseq2_norm.normalised_counts.tsv:md5,46ab7200c626649ab6256ed797ef5071" ], [ { - "id": "treatment_mCherry_hND6__test", - "variable": "treatment", - "reference": "mCherry", - "target": "hND6", - "blocking": "", + "id": "test", "method": "limma" }, - "treatment_mCherry_hND6__test_limma_voom_norm.normalised_counts.tsv:md5,2aa4880ba5ae246a728b25f4316ca2ca" + "test_limma_voom_norm.normalised_counts.tsv:md5,2aa4880ba5ae246a728b25f4316ca2ca" ] ], [ [ { - "id": "treatment_mCherry_hND6__test", - "variable": "treatment", - "reference": "mCherry", - "target": "hND6", - "blocking": "", + "id": "test", "method": "deseq2" }, - "treatment_mCherry_hND6__test_deseq2_norm.rlog.tsv:md5,b1adc1fba6bd0c8b55973608f4b97030" + "test_deseq2_norm.rlog.tsv:md5,b1adc1fba6bd0c8b55973608f4b97030" ] ], [ @@ -246,9 +234,9 @@ ], "meta": { "nf-test": "0.9.2", - "nextflow": "24.10.2" + "nextflow": "24.10.3" }, - "timestamp": "2024-12-07T16:34:54.548033825" + "timestamp": "2025-01-14T16:53:11.245100955" }, "limma - voom": { "content": [ @@ -283,14 +271,10 @@ [ [ { - "id": "treatment_mCherry_hND6__test", - "variable": "treatment", - "reference": "mCherry", - "target": "hND6", - "blocking": "", + "id": "test", "method": "limma" }, - "treatment_mCherry_hND6__test_limma_voom_norm.normalised_counts.tsv:md5,2aa4880ba5ae246a728b25f4316ca2ca" + "test_limma_voom_norm.normalised_counts.tsv:md5,2aa4880ba5ae246a728b25f4316ca2ca" ] ], [ @@ -324,9 +308,9 @@ ], "meta": { "nf-test": "0.9.2", - "nextflow": "24.10.2" + "nextflow": "24.10.3" }, - "timestamp": "2024-12-07T16:33:26.97858478" + "timestamp": "2025-01-14T16:51:32.460857013" }, "deseq2 + limma-voom + propd - mouse - basic": { "content": [ @@ -505,38 +489,26 @@ [ [ { - "id": "treatment_mCherry_hND6__test", - "variable": "treatment", - "reference": "mCherry", - "target": "hND6", - "blocking": "", + "id": "test", "method": "deseq2" }, - "treatment_mCherry_hND6__test_deseq2_norm.normalised_counts.tsv:md5,46ab7200c626649ab6256ed797ef5071" + "test_deseq2_norm.normalised_counts.tsv:md5,46ab7200c626649ab6256ed797ef5071" ], [ { - "id": "treatment_mCherry_hND6__test", - "variable": "treatment", - "reference": "mCherry", - "target": "hND6", - "blocking": "", + "id": "test", "method": "limma" }, - "treatment_mCherry_hND6__test_limma_voom_norm.normalised_counts.tsv:md5,2aa4880ba5ae246a728b25f4316ca2ca" + "test_limma_voom_norm.normalised_counts.tsv:md5,2aa4880ba5ae246a728b25f4316ca2ca" ] ], [ [ { - "id": "treatment_mCherry_hND6__test", - "variable": "treatment", - "reference": "mCherry", - "target": "hND6", - "blocking": "", + "id": "test", "method": "deseq2" }, - "treatment_mCherry_hND6__test_deseq2_norm.rlog.tsv:md5,b1adc1fba6bd0c8b55973608f4b97030" + "test_deseq2_norm.rlog.tsv:md5,b1adc1fba6bd0c8b55973608f4b97030" ] ], [ @@ -596,9 +568,9 @@ ], "meta": { "nf-test": "0.9.2", - "nextflow": "24.10.2" + "nextflow": "24.10.3" }, - "timestamp": "2024-12-13T16:07:08.941008861" + "timestamp": "2025-01-14T16:53:54.80697542" }, "stub": { "content": [ @@ -656,32 +628,24 @@ ] ], "2": [ - + ], "3": [ [ { - "id": "treatment_mCherry_hND6__test", - "variable": "treatment", - "reference": "mCherry", - "target": "hND6", - "blocking": "", + "id": "test", "method": "deseq2" }, - "treatment_mCherry_hND6__test.normalised_counts.tsv:md5,d41d8cd98f00b204e9800998ecf8427e" + "test.normalised_counts.tsv:md5,d41d8cd98f00b204e9800998ecf8427e" ] ], "4": [ [ { - "id": "treatment_mCherry_hND6__test", - "variable": "treatment", - "reference": "mCherry", - "target": "hND6", - "blocking": "", + "id": "test", "method": "deseq2" }, - "treatment_mCherry_hND6__test.rlog.tsv:md5,d41d8cd98f00b204e9800998ecf8427e" + "test.rlog.tsv:md5,d41d8cd98f00b204e9800998ecf8427e" ] ], "5": [ @@ -713,7 +677,7 @@ "versions.yml:md5,05e3901f6d78f8839a7e07f422e9bc03" ], "adjacency": [ - + ], "model": [ [ @@ -742,14 +706,10 @@ "normalised_matrix": [ [ { - "id": "treatment_mCherry_hND6__test", - "variable": "treatment", - "reference": "mCherry", - "target": "hND6", - "blocking": "", + "id": "test", "method": "deseq2" }, - "treatment_mCherry_hND6__test.normalised_counts.tsv:md5,d41d8cd98f00b204e9800998ecf8427e" + "test.normalised_counts.tsv:md5,d41d8cd98f00b204e9800998ecf8427e" ] ], "results_genewise": [ @@ -807,14 +767,10 @@ "variance_stabilised_matrix": [ [ { - "id": "treatment_mCherry_hND6__test", - "variable": "treatment", - "reference": "mCherry", - "target": "hND6", - "blocking": "", + "id": "test", "method": "deseq2" }, - "treatment_mCherry_hND6__test.rlog.tsv:md5,d41d8cd98f00b204e9800998ecf8427e" + "test.rlog.tsv:md5,d41d8cd98f00b204e9800998ecf8427e" ] ], "versions": [ @@ -825,9 +781,9 @@ ], "meta": { "nf-test": "0.9.2", - "nextflow": "24.10.2" + "nextflow": "24.10.3" }, - "timestamp": "2024-12-13T15:08:45.989521056" + "timestamp": "2025-01-14T16:54:12.823125892" }, "deseq2 - mouse - basic": { "content": [ @@ -886,27 +842,19 @@ [ [ { - "id": "treatment_mCherry_hND6__test", - "variable": "treatment", - "reference": "mCherry", - "target": "hND6", - "blocking": "", + "id": "test", "method": "deseq2" }, - "treatment_mCherry_hND6__test_deseq2_voom_norm.normalised_counts.tsv:md5,46ab7200c626649ab6256ed797ef5071" + "test_deseq2_norm.normalised_counts.tsv:md5,46ab7200c626649ab6256ed797ef5071" ] ], [ [ { - "id": "treatment_mCherry_hND6__test", - "variable": "treatment", - "reference": "mCherry", - "target": "hND6", - "blocking": "", + "id": "test", "method": "deseq2" }, - "treatment_mCherry_hND6__test_deseq2_voom_norm.rlog.tsv:md5,b1adc1fba6bd0c8b55973608f4b97030" + "test_deseq2_norm.rlog.tsv:md5,b1adc1fba6bd0c8b55973608f4b97030" ] ], [ @@ -940,9 +888,9 @@ ], "meta": { "nf-test": "0.9.2", - "nextflow": "24.10.2" + "nextflow": "24.10.3" }, - "timestamp": "2024-12-07T16:32:17.301539736" + "timestamp": "2025-01-14T16:50:35.085607799" }, "deseq2 - with transcript lengths": { "content": [ @@ -1001,27 +949,19 @@ [ [ { - "id": "treatment_mCherry_hND6__test", - "variable": "treatment", - "reference": "mCherry", - "target": "hND6", - "blocking": "", + "id": "test", "method": "deseq2" }, - "treatment_mCherry_hND6__test_deseq2_voom_norm.normalised_counts.tsv:md5,7050f44c460cc13e3f101d048d503527" + "test_deseq2_norm.normalised_counts.tsv:md5,7050f44c460cc13e3f101d048d503527" ] ], [ [ { - "id": "treatment_mCherry_hND6__test", - "variable": "treatment", - "reference": "mCherry", - "target": "hND6", - "blocking": "", + "id": "test", "method": "deseq2" }, - "treatment_mCherry_hND6__test_deseq2_voom_norm.rlog.tsv:md5,22a4b117246b2317e0f4daf7919703f2" + "test_deseq2_norm.rlog.tsv:md5,22a4b117246b2317e0f4daf7919703f2" ] ], [ @@ -1055,9 +995,9 @@ ], "meta": { "nf-test": "0.9.2", - "nextflow": "24.10.2" + "nextflow": "24.10.3" }, - "timestamp": "2024-12-07T16:34:05.584119298" + "timestamp": "2025-01-14T16:52:07.822745077" }, "propd - mouse - basic": { "content": [ @@ -1144,8 +1084,8 @@ ], "meta": { "nf-test": "0.9.2", - "nextflow": "24.10.2" + "nextflow": "24.10.3" }, - "timestamp": "2024-12-13T15:02:45.903371649" + "timestamp": "2025-01-14T16:52:25.336720308" } -} +} \ No newline at end of file