@@ -182,7 +182,7 @@ workflow CHIPSEQ {
182182 }
183183
184184 //
185- // SUBWORKFLOW: Alignment with BOWTIE2 & BAM QC
185+ // SUBWORKFLOW: Alignment with Bowtie2 & BAM QC
186186 //
187187 if (params. aligner == ' bowtie2' ) {
188188 ALIGN_BOWTIE2 (
@@ -199,7 +199,7 @@ workflow CHIPSEQ {
199199 }
200200
201201 //
202- // SUBWORKFLOW: Alignment with CHROMAP & BAM QC
202+ // SUBWORKFLOW: Alignment with Chromap & BAM QC
203203 //
204204 if (params. aligner == ' chromap' ) {
205205 ALIGN_CHROMAP (
@@ -210,7 +210,7 @@ workflow CHIPSEQ {
210210
211211 // Filter out paired-end reads until the issue below is fixed
212212 // https://github.com/nf-core/chipseq/issues/291
213- // ch_genome_bam = ALIGN_CHROMAP.out.bam
213+ // ch_genome_bam = ALIGN_CHROMAP.out.bam
214214 ALIGN_CHROMAP
215215 .out
216216 .bam
@@ -220,9 +220,11 @@ workflow CHIPSEQ {
220220 return [ meta, bam ]
221221 paired_end : ! meta. single_end
222222 return [ meta, bam ]
223- }. set { ch_genome_bam_chromap }
223+ }
224+ .set { ch_genome_bam_chromap }
224225
225- ch_genome_bam_chromap. paired_end
226+ ch_genome_bam_chromap
227+ .paired_end
226228 .collect()
227229 .map {
228230 it ->
@@ -264,7 +266,7 @@ workflow CHIPSEQ {
264266 }
265267
266268 //
267- // SUBWORKFLOW : Merge resequenced BAM files
269+ // MODULE : Merge resequenced BAM files
268270 //
269271 ch_genome_bam
270272 .map {
@@ -306,7 +308,7 @@ workflow CHIPSEQ {
306308 ch_versions = ch_versions. mix(FILTER_BAM_BAMTOOLS . out. versions. first(). ifEmpty(null ))
307309
308310 //
309- // MODULE: Library coverage
311+ // MODULE: Preseq coverage analysis
310312 //
311313 ch_preseq_multiqc = Channel . empty()
312314 if (! params. skip_preseq) {
@@ -318,7 +320,7 @@ workflow CHIPSEQ {
318320 }
319321
320322 //
321- // MODULE: Post alignment QC
323+ // MODULE: Picard post alignment QC
322324 //
323325 ch_picardcollectmultiplemetrics_multiqc = Channel . empty()
324326 if (! params. skip_picard_metrics) {
@@ -332,13 +334,16 @@ workflow CHIPSEQ {
332334 }
333335
334336 //
335- // MODULE: Strand cross-correlation
337+ // MODULE: Phantompeaktools strand cross-correlation and QC metrics
336338 //
337339 PHANTOMPEAKQUALTOOLS (
338340 FILTER_BAM_BAMTOOLS . out. bam
339341 )
340342 ch_versions = ch_versions. mix(PHANTOMPEAKQUALTOOLS . out. versions. first())
341343
344+ //
345+ // MODULE: MultiQC custom content for Phantompeaktools
346+ //
342347 MULTIQC_CUSTOM_PHANTOMPEAKQUALTOOLS (
343348 PHANTOMPEAKQUALTOOLS . out. spp. join(PHANTOMPEAKQUALTOOLS . out. rdata, by : [0 ]),
344349 ch_spp_nsc_header,
@@ -347,47 +352,53 @@ workflow CHIPSEQ {
347352 )
348353
349354 //
350- // MODULE: Coverage tracks
355+ // MODULE: BedGraph coverage tracks
351356 //
352357 BEDTOOLS_GENOMECOV (
353358 FILTER_BAM_BAMTOOLS . out. bam. join(FILTER_BAM_BAMTOOLS . out. flagstat, by : [0 ])
354359 )
355360 ch_versions = ch_versions. mix(BEDTOOLS_GENOMECOV . out. versions. first())
356361
357362 //
358- // MODULE: Coverage tracks
363+ // MODULE: BigWig coverage tracks
359364 //
360365 UCSC_BEDGRAPHTOBIGWIG (
361366 BEDTOOLS_GENOMECOV . out. bedgraph,
362367 PREPARE_GENOME . out. chrom_sizes
363368 )
364369 ch_versions = ch_versions. mix(UCSC_BEDGRAPHTOBIGWIG . out. versions. first())
365370
366- //
367- // MODULE: Coverage plots
368- //
369371 ch_deeptoolsplotprofile_multiqc = Channel . empty()
370372 if (! params. skip_plot_profile) {
373+ //
374+ // MODULE: deepTools matrix generation for plotting
375+ //
371376 DEEPTOOLS_COMPUTEMATRIX (
372377 UCSC_BEDGRAPHTOBIGWIG . out. bigwig,
373378 PREPARE_GENOME . out. gene_bed
374379 )
375380 ch_versions = ch_versions. mix(DEEPTOOLS_COMPUTEMATRIX . out. versions. first())
376381
382+ //
383+ // MODULE: deepTools profile plots
384+ //
377385 DEEPTOOLS_PLOTPROFILE (
378386 DEEPTOOLS_COMPUTEMATRIX . out. matrix
379387 )
380388 ch_deeptoolsplotprofile_multiqc = DEEPTOOLS_PLOTPROFILE . out. table
381389 ch_versions = ch_versions. mix(DEEPTOOLS_PLOTPROFILE . out. versions. first())
382390
391+ //
392+ // MODULE: deepTools heatmaps
393+ //
383394 DEEPTOOLS_PLOTHEATMAP (
384395 DEEPTOOLS_COMPUTEMATRIX . out. matrix
385396 )
386397 ch_versions = ch_versions. mix(DEEPTOOLS_PLOTHEATMAP . out. versions. first())
387398 }
388399
389400 //
390- // Refactor channels: [ meta, [ ip_bam, control_bam ] [ ip_bai, control_bai ] ]
401+ // Create channels: [ meta, [ ip_bam, control_bam ] [ ip_bai, control_bai ] ]
391402 //
392403 FILTER_BAM_BAMTOOLS
393404 .out
@@ -404,7 +415,7 @@ workflow CHIPSEQ {
404415 .set { ch_ip_control_bam_bai }
405416
406417 //
407- // plotFingerprint for IP and control together
418+ // MODULE: deepTools plotFingerprint joint QC for IP and control
408419 //
409420 ch_deeptoolsplotfingerprint_multiqc = Channel . empty()
410421 if (! params. skip_plot_fingerprint) {
@@ -416,7 +427,7 @@ workflow CHIPSEQ {
416427 }
417428
418429 //
419- // Call peaks
430+ // MODULE: Calculute genome size with khmer
420431 //
421432 ch_macs_gsize = Channel . empty()
422433 ch_custompeaks_frip_multiqc = Channel . empty()
@@ -432,30 +443,33 @@ workflow CHIPSEQ {
432443 ch_macs_gsize = KHMER_UNIQUEKMERS . out. kmers. map { it. text. trim() }
433444 }
434445
435- // Create channel : [ meta, ip_bam, control_bam ]
446+ // Create channels : [ meta, ip_bam, control_bam ]
436447 ch_ip_control_bam_bai
437448 .map {
438449 meta, bams, bais ->
439450 [ meta , bams[0 ], bams[1 ] ]
440451 }
441452 .set { ch_ip_control_bam }
442453
454+ //
455+ // MODULE: Call peaks with MACS2
456+ //
443457 MACS2_CALLPEAK (
444458 ch_ip_control_bam,
445459 ch_macs_gsize
446460 )
447461 ch_versions = ch_versions. mix(MACS2_CALLPEAK . out. versions. first())
448462
449463 //
450- // Filter for MACS2 files without peaks
464+ // Filter out samples with 0 MACS2 peaks called
451465 //
452466 MACS2_CALLPEAK
453467 .out
454468 .peak
455469 .filter { meta, peaks -> peaks. size() > 0 }
456470 .set { ch_macs2_peaks }
457471
458- // Create channel : [ meta, ip_bam, peaks ]
472+ // Create channels : [ meta, ip_bam, peaks ]
459473 ch_ip_control_bam
460474 .join(ch_macs2_peaks, by : [0 ])
461475 .map {
@@ -464,12 +478,15 @@ workflow CHIPSEQ {
464478 }
465479 .set { ch_ip_bam_peaks }
466480
481+ //
482+ // MODULE: Calculate FRiP score
483+ //
467484 FRIP_SCORE (
468485 ch_ip_bam_peaks
469486 )
470487 ch_versions = ch_versions. mix(FRIP_SCORE . out. versions. first())
471488
472- // Create channel : [ meta, peaks, frip ]
489+ // Create channels : [ meta, peaks, frip ]
473490 ch_ip_bam_peaks
474491 .join(FRIP_SCORE . out. txt, by : [0 ])
475492 .map {
@@ -478,6 +495,9 @@ workflow CHIPSEQ {
478495 }
479496 .set { ch_ip_peaks_frip }
480497
498+ //
499+ // MODULE: FRiP score custom content for MultiQC
500+ //
481501 MULTIQC_CUSTOM_PEAKS (
482502 ch_ip_peaks_frip,
483503 ch_peak_count_header,
@@ -487,6 +507,9 @@ workflow CHIPSEQ {
487507 ch_custompeaks_count_multiqc = MULTIQC_CUSTOM_PEAKS . out. count
488508
489509 if (! params. skip_peak_annotation) {
510+ | //
511+ // MODULE: Annotate peaks with MACS2
512+ //
490513 HOMER_ANNOTATEPEAKS_MACS2 (
491514 ch_macs2_peaks,
492515 PREPARE_GENOME . out. fasta,
@@ -495,11 +518,17 @@ workflow CHIPSEQ {
495518 ch_versions = ch_versions. mix(HOMER_ANNOTATEPEAKS_MACS2 . out. versions. first())
496519
497520 if (! params. skip_peak_qc) {
521+ //
522+ // MODULE: MACS2 QC plots with R
523+ //
498524 PLOT_MACS2_QC (
499525 ch_macs2_peaks. collect{it[1 ]}
500526 )
501527 ch_versions = ch_versions. mix(PLOT_MACS2_QC . out. versions)
502528
529+ //
530+ // MODULE: Peak annotation QC plots with R
531+ //
503532 PLOT_HOMER_ANNOTATEPEAKS (
504533 HOMER_ANNOTATEPEAKS_MACS2 . out. txt. collect{it[1 ]},
505534 ch_peak_annotation_header,
@@ -517,7 +546,7 @@ workflow CHIPSEQ {
517546 ch_deseq2_pca_multiqc = Channel . empty()
518547 ch_deseq2_clustering_multiqc = Channel . empty()
519548 if (! params. skip_consensus_peaks) {
520- // Create channel : [ meta , [ peaks ] ]
549+ // Create channels : [ meta , [ peaks ] ]
521550 // Where meta = [ id:antibody, multiple_groups:true/false, replicates_exist:true/false ]
522551 ch_macs2_peaks
523552 .map {
@@ -543,27 +572,36 @@ workflow CHIPSEQ {
543572 }
544573 .set { ch_antibody_peaks }
545574
575+ //
576+ // MODULE: Generate consensus peaks across samples
577+ //
546578 MACS2_CONSENSUS (
547579 ch_antibody_peaks
548580 )
549581 ch_macs2_consensus_bed_lib = MACS2_CONSENSUS . out. bed
550582 ch_versions = ch_versions. mix(MACS2_CONSENSUS . out. versions)
551583
552584 if (! params. skip_peak_annotation) {
585+ //
586+ // MODULE: Annotate consensus peaks
587+ //
553588 HOMER_ANNOTATEPEAKS_CONSENSUS (
554589 MACS2_CONSENSUS . out. bed,
555590 PREPARE_GENOME . out. fasta,
556591 PREPARE_GENOME . out. gtf
557592 )
558593 ch_versions = ch_versions. mix(HOMER_ANNOTATEPEAKS_CONSENSUS . out. versions)
559594
595+ //
596+ // MODULE: Add boolean fields to annotated consensus peaks to aid filtering
597+ //
560598 ANNOTATE_BOOLEAN_PEAKS (
561599 MACS2_CONSENSUS . out. boolean_txt. join(HOMER_ANNOTATEPEAKS_CONSENSUS . out. txt, by : [0 ]),
562600 )
563601 ch_versions = ch_versions. mix(ANNOTATE_BOOLEAN_PEAKS . out. versions)
564602 }
565603
566- // Create channel : [ antibody, [ ip_bams ] ]
604+ // Create channels : [ antibody, [ ip_bams ] ]
567605 ch_ip_control_bam
568606 .map {
569607 meta, ip_bam, control_bam ->
@@ -572,7 +610,7 @@ workflow CHIPSEQ {
572610 .groupTuple()
573611 .set { ch_antibody_bams }
574612
575- // Create channel : [ meta, [ ip_bams ], saf ]
613+ // Create channels : [ meta, [ ip_bams ], saf ]
576614 MACS2_CONSENSUS
577615 .out
578616 .saf
@@ -587,13 +625,19 @@ workflow CHIPSEQ {
587625 }
588626 .set { ch_saf_bams }
589627
628+ //
629+ // MODULE: Quantify peaks across samples with featureCounts
630+ //
590631 SUBREAD_FEATURECOUNTS (
591632 ch_saf_bams
592633 )
593634 ch_subreadfeaturecounts_multiqc = SUBREAD_FEATURECOUNTS . out. summary
594635 ch_versions = ch_versions. mix(SUBREAD_FEATURECOUNTS . out. versions. first())
595636
596637 if (! params. skip_deseq2_qc) {
638+ //
639+ // MODULE: Generate QC plots with DESeq2
640+ //
597641 DESEQ2_QC (
598642 SUBREAD_FEATURECOUNTS . out. counts,
599643 ch_deseq2_pca_header,
@@ -605,7 +649,7 @@ workflow CHIPSEQ {
605649 }
606650
607651 //
608- // Create IGV session
652+ // MODULE: Create IGV session
609653 //
610654 if (! params. skip_igv) {
611655 IGV (
0 commit comments