Skip to content

Commit

Permalink
update NORM meta in abundance_differential_filter (#7302)
Browse files Browse the repository at this point in the history
* 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 <mashehu@users.noreply.github.com>
  • Loading branch information
suzannejin and mashehu authored Jan 16, 2025
1 parent 83ba95c commit 2b977a4
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 130 deletions.
27 changes: 14 additions & 13 deletions subworkflows/nf-core/abundance_differential_filter/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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' }
)

// ----------------------------------------------------
Expand All @@ -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()
Expand All @@ -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' }
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ output:
authors:
- "@pinin4fjords"
- "@bjlang"
- "@araiz2001"
- "@caraiz2001"
- "@suzannejin"
maintainers:
- "@pinin4fjords"
Expand Down
Original file line number Diff line number Diff line change
@@ -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" }
}
}
Original file line number Diff line number Diff line change
@@ -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}" }
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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}" }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ nextflow_workflow {

test("deseq2 - mouse - basic") {
config './deseq2_basic.config'
tag "deseq2"
tag "deseq2_basic"

when {
workflow {
Expand Down Expand Up @@ -74,7 +74,7 @@ nextflow_workflow {

test("limma - basic - microarray") {
config './limma_basic_microarray.config'
tag "limma"
tag "limma_basic_microarray"

setup {
run("UNTAR") {
Expand Down
Loading

0 comments on commit 2b977a4

Please sign in to comment.