@@ -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}
0 commit comments