Skip to content

Commit 55f1d16

Browse files
committed
simplify differential_functional_enrichment outputs
1 parent 2957563 commit 55f1d16

2 files changed

Lines changed: 105 additions & 160 deletions

File tree

subworkflows/nf-core/differential_functional_enrichment/main.nf

Lines changed: 84 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ workflow DIFFERENTIAL_FUNCTIONAL_ENRICHMENT {
3333

3434
main:
3535

36-
ch_versions = channel.empty()
36+
ch_versions = channel.empty()
37+
ch_results = channel.empty()
38+
ch_artifacts = channel.empty()
3739

3840
// Add method information into meta map of ch_input
3941
// This information is used later to determine which method to run for each input
@@ -82,21 +84,40 @@ workflow DIFFERENTIAL_FUNCTIONAL_ENRICHMENT {
8284
.combine(ch_contrasts_transposed, by:0)
8385
.multiMap(criteria)
8486

85-
8687
// ----------------------------------------------------
8788
// Perform enrichment analysis with gprofiler2
8889
// ----------------------------------------------------
8990

91+
// run gprofiler2
9092
GPROFILER2_GOST(
9193
ch_input_for_other.input.filter{ index -> index[0].functional_method == 'gprofiler2' },
9294
ch_input_for_other.genesets.filter{ index -> index[0].functional_method == 'gprofiler2'},
9395
ch_input_for_other.background.filter{ index -> index[0].functional_method == 'gprofiler2'}
9496
)
9597

98+
// collect main results
99+
ch_results = ch_results
100+
.mix(
101+
GPROFILER2_GOST.out.plot_html
102+
.join(GPROFILER2_GOST.out.all_enrich, remainder: true)
103+
.join(GPROFILER2_GOST.out.sub_enrich, remainder: true)
104+
)
105+
106+
// other results
107+
ch_artifacts = ch_artifacts
108+
.mix(
109+
GPROFILER2_GOST.out.plot_png
110+
.mix(GPROFILER2_GOST.out.sub_plot)
111+
.mix(GPROFILER2_GOST.out.rds)
112+
.mix(GPROFILER2_GOST.out.filtered_gmt)
113+
.mix(GPROFILER2_GOST.out.session_info)
114+
)
115+
96116
// ----------------------------------------------------
97117
// Perform enrichment analysis with GSEA
98118
// ----------------------------------------------------
99119

120+
// prepare GSEA input files (gct, cls, chip)
100121
CUSTOM_TABULARTOGSEAGCT(ch_input_for_gsea.input)
101122
CUSTOM_TABULARTOGSEACLS(ch_input_for_gsea.contrasts_and_samples)
102123
CUSTOM_TABULARTOGSEACHIP(
@@ -117,32 +138,87 @@ workflow DIFFERENTIAL_FUNCTIONAL_ENRICHMENT {
117138
[meta, chip]
118139
}
119140

141+
// run gsea
120142
GSEA_GSEA(
121143
ch_in_gsea.input,
122144
ch_in_gsea.ref_target,
123145
ch_in_gsea.chip
124146
)
125147

148+
// collect main results
149+
ch_results = ch_results
150+
.mix(
151+
GSEA_GSEA.out.report_tsvs_ref
152+
.join(GSEA_GSEA.out.report_tsvs_target)
153+
)
154+
155+
// other results
156+
ch_artifacts = ch_artifacts
157+
.mix(
158+
GSEA_GSEA.out.rpt
159+
.mix(GSEA_GSEA.out.index_html)
160+
.mix(GSEA_GSEA.out.heat_map_corr_plot)
161+
.mix(GSEA_GSEA.out.report_tsvs_ref)
162+
.mix(GSEA_GSEA.out.report_htmls_ref)
163+
.mix(GSEA_GSEA.out.report_tsvs_target)
164+
.mix(GSEA_GSEA.out.report_htmls_target)
165+
.mix(GSEA_GSEA.out.ranked_gene_list)
166+
.mix(GSEA_GSEA.out.gene_set_sizes)
167+
.mix(GSEA_GSEA.out.histogram)
168+
.mix(GSEA_GSEA.out.heatmap)
169+
.mix(GSEA_GSEA.out.pvalues_vs_nes_plot)
170+
.mix(GSEA_GSEA.out.ranked_list_corr)
171+
.mix(GSEA_GSEA.out.butterfly_plot)
172+
.mix(GSEA_GSEA.out.gene_set_tsv)
173+
.mix(GSEA_GSEA.out.gene_set_html)
174+
.mix(GSEA_GSEA.out.gene_set_heatmap)
175+
.mix(GSEA_GSEA.out.snapshot)
176+
.mix(GSEA_GSEA.out.gene_set_enplot)
177+
.mix(GSEA_GSEA.out.gene_set_dist)
178+
.mix(GSEA_GSEA.out.archive)
179+
)
180+
126181
// ----------------------------------------------------
127182
// Perform enrichment analysis with DECOUPLER
128183
// ----------------------------------------------------
129184

185+
// run decoupler
130186
DECOUPLER_DECOUPLER(
131187
ch_input_for_other.input.filter{ index -> index[0].functional_method == 'decoupler' },
132188
ch_input_for_other.genesets.filter{ index -> index[0].functional_method == 'decoupler'},
133189
ch_input_for_other.features.filter{ index -> index[0].functional_method == 'decoupler'}
134190
.map{ meta, features_sheet, _features_id, _features_symbol -> [meta, features_sheet] }
135191
)
136192

193+
// collect main results
194+
ch_results = ch_results
195+
.mix(
196+
DECOUPLER_DECOUPLER.out.dc_estimate
197+
.join(DECOUPLER_DECOUPLER.out.dc_pvals)
198+
)
199+
200+
// other results
201+
ch_artifacts = ch_artifacts
202+
.mix(DECOUPLER_DECOUPLER.out.png)
203+
137204
// ----------------------------------------------------
138205
// Perform enrichment analysis with GREA
139206
// ----------------------------------------------------
140207

208+
// run gene ratio enrichment analysis
141209
PROPR_GREA(
142210
ch_input_for_other.input.filter{ index -> index[0].functional_method == 'grea' },
143211
ch_input_for_other.genesets.filter{ index -> index[0].functional_method == 'grea' }
144212
)
145213

214+
// collect main results
215+
ch_results = ch_results
216+
.mix(PROPR_GREA.out.results)
217+
218+
// ----------------------------------------------------
219+
// Outputs
220+
// ----------------------------------------------------
221+
146222
// collect versions info
147223
ch_versions = ch_versions
148224
.mix(GPROFILER2_GOST.out.versions)
@@ -156,48 +232,12 @@ workflow DIFFERENTIAL_FUNCTIONAL_ENRICHMENT {
156232
// here we emit the outputs that will be useful afterwards in the
157233
// nf-core/differentialabundance pipeline
158234

159-
// gprofiler2-specific outputs
160-
gprofiler2_plot_html = GPROFILER2_GOST.out.plot_html
161-
gprofiler2_all_enrich = GPROFILER2_GOST.out.all_enrich
162-
gprofiler2_sub_enrich = GPROFILER2_GOST.out.sub_enrich
163-
gprofiler2_artifacts = GPROFILER2_GOST.out.plot_png
164-
.mix(GPROFILER2_GOST.out.sub_plot)
165-
.mix(GPROFILER2_GOST.out.rds)
166-
.mix(GPROFILER2_GOST.out.filtered_gmt)
167-
.mix(GPROFILER2_GOST.out.session_info)
168-
169-
// gsea-specific outputs
170-
gsea_report = GSEA_GSEA.out.report_tsvs_ref.join(GSEA_GSEA.out.report_tsvs_target)
171-
gsea_artifacts = GSEA_GSEA.out.rpt
172-
.mix(GSEA_GSEA.out.index_html)
173-
.mix(GSEA_GSEA.out.heat_map_corr_plot)
174-
.mix(GSEA_GSEA.out.report_tsvs_ref)
175-
.mix(GSEA_GSEA.out.report_htmls_ref)
176-
.mix(GSEA_GSEA.out.report_tsvs_target)
177-
.mix(GSEA_GSEA.out.report_htmls_target)
178-
.mix(GSEA_GSEA.out.ranked_gene_list)
179-
.mix(GSEA_GSEA.out.gene_set_sizes)
180-
.mix(GSEA_GSEA.out.histogram)
181-
.mix(GSEA_GSEA.out.heatmap)
182-
.mix(GSEA_GSEA.out.pvalues_vs_nes_plot)
183-
.mix(GSEA_GSEA.out.ranked_list_corr)
184-
.mix(GSEA_GSEA.out.butterfly_plot)
185-
.mix(GSEA_GSEA.out.gene_set_tsv)
186-
.mix(GSEA_GSEA.out.gene_set_html)
187-
.mix(GSEA_GSEA.out.gene_set_heatmap)
188-
.mix(GSEA_GSEA.out.snapshot)
189-
.mix(GSEA_GSEA.out.gene_set_enplot)
190-
.mix(GSEA_GSEA.out.gene_set_dist)
191-
.mix(GSEA_GSEA.out.archive)
192-
193-
// decoupler-specific outputs
194-
decoupler_dc_estimate = DECOUPLER_DECOUPLER.out.dc_estimate
195-
decoupler_dc_pvals = DECOUPLER_DECOUPLER.out.dc_pvals
196-
decoupler_png = DECOUPLER_DECOUPLER.out.png
197-
198-
// grea-specific outputs
199-
grea_results = PROPR_GREA.out.results
235+
// main results
236+
results = ch_results
237+
238+
// artifacts - these are all the other files produced by the modules that are not the main results, but that we still want to keep and make available
239+
artifacts = ch_artifacts
200240

201241
// tool versions
202-
versions = ch_versions
242+
versions = ch_versions
203243
}

subworkflows/nf-core/differential_functional_enrichment/meta.yml

Lines changed: 21 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -92,136 +92,41 @@ input:
9292

9393
output:
9494
- versions:
95-
type: file
9695
description: |
97-
File containing software versions
98-
Structure: [ path(versions.yml) ]
99-
pattern: "versions.yml"
100-
- gprofiler2_all_enrich:
101-
description: Channel containing the main enrichment table output from gprofiler2
96+
File containing software versions.
10297
structure:
103-
- meta:
104-
type: map
105-
description: Metadata map
106-
- all_enrich:
107-
type: file
108-
description: |
109-
Table listing all enriched pathways that were found by gprofiler2.
110-
It can be empty, if none is found.
111-
pattern: "*.gprofiler2.all_enriched_pathways.tsv"
112-
- gprofiler2_sub_enrich:
113-
description: Channel containing the secondary enrichment table output from gprofiler2.
114-
structure:
115-
- meta:
116-
type: map
117-
description: Metadata map
118-
- sub_enrich:
119-
type: file
120-
description: |
121-
Table listing enriched pathways that were found from one particular source.
122-
Note that it will only be created if any were found.
123-
pattern: "*.gprofiler2.*.sub_enriched_pathways.tsv"
124-
- gprofiler2_plot_html:
125-
description: Channel containing the html report generated from gprofiler2.
126-
structure:
127-
- meta:
128-
type: map
129-
description: Metadata map
130-
- plot_html:
98+
- versions.yml:
13199
type: file
132-
description: |
133-
HTML file; interactive Manhattan plot of all enriched pathways.
134-
Note that this file will only be generated if enriched pathways were found.
135-
pattern: "*.gprofiler2.gostplot.html"
136-
- gprofiler2_artifacts:
137-
description: Channel containing additional gprofiler2 artifacts.
138-
structure:
139-
- meta:
140-
type: map
141-
description: Metadata map
142-
- artifact:
143-
type: file
144-
description: |
145-
Additional outputs from gprofiler2, including gost results (RDS),
146-
filtered GMT files, R session logs, and PNG plot files.
147-
pattern: "*.{rds,gmt,log,png}"
148-
- gsea_report:
149-
description: Channel containing all the output from GSEA needed for further reporting.
100+
description: File containing software versions
101+
pattern: "versions.yml"
102+
- results:
103+
description: |
104+
Channel containing the main results from all functional enrichment methods.
105+
For gprofiler2, this includes the plot HTML, all enriched pathways table, and sub enriched pathways table.
106+
For GSEA, this includes the report TSVs for reference and target groups.
107+
For decoupler, this includes the estimate and p-values files.
108+
For GREA, this includes the main results TSV.
150109
structure:
151110
- meta:
152111
type: map
153112
description: Metadata map
154-
- reports_ref:
155-
type: file
156-
description: Main TSV results report file for the reference group.
157-
pattern: "*gsea_report_for_${reference}.tsv"
158-
- reports_target:
113+
- results:
159114
type: file
160-
description: Main TSV results report file for the target group.
161-
pattern: "*gsea_report_for_${target}.tsv"
162-
- gsea_artifacts:
163-
description: Channel containing additional GSEA output artifacts.
115+
description: Main result files from the functional enrichment method.
116+
- artifacts:
117+
description: |
118+
Channel containing additional output files from all functional enrichment methods
119+
that are not the main results but are still useful to keep.
120+
For gprofiler2, this includes PNG plots, RDS files, filtered GMT, and session info.
121+
For GSEA, this includes reports, plots, archives, and supporting HTML/TSV outputs.
122+
For decoupler, this includes PNG plot files.
164123
structure:
165124
- meta:
166125
type: map
167126
description: Metadata map
168127
- artifact:
169128
type: file
170-
description: |
171-
Additional files generated by GSEA, including reports, plots, archives,
172-
and supporting HTML/TSV outputs.
173-
pattern: "*.{rpt,html,tsv,png,zip}"
174-
- decoupler_dc_estimate:
175-
description: Channel containing decoupler estimate results.
176-
structure:
177-
- meta:
178-
type: map
179-
description: |
180-
Groovy Map containing sample information
181-
e.g. [ id:'test', single_end ]
182-
- estimate_files:
183-
type: file
184-
description: |
185-
Files containing the estimation results of the enrichment(s)
186-
pattern: "*estimate_decoupler.tsv"
187-
- decoupler_dc_pvals:
188-
description: Channel containing decoupler pvals results.
189-
structure:
190-
- meta:
191-
type: map
192-
description: |
193-
Groovy Map containing sample information
194-
e.g. [ id:'test', single_end ]
195-
- pvals_files:
196-
type: file
197-
description: |
198-
Files containing the p-values associated to the estimation
199-
results of the enrichment(s)
200-
pattern: "*pvals_decoupler.tsv"
201-
- decoupler_png:
202-
description: Channel containing decoupler png results.
203-
structure:
204-
- meta:
205-
type: map
206-
description: |
207-
Groovy Map containing sample information
208-
e.g. [ id:'test', single_end ]
209-
- plot_files:
210-
type: file
211-
description: |
212-
Files containing the plots associated to the estimation
213-
results of the enrichment(s)
214-
pattern: "*estimate_decoupler_plot.png"
215-
- grea_results:
216-
description: Channel containing the output from GREA.
217-
structure:
218-
- meta:
219-
type: map
220-
description: Metadata map
221-
- results:
222-
type: file
223-
description: Main TSV results file.
224-
pattern: "*.grea.tsv"
129+
description: Additional output files from the functional enrichment method.
225130
authors:
226131
- "@suzannejin"
227132
- "@bjlang"

0 commit comments

Comments
 (0)