-
Notifications
You must be signed in to change notification settings - Fork 8
/
run_aftermzmine.nf
592 lines (448 loc) · 23.9 KB
/
run_aftermzmine.nf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
#!/usr/bin/env nextflow
/**
RUMP: A Reproducible Untargeted Metabolomics Data Processing Pipeline
Description : A Nextflow-based reproducible pipeline for untargeted metabolomics data analysis, this file includes part of the pipeline and is used to analyze peak table generated by MZmine-2.53
Copyright : (C) LemasLab
Author : Xinsong Du
License : GNU GPL-v3.0 License
This script is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This script is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this script. If not, see <http://www.gnu.org/licenses/>.
For any bugs or problems found, please contact us at
- https://github.com/lemaslab/RUMP
*/
// Those variable names which are all uppercase are channel names
version='0.0.0'
timestamp='20200226'
MZMINE = Channel.fromPath(params.mzmine_dir, type: 'dir') // The location of folder of MzMine
MZMINE.into{POS_MZMINE; NEG_MZMINE} // Duplicate the MZMINE chennel into two channels, one of which deals with positive sample while the other deals with negative sample.
// BATCHFILE_GENERATOR = Channel.fromPath(params.batchfile_generator) // This channel stores Python code (~/src/batchfile_generator.py) for generating MzMine batchfile, which enables us to run MzMine in batch mode.
POS_DATA_DIR = Channel.fromPath(params.input_dir_pos, type: 'dir') // Location of folder storing positive data
NEG_DATA_DIR = Channel.fromPath(params.input_dir_neg, type: 'dir') // Location of folder storing negative data
PYTHON_PCA = Channel.fromPath(params.python_pca) // Chennel of Python code for principle component analysis
PYTHON_PCA.into{PYTHON_PCA_NOBG; PYTHON_PCA_WITHBG} // Duplicate the above chennel to two channels, one the them processes result without background substraction, the other one processes processes result with background subtraction.
PYTHON_HCLUSTERING = Channel.fromPath(params.python_hclustering) // Chennel of Python code for hierarchical clustering
PYTHON_HCLUSTERING.into{PYTHON_HCLUSTERING_NOBG; PYTHON_HCLUSTERING_WITHBG}
PYTHON_VD = Channel.fromPath(params.python_vd) // Chennel of Python code for venn diagram
PYTHON_VD.into{PYTHON_VD_NOBG; PYTHON_VD_WITHBG}
PYTHON_BARPLOT = Channel.fromPath(params.python_barplot) // Chennel of Python code for venn diagram
PYTHON_BARPLOT.into{PYTHON_BARPLOT_NOBG; PYTHON_BARPLOT_WITHBG}
PYTHON_ADDSTATS = Channel.fromPath(params.python_addstats)
PYTHON_DATA_INFO = Channel.fromPath(params.data_info) // Python code for generating MultiQC file regarding data information including file name and file size.
PYTHON_MODIS_INFO = Channel.fromPath(params.modis_info) // Python code for generating MultiQC file regarding MODIS test information including MODIS score, if required metadata are provided, etc.
PYTHON_PEAK_NUMBER_COMPARISON = Channel.fromPath(params.peak_number_comparison_path) // Python code for generating MultiQC file ragarding peak numbers for different background subtraction threshold.
PYTHON_MUMMICHOG_INPUT_PREPARE = Channel.fromPath(params.python_mummichog_input_prepare)
PYTHON_MUMMICHOG_INPUT_PREPARE.into{PYTHON_MUMMICHOG_INPUT_PREPARE_NOBG; PYTHON_MUMMICHOG_INPUT_PREPARE_WITHBG}
// Following is Python code for background subtraction.
PYTHON_BS = Channel.fromPath(params.python_bs)
POS_MZMINE_RESULT = Channel.fromPath(params.pos_mzmine_peak_output)
// POS_NOBG.into{POS_NOBG_FOR_AS; POS_NOBG_FOR_BS; POS_NOBG_FOR_PCA; POS_NOBG_FOR_HCLUSTERING; POS_NOBG_FOR_VD; POS_NOBG_FOR_BARPLOT}
NEG_MZMINE_RESULT = Channel.fromPath(params.neg_mzmine_peak_output)
// NEG_NOBG.into{NEG_NOBG_FOR_AS; NEG_NOBG_FOR_BS; NEG_NOBG_FOR_PCA; NEG_NOBG_FOR_HCLUSTERING; NEG_NOBG_FOR_VD; NEG_NOBG_FOR_BARPLOT}
// Library
POS_LIBRARY = Channel.fromPath(params.pos_library)
NEG_LIBRARY = Channel.fromPath(params.neg_library)
POS_LIBRARY.into{POS_LIBRARY_MZMINE; POS_LIBRARY_STAT}
NEG_LIBRARY.into{NEG_LIBRARY_MZMINE; NEG_LIBRARY_STAT}
// Design files for positive data and negative data.
POS_DESIGN = Channel.fromPath(params.POS_design_path)
POS_DESIGN.into{POS_DESIGN_FOR_AS; POS_DESIGN_FOR_BS; POS_DESIGN_FOR_PCA_NOBG; POS_DESIGN_FOR_PCA_WITHBG; POS_DESIGN_FOR_HCLUSTERING_NOBG; POS_DESIGN_FOR_HCLUSTERING_WITHBG; POS_DESIGN_FOR_VD_NOBG; POS_DESIGN_FOR_VD_WITHBG; POS_DESIGN_FOR_BARPLOT_NOBG; POS_DESIGN_FOR_BARPLOT_WITHBG}
NEG_DESIGN = Channel.fromPath(params.NEG_design_path)
NEG_DESIGN.into{NEG_DESIGN_FOR_AS; NEG_DESIGN_FOR_BS; NEG_DESIGN_FOR_PCA_NOBG; NEG_DESIGN_FOR_PCA_WITHBG; NEG_DESIGN_FOR_HCLUSTERING_NOBG; NEG_DESIGN_FOR_HCLUSTERING_WITHBG; NEG_DESIGN_FOR_VD_NOBG; NEG_DESIGN_FOR_VD_WITHBG; NEG_DESIGN_FOR_BARPLOT_NOBG; NEG_DESIGN_FOR_BARPLOT_WITHBG}
// MODIS Excel file
MODIS_INFO_EXCEL = Channel.fromPath(params.modis_info_excel)
// Pre-build MultiQC report information
// EXPERIMENTS_INFO = Channel.fromPath(params.experiments_info)
// MQC_CONFIG = Channel.fromPath(params.mqc_config)
// R code for unknown search
R_UNKNOWN_SEARCH = Channel.fromPath(params.r_unknown_search)
R_UNKNOWN_SEARCH.into{R_UNKNOWN_SEARCH_NOBG; R_UNKNOWN_SEARCH_WITHBG}
// Result files used by MultiQC to generate report.
// MQC_DIR = Channel.fromPath(params.mqc_dir, type: 'dir')
/**
Prints version when asked for
*/
if (params.version) {
System.out.println("")
System.out.println("RUMP: A Reproducible Untargeted Metabolomics Data Processing Pipeline - Version: $version ($timestamp)")
exit 1
}
/**
Prints help when asked for
*/
if (params.help) {
System.out.println("")
System.out.println("RUMP: A Reproducible Untargeted Metabolomics Data Processing Pipeline - Version: $version ($timestamp)")
System.out.println("This pipeline is distributed in the hope that it will be useful")
System.out.println("but WITHOUT ANY WARRANTY. See the GNU GPL v3.0 for more details.")
System.out.println("")
System.out.println("Please report comments and bugs to [email protected]")
System.out.println("or at https://github.com/lemaslab/RUMP/issues.")
System.out.println("Check https://github.com/lemaslab/RUMP for updates, and refer to")
System.out.println("https://github.com/lemaslab/RUMP/wiki")
System.out.println("")
System.out.println("Usage: ")
System.out.println(" nextflow run_all.nf [options] -with-docker xinsongdu/lemaslab_rump:v0.0.0")
System.out.println("")
System.out.println("Arguments (it is mandatory to change `input_file` and `mzmine_dir` before running:")
System.out.println("----------------------------- common parameters ----------------------------------")
System.out.println(" --input_dir_pos folder location for positive data, default is 'data/POS'")
System.out.println(" --input_dir_neg folder location for positive data, default is 'data/NEG'")
System.out.println(" --POS_design_path location for positive design file, default is 'data/pos_design.csv'")
System.out.println(" --NEG_design_path location for negative design file, default is 'data/neg_design.csv'")
System.out.println(" --pos_mzmine_peak_output location for positive peak table generated by MZmine-2.53, default is 'pos_data.csv'")
System.out.println(" --neg_mzmine_peak_output location for negative peak table generated by MZmine-2.53, default is 'neg_data.csv'")
System.out.println(" --cutoff cutoff p-value for mummichog pathway analysis, default is 0.05")
System.out.println(" --unknown_search whether do unknown search for unidentified metabolites or not, default is '0', please set it to '0' when you want to disable it")
System.out.println(" --version whether to show version information or not, default is null")
System.out.println(" --help whether to show help information or not, default is null")
System.out.println("Please refer to nextflow.config for more options.")
System.out.println("")
System.out.println("Container:")
System.out.println(" Docker image to use with -with-docker|-with-singularity options is")
System.out.println(" 'docker://xinsongdu/lemaslab_rump:v0.0.0'")
System.out.println("")
System.out.println("RUMP supports .mzXML format files.")
System.out.println("")
exit 1
}
// Prepare data information for multiQC.
process mqc_data_info {
publishDir './results/mqc/', mode: 'copy'
input:
file get_data_info from PYTHON_DATA_INFO
file pos_data_dir from POS_DATA_DIR
file neg_data_dir from NEG_DATA_DIR
// POS_DATA and NEG_DATA are channels containing filtered POS and NEG data, which are ready to be input to R codes.
output:
file params.pos_data_info_mqc into POS_DATA_INFO_MQC
file params.neg_data_info_mqc into NEG_DATA_INFO_MQC
shell:
"""
python3 ${get_data_info} -i ${pos_data_dir} -o $params.pos_data_info_mqc -n p &&
python3 ${get_data_info} -i ${neg_data_dir} -o $params.neg_data_info_mqc -n n
"""
}
process add_stats {
publishDir './results/peak_table/', mode: 'copy'
echo true
input:
file python_addstats from PYTHON_ADDSTATS
file data_pos from POS_MZMINE_RESULT
file pos_design from POS_DESIGN_FOR_AS
file data_neg from NEG_MZMINE_RESULT
file neg_design from NEG_DESIGN_FOR_AS
file pos_library from POS_LIBRARY_STAT
file neg_library from NEG_LIBRARY_STAT
output:
file params.pos_data_nobg into POS_DATA_NOBG
file params.neg_data_nobg into NEG_DATA_NOBG
shell:
"""
python3 ${python_addstats} -i ${data_pos} -d ${pos_design} -o ${params.pos_data_nobg} -l ${pos_library} &&
python3 ${python_addstats} -i ${data_neg} -d ${neg_design} -o ${params.neg_data_nobg} -l ${neg_library}
"""
}
// split channel content for multiple-time use
POS_DATA_NOBG.into{POS_NOBG_FOR_BS; POS_NOBG_FOR_MQC; POS_NOBG_FOR_PCA; POS_NOBG_FOR_HCLUSTERING; POS_NOBG_FOR_VD; POS_NOBG_FOR_BARPLOT; POS_NOBG_FOR_MUMMICHOG; POS_NOBG_FOR_UNKNOWN_SEARCH}
NEG_DATA_NOBG.into{NEG_NOBG_FOR_BS; NEG_NOBG_FOR_MQC; NEG_NOBG_FOR_PCA; NEG_NOBG_FOR_HCLUSTERING; NEG_NOBG_FOR_VD; NEG_NOBG_FOR_BARPLOT; NEG_NOBG_FOR_MUMMICHOG; NEG_NOBG_FOR_UNKNOWN_SEARCH}
// Background subtraction
process blank_subtraction {
publishDir './results/peak_table/', mode: 'copy'
input:
file python_bs from PYTHON_BS
file data_pos from POS_NOBG_FOR_BS
file pos_design from POS_DESIGN_FOR_BS
file data_neg from NEG_NOBG_FOR_BS
file neg_design from NEG_DESIGN_FOR_BS
output:
file params.pos_data_withbg into POS_DATA_WITHBG
file params.neg_data_withbg into NEG_DATA_WITHBG
shell:
"""
python3 ${python_bs} -i ${data_pos} -d ${pos_design} -o ${params.pos_data_withbg} &&
python3 ${python_bs} -i ${data_neg} -d ${neg_design} -o ${params.neg_data_withbg}
"""
}
// split channel content for multiple-time use
POS_DATA_WITHBG.into{POS_WITHBG_FOR_MQC; POS_WITHBG_FOR_PCA; POS_WITHBG_FOR_HCLUSTERING; POS_WITHBG_FOR_VD; POS_WITHBG_FOR_BARPLOT; POS_WITHBG_FOR_MUMMICHOG; POS_WITHBG_FOR_UNKNOWN_SEARCH}
NEG_DATA_WITHBG.into{NEG_WITHBG_FOR_MQC; NEG_WITHBG_FOR_PCA; NEG_WITHBG_FOR_HCLUSTERING; NEG_WITHBG_FOR_VD; NEG_WITHBG_FOR_BARPLOT; NEG_WITHBG_FOR_MUMMICHOG; NEG_WITHBG_FOR_UNKNOWN_SEARCH}
// Process for generating files that can be parsed by MultiQC regarding peak numbers of different steps.
process mqc_peak_number_comparison {
publishDir './results/mqc/', mode: 'copy'
echo true
input:
file get_peak_number_comparison from PYTHON_PEAK_NUMBER_COMPARISON
file pos_nobg from POS_NOBG_FOR_MQC
file neg_nobg from NEG_NOBG_FOR_MQC
file pos_withbg from POS_WITHBG_FOR_MQC
file neg_withbg from NEG_WITHBG_FOR_MQC
output:
file params.peak_number_comparison_mqc into PEAK_NUMBER_COMPARISON_MQC
when:
params.bs == "1"
shell:
"""
python3 ${get_peak_number_comparison} -i1 ${pos_nobg} -i2 ${neg_nobg} -i3 ${pos_withbg} -i4 ${neg_withbg} -o ${params.peak_number_comparison_mqc}
"""
}
// process for PCA of "no background subtraction" results
process pca_nobg {
publishDir './results/figs', mode: 'copy'
input:
file data_pos from POS_NOBG_FOR_PCA
file pos_design from POS_DESIGN_FOR_PCA_NOBG
file data_neg from NEG_NOBG_FOR_PCA
file neg_design from NEG_DESIGN_FOR_PCA_NOBG
file python_pca from PYTHON_PCA_NOBG
output:
file params.pca_pos_nobg into PCA_POS_NOBG
file params.pca_neg_nobg into PCA_NEG_NOBG
shell:
"""
python3 ${python_pca} -i ${data_pos} -d ${pos_design} -o ${params.pca_pos_nobg} &&
python3 ${python_pca} -i ${data_neg} -d ${neg_design} -o ${params.pca_neg_nobg}
"""
}
// process for PCA of "with background subtraction" results, here we use 100 as the threshold of background subtraction.
process pca_withbg {
publishDir './results/figs', mode: 'copy'
input:
file data_pos from POS_WITHBG_FOR_PCA
file pos_design from POS_DESIGN_FOR_PCA_WITHBG
file data_neg from NEG_WITHBG_FOR_PCA
file neg_design from NEG_DESIGN_FOR_PCA_WITHBG
file python_pca from PYTHON_PCA_WITHBG
output:
file params.pca_pos_withbg into PCA_POS_WITHBG
file params.pca_neg_withbg into PCA_NEG_WITHBG
shell:
"""
python3 ${python_pca} -i ${data_pos} -d ${pos_design} -o ${params.pca_pos_withbg} &&
python3 ${python_pca} -i ${data_neg} -d ${neg_design} -o ${params.pca_neg_withbg}
"""
}
// process for hierarchical clustering of "no background subtraction" results
process h_clustering_nobg {
publishDir './results/figs', mode: 'copy'
input:
file data_pos from POS_NOBG_FOR_HCLUSTERING
file pos_design from POS_DESIGN_FOR_HCLUSTERING_NOBG
file data_neg from NEG_NOBG_FOR_HCLUSTERING
file neg_design from NEG_DESIGN_FOR_HCLUSTERING_NOBG
file python_hclustering from PYTHON_HCLUSTERING_NOBG
output:
file params.hclustering_pos_nobg into HCLUSTERING_POS_NOBG
file params.hclustering_neg_nobg into HCLUSTERING_NEG_NOBG
shell:
"""
python3 ${python_hclustering} -i ${data_pos} -d ${pos_design} -o ${params.hclustering_pos_nobg} -m 0 &&
python3 ${python_hclustering} -i ${data_neg} -d ${neg_design} -o ${params.hclustering_neg_nobg} -m 0
"""
}
// process for hierarchical clustering of "with background subtraction" results, here we use 100 as the threshold of background subtraction.
process h_clustering_withbg {
publishDir './results/figs', mode: 'copy'
input:
file data_pos from POS_WITHBG_FOR_HCLUSTERING
file pos_design from POS_DESIGN_FOR_HCLUSTERING_WITHBG
file data_neg from NEG_WITHBG_FOR_HCLUSTERING
file neg_design from NEG_DESIGN_FOR_HCLUSTERING_WITHBG
file python_hclustering from PYTHON_HCLUSTERING_WITHBG
output:
file params.hclustering_pos_withbg into HCLUSTERING_POS_WITHBG
file params.hclustering_neg_withbg into HCLUSTERING_NEG_WITHBG
shell:
"""
python3 ${python_hclustering} -i ${data_pos} -d ${pos_design} -o ${params.hclustering_pos_withbg} -m 0 &&
python3 ${python_hclustering} -i ${data_neg} -d ${neg_design} -o ${params.hclustering_neg_withbg} -m 0
"""
}
// process for venn diagram of "no background subtraction" results
process venn_diagram_nobg {
publishDir './results/figs', mode: 'copy'
input:
file data_pos from POS_NOBG_FOR_VD
file pos_design from POS_DESIGN_FOR_VD_NOBG
file data_neg from NEG_NOBG_FOR_VD
file neg_design from NEG_DESIGN_FOR_VD_NOBG
file python_vd from PYTHON_VD_NOBG
output:
file params.vd_pos_nobg into VD_POS_NOBG
file params.vd_neg_nobg into VD_NEG_NOBG
file params.pos_vd_group1_nobg into POS_VD_GROUP1_NOBG
file params.pos_vd_group2_nobg into POS_VD_GROUP2_NOBG
file params.pos_vd_both_nobg into POS_VD_BOTH_NOBG
file params.neg_vd_group1_nobg into NEG_VD_GROUP1_NOBG
file params.neg_vd_group2_nobg into NEG_VD_GROUP2_NOBG
file params.neg_vd_both_nobg into NEG_VD_BOTH_NOBG
file "pos*.txt" into POS_NOBG_CUTOFFS
file "neg*.txt" into NEG_NOBG_CUTOFFS
shell:
"""
python3 ${python_vd} -i ${data_pos} -d ${pos_design} -o ${params.vd_pos_nobg} -bs 0 -g1 ${params.pos_vd_group1_nobg} -g2 ${params.pos_vd_group2_nobg} -bt ${params.pos_vd_both_nobg} &&
python3 ${python_vd} -i ${data_neg} -d ${neg_design} -o ${params.vd_neg_nobg} -bs 0 -g1 ${params.neg_vd_group1_nobg} -g2 ${params.neg_vd_group2_nobg} -bt ${params.neg_vd_both_nobg}
"""
}
// process for venn diagram of "with background subtraction" results, here we use 100 as the threshold of background subtraction.
process venn_diagram_withbg {
publishDir './results/figs', mode: 'copy'
input:
file data_pos from POS_WITHBG_FOR_VD
file pos_design from POS_DESIGN_FOR_VD_WITHBG
file data_neg from NEG_WITHBG_FOR_VD
file neg_design from NEG_DESIGN_FOR_VD_WITHBG
file python_vd from PYTHON_VD_WITHBG
output:
file params.vd_pos_withbg into VD_POS_WITHBG
file params.vd_neg_withbg into VD_NEG_WITHBG
file params.pos_vd_group1_withbg into POS_VD_GROUP1_WITHBG
file params.pos_vd_group2_withbg into POS_VD_GROUP2_WITHBG
file params.pos_vd_both_withbg into POS_VD_BOTH_WITHBG
file params.neg_vd_group1_withbg into NEG_VD_GROUP1_WITHBG
file params.neg_vd_group2_withbg into NEG_VD_GROUP2_WITHBG
file params.neg_vd_both_withbg into NEG_VD_BOTH_WITHBG
file "pos*.txt" into POS_WITHBG_CUTOFFS
file "neg*.txt" into NEG_WITHBG_CUTOFFS
shell:
"""
python3 ${python_vd} -i ${data_pos} -d ${pos_design} -o ${params.vd_pos_withbg} -bs 1 -g1 ${params.pos_vd_group1_withbg} -g2 ${params.pos_vd_group2_withbg} -bt ${params.pos_vd_both_withbg} &&
python3 ${python_vd} -i ${data_neg} -d ${neg_design} -o ${params.vd_neg_withbg} -bs 1 -g1 ${params.neg_vd_group1_withbg} -g2 ${params.neg_vd_group2_withbg} -bt ${params.neg_vd_both_withbg}
"""
}
// process for bar plot of "no background subtraction" results
process bar_plot_nobg {
publishDir './results/figs', mode: 'copy'
input:
file data_pos from POS_NOBG_FOR_BARPLOT
file pos_design from POS_DESIGN_FOR_BARPLOT_NOBG
file data_neg from NEG_NOBG_FOR_BARPLOT
file neg_design from NEG_DESIGN_FOR_BARPLOT_NOBG
file python_barplot from PYTHON_BARPLOT_NOBG
output:
file params.barplot_pos_nobg into BARPLOT_POS_NOBG
file params.barplot_neg_nobg into BARPLOT_NEG_NOBG
shell:
"""
python3 ${python_barplot} -i ${data_pos} -d ${pos_design} -o ${params.barplot_pos_nobg} -m 0 -bs 0 &&
python3 ${python_barplot} -i ${data_neg} -d ${neg_design} -o ${params.barplot_neg_nobg} -m 0 -bs 0
"""
}
// process for bar plot of "with background subtraction" results, here we use 100 as the threshold of background subtraction.
process bar_plot_withbg {
publishDir './results/figs', mode: 'copy'
input:
file data_pos from POS_WITHBG_FOR_BARPLOT
file pos_design from POS_DESIGN_FOR_BARPLOT_WITHBG
file data_neg from NEG_WITHBG_FOR_BARPLOT
file neg_design from NEG_DESIGN_FOR_BARPLOT_WITHBG
file python_barplot from PYTHON_BARPLOT_WITHBG
output:
file params.barplot_pos_withbg into BARPLOT_POS_WITHBG
file params.barplot_neg_withbg into BARPLOT_NEG_WITHBG
shell:
"""
python3 ${python_barplot} -i ${data_pos} -d ${pos_design} -o ${params.barplot_pos_withbg} -m 0 -bs 1 &&
python3 ${python_barplot} -i ${data_neg} -d ${neg_design} -o ${params.barplot_neg_withbg} -m 0 -bs 1
"""
}
// unknown search for metabolites identified before blank subtraction
process unknown_search_nobg {
publishDir './results/peak_table/', mode: 'copy'
input:
file data_pos from POS_NOBG_FOR_UNKNOWN_SEARCH
file data_neg from NEG_NOBG_FOR_UNKNOWN_SEARCH
file r_unknown_search from R_UNKNOWN_SEARCH_NOBG
output:
file params.unknown_search_pos_nobg into UNKNOWN_SEARCH_POS_NOBG
file params.unknown_search_neg_nobg into UNKNOWN_SEARCH_NEG_NOBG
when:
params.unknown_search == "1"
shell:
"""
Rscript ${r_unknown_search} -i ${data_pos} -n positive -c ${params.mz_col_pos_nobg} -o ${params.unknown_search_pos_nobg} &&
Rscript ${r_unknown_search} -i ${data_neg} -n negative -c ${params.mz_col_neg_nobg} -o ${params.unknown_search_neg_nobg}
"""
}
// unknown search for metabolites identified after blank subtraction
process unknown_search_withbg {
publishDir './results/peak_table/', mode: 'copy'
input:
file data_pos from POS_WITHBG_FOR_UNKNOWN_SEARCH
file data_neg from NEG_WITHBG_FOR_UNKNOWN_SEARCH
file r_unknown_search from R_UNKNOWN_SEARCH_WITHBG
output:
file params.unknown_search_pos_withbg into UNKNOWN_SEARCH_POS_WITHBG
file params.unknown_search_neg_withbg into UNKNOWN_SEARCH_NEG_WITHBG
when:
params.bs == "1" && params.unknown_search == "1"
shell:
"""
Rscript ${r_unknown_search} -i ${data_pos} -n positive -c ${params.mz_col_pos_withbg} -o ${params.unknown_search_pos_withbg} &&
Rscript ${r_unknown_search} -i ${data_neg} -n negative -c ${params.mz_col_neg_withbg} -o ${params.unknown_search_neg_withbg}
"""
}
// The following conditional codes is because the folder of matplotlib is different using HPC and using local machine
if (workflow.profile != "docker") {
MAT_CONFIG_DIR = Channel.from('~/.config/matplotlib/')
MAT_CONFIG_FILE = Channel.from('~/.config/matplotlib/matplotlibrc')
}
else {
MAT_CONFIG_DIR = Channel.from('/root/.config/matplotlib/')
MAT_CONFIG_FILE = Channel.from('/root/.config/matplotlib/matplotlibrc')
}
MAT_CONFIG_DIR.into{MAT_CONFIG_DIR_NOBG; MAT_CONFIG_DIR_WITHBG}
MAT_CONFIG_FILE.into{MAT_CONFIG_FILE_NOBG; MAT_CONFIG_FILE_WITHBG}
// Mummichog pathway analysis
process mummichog_report_nobg {
publishDir './results/mummichog/before_blank_subtraction', mode: 'copy'
input:
file python_mummichog_input_prepare from PYTHON_MUMMICHOG_INPUT_PREPARE_NOBG
file pos_vd_both_nobg from POS_VD_BOTH_NOBG
// file neg_vd_both_nobg from NEG_VD_BOTH_NOBG
val mat_config_dir_nobg from MAT_CONFIG_DIR_NOBG
val mat_config_file_nobg from MAT_CONFIG_FILE_NOBG
// file "*" from POS_NOBG_CUTOFFS
output:
file "*" into MUMMICHOG_REPORT_NOBG
shell:
"""
pip install networkx==1.11 &&
echo "generating mommichog report for peaks before blank subtraction" &&
sudo mkdir -p !{mat_config_dir_nobg} &&
sudo echo "backend: Agg" > !{mat_config_file_nobg} &&
python3 !{python_mummichog_input_prepare} -i !{pos_vd_both_nobg} -o !{params.data_pos_nobg_both_mummichog} &&
mummichog -f !{params.data_pos_nobg_both_mummichog} -o !{params.data_pos_nobg_both_mummichog_out} -c !{params.cutoff}
"""
}
process mummichog_report_withbg {
publishDir './results/mummichog/after_blank_subtraction', mode: 'copy'
input:
file python_mummichog_input_prepare from PYTHON_MUMMICHOG_INPUT_PREPARE_WITHBG
file pos_vd_both_withbg from POS_VD_BOTH_WITHBG
// file neg_vd_both_withbg from NEG_VD_BOTH_WITHBG
val mat_config_dir_withbg from MAT_CONFIG_DIR_WITHBG
val mat_config_file_withbg from MAT_CONFIG_FILE_WITHBG
// file "*" from POS_WITHBG_CUTOFFS
output:
file "*" into MUMMICHOG_REPORT_WITHBG
when:
params.bs == "1"
shell:
"""
pip install networkx==1.11 &&
echo "generating mommichog report for peaks after blank subtraction" &&
sudo mkdir -p !{mat_config_dir_withbg} &&
sudo echo "backend: Agg" > !{mat_config_file_withbg} &&
python3 !{python_mummichog_input_prepare} -i !{pos_vd_both_withbg} -o !{params.data_pos_withbg_both_mummichog} &&
mummichog -f !{params.data_pos_withbg_both_mummichog} -o !{params.data_pos_withbg_both_mummichog_out} -c !{params.cutoff}
"""
}