Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dev-ratio] simplified toolsheet structure, and modified the subworkflows accordingly #293

Merged
merged 9 commits into from
Oct 7, 2024
12 changes: 6 additions & 6 deletions assets/tools_samplesheet.csv
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pathway_name,diff_method,args_diff,enr_diff_method,args_enr_diff,cor_method,args_cor,enr_cor_method,args_enr_cor,sel_method,args_sel
diff_prop,propd,--adjacency true --cutoff_min 0.05 --cutoff_max 0.95 --cutoff_interval 0.05 --permutation 100 --fixseed true,,,,,,,,
diff_prop_noperm,propd,--cutoff_min 0.05 --cutoff_max 0.95 --cutoff_interval 0.05 --permutation 0 --fixseed true,,,,,,,,
filtered_pcor,propd,--adjacency true --cutoff_min 0.05 --cutoff_max 0.95 --cutoff_interval 0.05 --permutation 100 --fixseed true,,,propr,--permutation 10 --adjacency true --cutoff_min 0.005 --cutoff_max 0.5 --cutoff_interval 0.01 --metric pcor.bshrink,,,filtervar,
prop,,,,,propr,--cutoff_min 0.05 --cutoff_max 0.95 --cutoff_interval 0.05 --fixseed true --metric rho --permutation 100 --adjacency true,,,,
diff_grea,propd,--adjacency true --cutoff_min 0.05 --cutoff_max 0.95 --cutoff_interval 0.05 --permutation 10 --fixseed true,grea,--permutation 10,,,,,,
pathway_name,diff_method,args_diff,cor_method,args_cor,enr_method,args_enr
propd,propd,--adjacency true --cutoff_min 0.05 --cutoff_max 0.95 --cutoff_interval 0.05 --permutation 10,,,,
propd_noperm,propd,--cutoff_min 0.05 --cutoff_max 0.95 --cutoff_interval 0.05 --permutation 0,,,,
pcorbshrink,,,propr,--permutation 10 --adjacency true --cutoff_min 0.005 --cutoff_max 0.5 --cutoff_interval 0.01 --metric pcor.bshrink,,
propr,,,propr,--cutoff_min 0.05 --cutoff_max 0.95 --cutoff_interval 0.05 --metric rho --permutation 10 --adjacency true,,
propd_grea,propd,--adjacency true --cutoff_min 0.05 --cutoff_max 0.95 --cutoff_interval 0.05 --permutation 10,,,grea,--permutation 10
22 changes: 10 additions & 12 deletions subworkflows/local/correlation/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@ workflow CORRELATION {
take:
ch_counts
ch_tools
ch_counts_filtered

main:

// initialize empty results channels
ch_results = Channel.empty()
ch_adjacency = Channel.empty()

// branch tools to select the correct correlation analysis method
ch_counts
.combine(ch_tools)
.map {
Expand All @@ -21,22 +26,15 @@ workflow CORRELATION {
}
.set { ch_counts_cor }

// Create a branch of the channel to retrieve the normal counts when there is no variable selection.
ch_counts_cor.propr
.branch{
no_sel: it[0]["sel_method"] == null
sel: it[0]["sel_method"] != null
}
.set { ch_counts_selection }
// ----------------------------------------------------
// Perform correlation analysis with propr
// ----------------------------------------------------

ch_propr = ch_counts_filtered.mix(ch_counts_selection.no_sel)

PROPR(ch_propr)
PROPR(ch_counts_cor.propr)
ch_matrix = PROPR.out.matrix
ch_adjacency = PROPR.out.adj

emit:
matrix = ch_matrix
adjacency = ch_adjacency

}
21 changes: 15 additions & 6 deletions subworkflows/local/differential/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
include { PROPR_PROPD as PROPD } from "../../../modules/nf-core/propr/propd/main.nf"
include { DESEQ2_DIFFERENTIAL } from '../../../modules/nf-core/deseq2/differential/main'


workflow DIFFERENTIAL {
take:
ch_contrasts // [meta, contrast_variable, reference, target]
Expand All @@ -13,22 +12,30 @@ workflow DIFFERENTIAL {
ch_tools

main:

// initialize empty results channels
ch_results = Channel.empty()
ch_adjacency = Channel.empty()

// branch tools to select the correct differential analysis method
ch_tools
.branch {
propd: it[0]["diff_method"] == "propd"
deseq2: it[0]["diff_method"] == "deseq2"
}
.set { ch_tools_single }

// ----------------------------------------------------
// Perform differential analysis with propd
// ----------------------------------------------------

// Perform differential analysis with PROPD
ch_counts
.combine(ch_tools_single.propd)
.combine(ch_contrasts)
.map {
meta_counts, counts, tools, meta_contrast, contrast_variable, reference, target ->
def meta = meta_counts.clone() + tools.clone()
meta.args_diff = (meta.args_diff ?: "") + " --group_col $contrast_variable"
meta.args_diff = (meta.args_diff ?: "") + " --group_col $contrast_variable" // TODO parse the toolsheet with the ext.arg from modules.config at the beginning of the experimental workflow
[ meta, counts ]
}
.unique()
Expand All @@ -38,10 +45,13 @@ workflow DIFFERENTIAL {
ch_counts_propd,
ch_samplesheet.first()
)
ch_results = PROPD.out.results
ch_adjacency = PROPD.out.adj
ch_results = ch_results.mix(PROPD.out.results)
ch_adjacency = ch_adjacency.mix(PROPD.out.adj)

// ----------------------------------------------------
// Perform differential analysis with DESeq2
// ----------------------------------------------------

// ToDo: In order to use deseq2 the downstream processes need to be updated to process the output correctly
// if (params.transcript_length_matrix) { ch_transcript_lengths = Channel.of([ exp_meta, file(params.transcript_length_matrix, checkIfExists: true)]).first() } else { ch_transcript_lengths = [[],[]] }
// if (params.control_features) { ch_control_features = Channel.of([ exp_meta, file(params.control_features, checkIfExists: true)]).first() } else { ch_control_features = [[],[]] }
Expand All @@ -64,5 +74,4 @@ workflow DIFFERENTIAL {
emit:
results = ch_results
adjacency = ch_adjacency

}
45 changes: 27 additions & 18 deletions subworkflows/local/experimental/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@
//
include { CORRELATION } from '../correlation/main.nf'
include { DIFFERENTIAL } from '../differential/main.nf'
include { VARIABLE_SELECTION } from '../variable_selection/main.nf'
include { ENRICHMENT } from '../enrichment/main.nf'


workflow EXPERIMENTAL {
take:
ch_contrasts
ch_samplesheet
ch_counts
ch_tools


main:
// Perform differential analysis

// ----------------------------------------------------
// DIFFERENTIAL ANALYSIS BLOCK
// ----------------------------------------------------

DIFFERENTIAL(
ch_contrasts,
ch_samplesheet,
Expand All @@ -26,33 +27,41 @@ workflow EXPERIMENTAL {
ch_diff_results = DIFFERENTIAL.out.results
ch_diff_adjacency = DIFFERENTIAL.out.adjacency

// Perform variable selection
ch_counts_filtered = VARIABLE_SELECTION(ch_diff_adjacency, ch_counts)
// ----------------------------------------------------
// CORRELATION ANALYSIS BLOCK
// ----------------------------------------------------

// Perform correlation analysis
CORRELATION(
ch_counts,
ch_tools,
ch_counts_filtered
ch_tools
)
ch_matrix = CORRELATION.out.matrix
ch_cor_adjacency = CORRELATION.out.adjacency
ch_corr_matrix = CORRELATION.out.matrix
ch_corr_adjacency = CORRELATION.out.adjacency

// ----------------------------------------------------
// FUNCTIONAL ENRICHMENT BLOCK
// ----------------------------------------------------

// Perform enrichment analysis
ENRICHMENT(
ch_diff_adjacency,
ch_cor_adjacency,
ch_corr_adjacency,
ch_counts
)
ch_enriched_cor = ENRICHMENT.out.enriched_cor
ch_enriched_diff = ENRICHMENT.out.enriched_diff

// ----------------------------------------------------
// VISUALIZATION BLOCK
// ----------------------------------------------------

// TODO: add visualization stuff here

// do we need to emit anything?
emit:
diff_res = ch_diff_results
diff_adj = ch_diff_adjacency
var_count = ch_counts_filtered
corr_matrix = ch_matrix
corr_adj = ch_cor_adjacency
diff_res = ch_diff_results
diff_adj = ch_diff_adjacency
corr_matrix = ch_corr_matrix
corr_adj = ch_corr_adjacency
enriched_cor = ch_enriched_cor
enriched_cor = ch_enriched_diff
}