-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathmain.nf
More file actions
623 lines (551 loc) · 25.2 KB
/
main.nf
File metadata and controls
623 lines (551 loc) · 25.2 KB
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
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
#!/usr/bin/env nextflow
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
goodwright/clipseq
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Github : https://github.com/goodwright/clipseq
----------------------------------------------------------------------------------------
*/
nextflow.enable.dsl = 2
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
IMPORT FUNCTIONS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
include { summary_log } from './modules/goodwright/util/logging/main'
include { multiqc_summary } from './modules/goodwright/util/logging/main'
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
INIT
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
log.info summary_log(workflow, params, params.debug, params.monochrome_logs)
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
VALIDATE INPUTS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
// Check manditory input parameters to see if the files exist if they have been specified
check_param_list = [
samplesheet: params.samplesheet,
fasta: params.fasta,
smrna_fasta: params.smrna_fasta,
gtf: params.gtf
]
for (param in check_param_list) {
if (!param.value) {
exit 1, "Required parameter not specified: ${param.key}"
}
else {
file(param.value, checkIfExists: true)
}
}
// Check non-manditory input parameters to see if the files exist if they have been specified
check_param_list = [
params.target_genome_index,
params.smrna_genome_index,
params.fasta_fai,
params.filtered_gtf,
params.chrom_sizes,
params.smrna_fasta_fai,
params.smrna_chrom_sizes,
params.longest_transcript,
params.longest_transcript_fai,
params.longest_transcript_gtf,
params.seg_gtf,
params.seg_filt_gtf,
params.seg_resolved_gtf,
params.seg_resolved_gtf_genic,
params.regions_gtf,
params.regions_filt_gtf,
params.regions_resolved_gtf,
params.regions_resolved_gtf_genic
]
for (param in check_param_list) { if (param) { file(param, checkIfExists: true) } }
// Stage dummy file to be used as an optional input where required
ch_dummy_file = file("$projectDir/assets/dummy_file.txt", checkIfExists: true)
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CONFIG FILES
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
ch_multiqc_config = file("$projectDir/assets/multiqc_config.yml", checkIfExists: true)
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
IMPORT LOCAL MODULES/SUBWORKFLOWS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
//
// MODULEs
//
include { MULTIQC } from './modules/local/multiqc'
include { GET_CROSSLINKS as CALC_SMRNA_K1_CROSSLINKS } from './modules/local/get_crosslinks'
include { GET_CROSSLINKS as CALC_GENOME_CROSSLINKS } from './modules/local/get_crosslinks'
include { GET_CROSSLINKS as CALC_TRANSCRIPT_CROSSLINKS } from './modules/local/get_crosslinks'
//
// SUBWORKFLOWS
//
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
IMPORT GOODWRIGHT MODULES/SUBWORKFLOWS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
//
// MODULEs
//
include { SAMTOOLS_SIMPLE_VIEW as FILTER_TRANSCRIPTS } from './modules/goodwright/samtools/simple_view/main'
include { CLIPPY as CLIPPY_GENOME } from './modules/goodwright/clippy/main'
include { CLIPPY as CLIPPY_TRANSCRIPT } from './modules/goodwright/clippy/main'
include { PEKA } from './modules/goodwright/peka/main'
include { DUMP_SOFTWARE_VERSIONS } from './modules/goodwright/dump_software_versions/main'
include { CLIPSEQ_CLIPQC } from './modules/goodwright/clipseq/clipqc/main'
include { ENCODE_MOVEUMI } from './modules/goodwright/clipseq/encode_moveumi/main'
//
// SUBWORKFLOWS
//
include { PREPARE_CLIPSEQ } from './subworkflows/goodwright/prepare_genome/prepare_clipseq/main'
include { PARSE_FASTQ_INPUT } from './subworkflows/goodwright/parse_fastq_input/main'
include { FASTQC_TRIMGALORE } from './subworkflows/goodwright/fastqc_trimgalore/main'
include { RNA_ALIGN } from './subworkflows/goodwright/rna_align/main'
include { BAM_DEDUP_SAMTOOLS_UMITOOLS as GENOME_UNIQUE_DEDUP } from './subworkflows/goodwright/bam_dedup_samtools_umitools/main'
include { BAM_DEDUP_SAMTOOLS_UMITOOLS as GENOME_MULTI_DEDUP } from './subworkflows/goodwright/bam_dedup_samtools_umitools/main'
include { BAM_DEDUP_SAMTOOLS_UMITOOLS as SMRNA_DEDUP } from './subworkflows/goodwright/bam_dedup_samtools_umitools/main'
include { BAM_DEDUP_SAMTOOLS_UMITOOLS as SMRNA_K1_DEDUP } from './subworkflows/goodwright/bam_dedup_samtools_umitools/main'
include { BAM_DEDUP_SAMTOOLS_UMITOOLS as TRANSCRIPT_DEDUP } from './subworkflows/goodwright/bam_dedup_samtools_umitools/main'
include { PARACLU_ANALYSE as PARACLU_ANALYSE_GENOME } from './subworkflows/goodwright/paraclu_analyse/main'
include { PARACLU_ANALYSE as PARACLU_ANALYSE_TRANSCRIPT } from './subworkflows/goodwright/paraclu_analyse/main'
include { ICOUNT_ANALYSE } from './subworkflows/goodwright/icount_analyse/main'
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
IMPORT NF-CORE MODULES/SUBWORKFLOWS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
//
// MODULEs
//
include { UMITOOLS_EXTRACT } from './modules/nf-core/umitools/extract/main'
include { SAMTOOLS_SORT as SAMTOOLS_SORT_FILT_TRANSCRIPT } from './modules/nf-core/samtools/sort/main'
include { SAMTOOLS_INDEX as SAMTOOLS_INDEX_FILT_TRANSCRIPT } from './modules/nf-core/samtools/index/main'
//
// SUBWORKFLOWS
//
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
RUN MAIN WORKFLOW
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
workflow CLIPSEQ {
// Init
ch_versions = Channel.empty()
// Prepare manditory params into channels
ch_samplesheet = file(params.samplesheet, checkIfExists: true)
ch_fasta = file(params.fasta, checkIfExists: true)
ch_smrna_fasta = file(params.smrna_fasta, checkIfExists: true)
ch_gtf = file(params.gtf, checkIfExists: true)
if (params.run_genome_prep) {
// Prepare non-manditory params into channels
ch_target_genome_index = []
ch_smrna_genome_index = []
ch_fasta_fai = []
ch_filtered_gtf = []
ch_chrom_sizes = []
ch_smrna_fasta_fai = []
ch_smrna_chrom_sizes = []
ch_longest_transcript = []
ch_seg_gtf = []
ch_seg_filt_gtf = []
ch_seg_resolved_gtf = []
ch_seg_resolved_gtf_genic = []
ch_regions_gtf = []
ch_regions_filt_gtf = []
ch_regions_resolved_gtf = []
ch_regions_resolved_gtf_genic = []
ch_longest_transcript_fai = []
ch_longest_transcript_gtf = []
if(params.target_genome_index) { ch_target_genome_index = file(params.target_genome_index, checkIfExists: true) }
if(params.smrna_genome_index) { ch_smrna_genome_index = file(params.smrna_genome_index, checkIfExists: true) }
if(params.fasta_fai) { ch_fasta_fai = Channel.of([[:],file(params.fasta_fai, checkIfExists: true)]) }
if(params.filtered_gtf) { ch_filtered_gtf = Channel.of([[:],file(params.filtered_gtf, checkIfExists: true)]) }
if(params.chrom_sizes) { ch_chrom_sizes = Channel.of([[:],file(params.chrom_sizes, checkIfExists: true)]) }
if(params.smrna_fasta_fai) { ch_smrna_fasta_fai = Channel.of([[:],file(params.smrna_fasta_fai, checkIfExists: true)]) }
if(params.smrna_chrom_sizes) { ch_smrna_chrom_sizes = Channel.of([[:],file(params.smrna_chrom_sizes, checkIfExists: true)]) }
if(params.longest_transcript) { ch_longest_transcript = Channel.of([[:],file(params.longest_transcript, checkIfExists: true)]) }
if(params.longest_transcript_fai) { ch_longest_transcript_fai = Channel.of([[:],file(params.longest_transcript_fai, checkIfExists: true)]) }
if(params.longest_transcript_gtf) { ch_longest_transcript_gtf = Channel.of([[:],file(params.longest_transcript_gtf, checkIfExists: true)]) }
if(params.seg_gtf) { ch_seg_gtf = Channel.of([[:],file(params.seg_gtf, checkIfExists: true)]) }
if(params.seg_filt_gtf) { ch_seg_filt_gtf = Channel.of([[:],file(params.seg_filt_gtf, checkIfExists: true)]) }
if(params.seg_resolved_gtf) { ch_seg_resolved_gtf = Channel.of([[:],file(params.seg_resolved_gtf, checkIfExists: true)]) }
if(params.seg_resolved_gtf_genic) { ch_seg_resolved_gtf_genic= Channel.of([[:],file(params.seg_resolved_gtf_genic, checkIfExists: true)]) }
if(params.regions_gtf) { ch_regions_gtf = Channel.of([[:],file(params.regions_gtf, checkIfExists: true)]) }
if(params.regions_filt_gtf) { ch_regions_filt_gtf = Channel.of([[:],file(params.regions_filt_gtf, checkIfExists: true)]) }
if(params.regions_resolved_gtf) { ch_regions_resolved_gtf = Channel.of([[:],file(params.regions_resolved_gtf, checkIfExists: true)]) }
if(params.regions_resolved_gtf_genic) { ch_regions_resolved_gtf_genic = Channel.of([[:],file(params.regions_resolved_gtf_genic, checkIfExists: true)]) }
/*
* SUBWORKFLOW: Prepare clipseq genome files
*/
PREPARE_CLIPSEQ (
ch_fasta,
ch_smrna_fasta,
ch_gtf,
ch_target_genome_index,
ch_smrna_genome_index,
ch_fasta_fai,
ch_filtered_gtf,
ch_chrom_sizes,
ch_smrna_fasta_fai,
ch_smrna_chrom_sizes,
ch_longest_transcript,
ch_seg_gtf,
ch_seg_filt_gtf,
ch_seg_resolved_gtf,
ch_seg_resolved_gtf_genic,
ch_regions_gtf,
ch_regions_filt_gtf,
ch_regions_resolved_gtf,
ch_regions_resolved_gtf_genic,
ch_longest_transcript_fai,
ch_longest_transcript_gtf
)
ch_versions = ch_versions.mix(PREPARE_CLIPSEQ.out.versions)
ch_fasta = PREPARE_CLIPSEQ.out.fasta
ch_fasta_fai = PREPARE_CLIPSEQ.out.fasta_fai
ch_gtf = PREPARE_CLIPSEQ.out.gtf
ch_filtered_gtf = PREPARE_CLIPSEQ.out.filtered_gtf
ch_chrom_sizes = PREPARE_CLIPSEQ.out.chrom_sizes
ch_smrna_fasta = PREPARE_CLIPSEQ.out.smrna_fasta
ch_smrna_fasta_fai = PREPARE_CLIPSEQ.out.smrna_fasta_fai
ch_smrna_chrom_sizes = PREPARE_CLIPSEQ.out.smrna_chrom_sizes
ch_longest_transcript = PREPARE_CLIPSEQ.out.longest_transcript
ch_longest_transcript_fai = PREPARE_CLIPSEQ.out.longest_transcript_fai
ch_longest_transcript_gtf = PREPARE_CLIPSEQ.out.longest_transcript_gtf
ch_seg_gtf = PREPARE_CLIPSEQ.out.seg_gtf
ch_seg_filt_gtf = PREPARE_CLIPSEQ.out.seg_filt_gtf
ch_seg_resolved_gtf = PREPARE_CLIPSEQ.out.seg_resolved_gtf
ch_seg_resolved_gtf_genic = PREPARE_CLIPSEQ.out.seg_resolved_gtf_genic
ch_regions_gtf = PREPARE_CLIPSEQ.out.regions_gtf
ch_regions_filt_gtf = PREPARE_CLIPSEQ.out.regions_filt_gtf
ch_regions_resolved_gtf = PREPARE_CLIPSEQ.out.regions_resolved_gtf
ch_regions_resolved_gtf_genic = PREPARE_CLIPSEQ.out.regions_resolved_gtf_genic
ch_target_genome_index = PREPARE_CLIPSEQ.out.genome_index
ch_smrna_genome_index = PREPARE_CLIPSEQ.out.smrna_index
}
ch_fastq = Channel.empty()
if(params.run_input_check) {
/*
* SUBWORKFLOW: Read in samplesheet, validate, stage input files and merge replicates
*/
PARSE_FASTQ_INPUT (
ch_samplesheet
)
ch_versions = ch_versions.mix(PARSE_FASTQ_INPUT.out.versions)
ch_fastq = PARSE_FASTQ_INPUT.out.fastq
}
//EXAMPLE CHANNEL STRUCT: [[id:h3k27me3_R1, group:h3k27me3, replicate:1, single_end:false], [FASTQ]]
//ch_fastq | view
if(params.encode_eclip){
ENCODE_MOVEUMI (
ch_fastq
)
ch_versions = ch_versions.mix(ENCODE_MOVEUMI.out.versions)
ch_fastq = ENCODE_MOVEUMI.out.reads
}
if(params.run_move_umi_to_header){
UMITOOLS_EXTRACT (
ch_fastq
)
ch_versions = ch_versions.mix(UMITOOLS_EXTRACT.out.versions)
ch_fastq = UMITOOLS_EXTRACT.out.reads
}
if(params.run_trim_galore_fastqc) {
/*
* SUBWORKFLOW: Run fastqc and trimming
*/
FASTQC_TRIMGALORE (
ch_fastq,
params.skip_fastqc,
params.skip_trimming
)
ch_versions = ch_versions.mix(FASTQC_TRIMGALORE.out.versions)
ch_fastq = FASTQC_TRIMGALORE.out.fastq
}
//EXAMPLE CHANNEL STRUCT: [[id:h3k27me3_R1, group:h3k27me3, replicate:1, single_end:false], [FASTQ]]
//ch_fastq | view
ch_genome_bam = Channel.empty()
ch_genome_bai = Channel.empty()
ch_transcript_bam = Channel.empty()
ch_transcript_bai = Channel.empty()
ch_bt_log = Channel.empty()
ch_star_log = Channel.empty()
if(params.run_alignment) {
/*
* SUBWORKFLOW: Run alignment to target and smrna genome. sort/index the output
*/
RNA_ALIGN (
ch_fastq,
ch_smrna_genome_index,
ch_target_genome_index,
ch_filtered_gtf,
ch_fasta
)
ch_versions = ch_versions.mix(RNA_ALIGN.out.versions)
ch_genome_unique_bam = RNA_ALIGN.out.genome_unique_bam
ch_genome_unique_bai = RNA_ALIGN.out.genome_unique_bai
ch_genome_multi_bam = RNA_ALIGN.out.genome_multi_bam
ch_genome_multi_bai = RNA_ALIGN.out.genome_multi_bai
ch_smrna_bam = RNA_ALIGN.out.smrna_bam
ch_smrna_bai = RNA_ALIGN.out.smrna_bai
ch_smrna_k1_bam = RNA_ALIGN.out.smrna_k1_bam
ch_smrna_k1_bai = RNA_ALIGN.out.smrna_k1_bai
ch_transcript_bam = RNA_ALIGN.out.transcript_bam
ch_transcript_bai = RNA_ALIGN.out.transcript_bai
ch_bt_log = RNA_ALIGN.out.bt_log
ch_star_log = RNA_ALIGN.out.star_log_final
}
if(params.run_read_filter) {
/*
* CHANNEL: Combine bam and bai files on id
*/
ch_transcript_bam_bai = ch_transcript_bam
.map { row -> [row[0].id, row ].flatten()}
.join ( ch_transcript_bai.map { row -> [row[0].id, row ].flatten()} )
.map { row -> [row[1], row[2], row[4]] }
/*
* MODULE: Filter transcriptome bam on longest transcripts
*/
FILTER_TRANSCRIPTS (
ch_transcript_bam_bai,
[],
ch_longest_transcript.collect{ it[1] }
)
ch_versions = ch_versions.mix(FILTER_TRANSCRIPTS.out.versions)
/*
* SUBWORKFLOW: sort, index filtered bam
*/
SAMTOOLS_SORT_FILT_TRANSCRIPT ( FILTER_TRANSCRIPTS.out.bam )
SAMTOOLS_INDEX_FILT_TRANSCRIPT ( SAMTOOLS_SORT_FILT_TRANSCRIPT.out.bam )
ch_versions = ch_versions.mix(SAMTOOLS_SORT_FILT_TRANSCRIPT.out.versions)
ch_versions = ch_versions.mix(SAMTOOLS_INDEX_FILT_TRANSCRIPT.out.versions)
ch_transcript_bam = SAMTOOLS_SORT_FILT_TRANSCRIPT.out.bam
ch_transcript_bai = SAMTOOLS_INDEX_FILT_TRANSCRIPT.out.bai
}
ch_umi_log = Channel.empty()
if(params.run_umi_dedup) {
/*
* CHANNEL: Combine bam and bai files on id
*/
ch_genome_unique_bam_bai = ch_genome_unique_bam
.map { row -> [row[0].id, row ].flatten()}
.join ( ch_genome_unique_bai.map { row -> [row[0].id, row ].flatten()} )
.map { row -> [row[1], row[2], row[4]] }
ch_genome_multi_bam_bai = ch_genome_multi_bam
.map { row -> [row[0].id, row ].flatten()}
.join ( ch_genome_multi_bai.map { row -> [row[0].id, row ].flatten()} )
.map { row -> [row[1], row[2], row[4]] }
ch_smrna_bam_bai = ch_smrna_bam
.map { row -> [row[0].id, row ].flatten()}
.join ( ch_smrna_bai.map { row -> [row[0].id, row ].flatten()} )
.map { row -> [row[1], row[2], row[4]] }
ch_smrna_k1_bam_bai = ch_smrna_k1_bam
.map { row -> [row[0].id, row ].flatten()}
.join ( ch_smrna_k1_bai.map { row -> [row[0].id, row ].flatten()} )
.map { row -> [row[1], row[2], row[4]] }
ch_transcript_bam_bai = ch_transcript_bam
.map { row -> [row[0].id, row ].flatten()}
.join ( ch_transcript_bai.map { row -> [row[0].id, row ].flatten()} )
.map { row -> [row[1], row[2], row[4]] }
/*
* SUBWORKFLOW: Run umi deduplication on genome-level alignments
*/
GENOME_UNIQUE_DEDUP (
ch_genome_unique_bam_bai
)
ch_versions = ch_versions.mix(GENOME_UNIQUE_DEDUP.out.versions)
ch_genome_bam = GENOME_UNIQUE_DEDUP.out.bam
ch_genome_bai = GENOME_UNIQUE_DEDUP.out.bai
ch_umi_log = GENOME_UNIQUE_DEDUP.out.umi_log
GENOME_MULTI_DEDUP (
ch_genome_multi_bam_bai
)
ch_versions = ch_versions.mix(GENOME_MULTI_DEDUP.out.versions)
SMRNA_DEDUP (
ch_smrna_bam_bai
)
ch_versions = ch_versions.mix(SMRNA_DEDUP.out.versions)
SMRNA_K1_DEDUP (
ch_smrna_k1_bam_bai
)
ch_versions = ch_versions.mix(SMRNA_K1_DEDUP.out.versions)
ch_smrna_k1_bam = SMRNA_K1_DEDUP.out.bam
ch_smrna_k1_bai = SMRNA_K1_DEDUP.out.bai
ch_umi_log = SMRNA_K1_DEDUP.out.umi_log
/*
* SUBWORKFLOW: Run umi deduplication on transcript-level alignments
*/
TRANSCRIPT_DEDUP (
ch_transcript_bam_bai
)
ch_versions = ch_versions.mix(TRANSCRIPT_DEDUP.out.versions)
ch_transcript_bam = TRANSCRIPT_DEDUP.out.bam
ch_transcript_bai = TRANSCRIPT_DEDUP.out.bai
} else {
ch_genome_bam = ch_genome_unique_bam
ch_genome_bai = ch_genome_unique_bai
}
ch_genome_crosslink_bed = Channel.empty()
ch_genome_crosslink_coverage = Channel.empty()
ch_genome_crosslink_coverage_norm = Channel.empty()
ch_trans_crosslink_bed = Channel.empty()
ch_trans_crosslink_coverage = Channel.empty()
ch_trans_crosslink_coverage_norm = Channel.empty()
if(params.run_calc_crosslinks) {
/*
* SUBWORKFLOW: Run crosslink calculation for smRNA with -k 1
*/
CALC_SMRNA_K1_CROSSLINKS (
ch_smrna_k1_bam.join(ch_smrna_k1_bai),
ch_smrna_fasta_fai.collect{ it[1] },
params.crosslink_position
)
ch_versions = ch_versions.mix(CALC_SMRNA_K1_CROSSLINKS.out.versions)
ch_smrna_crosslink_bed = CALC_SMRNA_K1_CROSSLINKS.out.bed
ch_smrna_crosslink_coverage = CALC_SMRNA_K1_CROSSLINKS.out.coverage
ch_smrna_crosslink_coverage_norm = CALC_SMRNA_K1_CROSSLINKS.out.coverage_norm
/*
* SUBWORKFLOW: Run crosslink calculation for genome
*/
CALC_GENOME_CROSSLINKS (
ch_genome_bam.join(ch_genome_bai),
ch_fasta_fai.collect{ it[1] },
params.crosslink_position
)
ch_versions = ch_versions.mix(CALC_GENOME_CROSSLINKS.out.versions)
ch_genome_crosslink_bed = CALC_GENOME_CROSSLINKS.out.bed
ch_genome_crosslink_coverage = CALC_GENOME_CROSSLINKS.out.coverage
ch_genome_crosslink_coverage_norm = CALC_GENOME_CROSSLINKS.out.coverage_norm
/*
* SUBWORKFLOW: Run crosslink calculation for transcripts
*/
CALC_TRANSCRIPT_CROSSLINKS (
ch_transcript_bam.join(ch_transcript_bai),
ch_longest_transcript_fai.collect{ it[1] },
params.crosslink_position
)
ch_versions = ch_versions.mix(CALC_TRANSCRIPT_CROSSLINKS.out.versions)
ch_trans_crosslink_bed = CALC_TRANSCRIPT_CROSSLINKS.out.bed
ch_trans_crosslink_coverage = CALC_TRANSCRIPT_CROSSLINKS.out.coverage
ch_trans_crosslink_coverage_norm = CALC_TRANSCRIPT_CROSSLINKS.out.coverage_norm
}
if(params.run_peak_calling) {
/*
* MODULE: Run clippy on genome-level crosslinks
*/
CLIPPY_GENOME (
ch_genome_crosslink_bed,
ch_filtered_gtf.collect{ it[1] },
ch_fasta_fai.collect{ it[1] }
)
ch_versions = ch_versions.mix(CLIPPY_GENOME.out.versions)
/*
* MODULE: Run clippy on transcript-level crosslinks
*/
CLIPPY_TRANSCRIPT (
ch_trans_crosslink_bed,
ch_longest_transcript_gtf.collect{ it[1] },
ch_longest_transcript_fai.collect{ it[1] }
)
ch_versions = ch_versions.mix(CLIPPY_TRANSCRIPT.out.versions)
/*
* SUBWORKFLOW: Run paraclu on genome-level and transcript-level crosslinks
*/
PARACLU_ANALYSE_GENOME (
ch_genome_crosslink_bed,
params.paraclu_min_value
)
ch_versions = ch_versions.mix(PARACLU_ANALYSE_GENOME.out.versions)
PARACLU_ANALYSE_TRANSCRIPT (
ch_trans_crosslink_bed,
params.paraclu_min_value
)
/*
* SUBWORKFLOW: Run iCount on genome-level crosslinks
*/
ICOUNT_ANALYSE (
ch_smrna_crosslink_bed,
ch_genome_crosslink_bed,
ch_regions_resolved_gtf.collect{ it[1] },
ch_seg_resolved_gtf.collect{ it[1] },
true
)
ch_versions = ch_versions.mix(ICOUNT_ANALYSE.out.versions)
/*
* MODULE: Run peka on genome-level crosslinks
*/
ch_peka_input = CLIPPY_GENOME.out.peaks
.join(ch_genome_crosslink_bed, by: 0)
PEKA (
ch_peka_input.map { meta, peaks, crosslinks -> [meta, peaks] },
ch_peka_input.map { meta, peaks, crosslinks -> [meta, crosslinks] },
ch_fasta.collect{ it[1] },
ch_fasta_fai.collect{ it[1] },
ch_regions_resolved_gtf.collect{ it[1] }
)
ch_versions = ch_versions.mix(PEKA.out.versions)
}
if(params.run_reporting) {
/*
* MODULE: Collect software versions
*/
DUMP_SOFTWARE_VERSIONS (
ch_versions.unique().collectFile()
)
/*
* MODULE: Run clipqc
*/
CLIPSEQ_CLIPQC (
ch_bt_log.collect{ it[1] },
ch_star_log.collect{ it[1] },
ch_umi_log.collect{ it[1] },
ch_genome_crosslink_bed.collect{ it[1] },
ICOUNT_ANALYSE.out.bed_peaks.collect{ it[1] },
PARACLU_ANALYSE_GENOME.out.peaks.collect{ it[1] },
CLIPPY_GENOME.out.peaks.collect{ it[1] }
)
/*
* MODULE: Run multiqc
*/
workflow_summary = multiqc_summary(workflow, params)
ch_workflow_summary = Channel.value(workflow_summary)
MULTIQC (
ch_multiqc_config,
DUMP_SOFTWARE_VERSIONS.out.mqc_yml.collect(),
DUMP_SOFTWARE_VERSIONS.out.mqc_unique_yml.collect(),
ch_workflow_summary.collectFile(name: "workflow_summary_mqc.yml"),
FASTQC_TRIMGALORE.out.fastqc_zip.collect{it[1]}.ifEmpty([]),
FASTQC_TRIMGALORE.out.fastqc_trim_zip.collect{it[1]}.ifEmpty([]),
FASTQC_TRIMGALORE.out.trim_log.collect{it[1]}.ifEmpty([]),
ch_bt_log.collect{it[1]}.ifEmpty([]),
ch_star_log.collect{it[1]}.ifEmpty([]),
CLIPSEQ_CLIPQC.out.tsv.collect().ifEmpty([])
)
}
}
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
RUN MAIN WORKFLOW
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
workflow {
CLIPSEQ ()
}
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
COMPLETION EVENTS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
// workflow.onComplete {
// }
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
END
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/