-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.nf
More file actions
1607 lines (1321 loc) · 50 KB
/
main.nf
File metadata and controls
1607 lines (1321 loc) · 50 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
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env nextflow
nextflow.enable.dsl=2
// set up and create an output directory
outdir = file(params.outdir)
outdir.mkdir()
nextflow_version="v.0.1"
// default behaviour is to NOT:
// run rapidCNS2 classifier
// run sturgeon classifier
// run nanoDx classifier
// run NanoPlot
// default the various optional parameters to false
params.rapidcns2 = false
params.sturgeon = false
params.nanoplot = false
params.nanodx = false
log.info """\
================================================================
SCARLET - Nextflow P I P E L I N E ${nextflow_version}
================================================================
INPUTS
================================================================
sample : ${params.sample}
input_bam : ${params.bam}
outdir : ${params.outdir}
reference : ${params.reference}
annotations : ${params.annotations}
threads : ${params.threads}
bam_min_coverage : ${params.bam_min_coverage}
min_mgmt_coverage : ${params.minimum_mgmt_cov}
rapidcns2 : ${params.rapidcns2}
sturgeon : ${params.sturgeon}
nanoplot : ${params.nanoplot}
nanodx : ${params.nanodx}
================================================================
To run with SLURM, add -process.executor='slurm' to your nextflow command.
================================================================
"""
.stripIndent()
process get_versions {
input:
output:
path "software_versions1.txt", emit: versions_file1
script:
"""
echo -e "Package and version" > software_versions1.txt
samtools --version | head -n 1 >> software_versions1.txt
/modkit --version >> software_versions1.txt
NanoPlot -v >> software_versions1.txt
/mosdepth --version -v >> software_versions1.txt
python3 /methylartist/methylartist -v >> software_versions1.txt
bcftools -v | head -n 1 >> software_versions1.txt
echo "clairS_to v0.1.0" >> software_versions1.txt
echo "igv_reports v1.12.0" >> software_versions1.txt
echo "cnvpytor v1.3.1" >> software_versions1.txt
vcftools | head -n 2 | tail -n 1 >> software_versions1.txt
pigz -V >> software_versions1.txt
gzip -V | head -n 1 >> software_versions1.txt
/annovar/convert2annovar.pl | grep Version | sed 's/^/annovar: /; s/,//g' >> "software_versions1.txt"
R --version | head -n 1 >> software_versions1.txt
source /sturgeon-0.4.4/venv/bin/activate
sturgeon -v >> software_versions1.txt
deactivate
echo "nanoDx - TODO" >> software_versions1.txt
"""
}
process get_versions_outside_docker {
input:
output:
path "software_versions2.txt", emit: versions_file2
script:
"""
docker -v | sed 's/,//g' > "software_versions2.txt"
nextflow -v >> software_versions2.txt
nextflow run epi2me-labs/wf-human-variation | grep '^Launching' | awk '{for (i=1; i<=NF; i++) if (\$i ~ /^revision:/) print "epi2me-labs/wf-human-variation " \$i " " \$(i+1)}' >> software_versions2.txt
"""
}
process merge_versions_files {
input:
path(versions_file1)
path(versions_file2)
output:
path "all_software_versions.txt", emit: versions_file
script:
"""
cat \
${versions_file1} \
${versions_file2} \
> all_software_versions.txt
"""
}
process check_bam_has_meth_data {
input:
path(input_bam)
val(threads)
output:
stdout emit: meth_check
script:
"""
samtools \
view \
-@${threads} \
${input_bam} \
| grep -m 1 MM:Z
"""
}
process modkit_adjust_mods {
input:
path(input_bam)
val(sample)
val(threads)
output:
path "*_modkit_merge.bam", emit: modkit_merged_bam
script:
"""
/modkit \
adjust-mods \
--convert h m \
${input_bam} \
${sample}_modkit_merge.bam \
--threads ${threads}
"""
}
process index_input_bam {
input:
path(input_bam)
val(threads)
output:
path "*.bai", emit: indexed_bam
tuple path(input_bam), path("*.bai"), emit: indexed_bam_tuple
script:
"""
samtools \
index \
-@${threads} \
${input_bam}
"""
}
process index_merged_bam {
input:
path(input_bam)
val(threads)
output:
tuple path(input_bam), path("*.bai"), emit: indexed_bam
script:
"""
samtools \
index \
-@${threads} \
${input_bam}
"""
}
process nanoplot {
input:
path(input_bam)
val(threads)
val(sample)
path(indexed_bam)
publishDir("${params.outdir}", mode: 'copy')
output:
path "*NanoPlot-report.html", emit: nanoplot
script:
"""
NanoPlot \
-t ${threads} \
--bam ${input_bam} \
-p ${sample}
"""
}
process check_mgmt_coverage {
input:
path(input_bam)
path(mgmt_bed)
val(minimum_mgmt_coverage)
path(indexed_bam)
val(threads)
output:
stdout emit: mgmt_avg_cov
script:
"""
/mosdepth \
-t ${threads} \
-n \
--by ${mgmt_bed} \
mgmt_cov ${input_bam}
cov="\$(grep "^chr10_region" mgmt_cov.mosdepth.summary.txt | awk '{ print \$4 }')"
echo \${cov}
"""
}
process draw_mgmt_methylartist {
maxRetries 3
errorStrategy { (task.attempt <= maxRetries) ? 'retry' : 'ignore' }
input:
tuple path(bam), path(bai)
path(reference)
val(params.outdir)
val(mgmt_avg_cov)
val(minimum_mgmt_coverage)
output:
path "*.png", emit: mgmt_plot optional true
script:
if ( mgmt_avg_cov.toFloat() > minimum_mgmt_coverage.toFloat() )
"""
python3 /methylartist/methylartist \
locus \
-i chr10:129466536-129467536 \
-b ${bam} \
--ref ${reference} \
--motif CG \
--mods m
"""
else
"""
echo "dummy_file" > dummy_plot.png
"""
}
process mosdepth {
input:
val(threads)
path(targets)
path(input_bam)
val(sample)
path(indexed_bam)
output:
path "*.mosdepth.summary.txt", emit: mosdepth_out
script:
"""
/mosdepth \
-t ${threads} \
-n \
--by ${targets} \
--fast-mode \
${sample} \
${input_bam}
"""
}
process index_subsetted_bam {
input:
path(input_bam)
val(threads)
output:
tuple path(input_bam), path("*.bai"), emit: subsetted_bam_index
val(true)
script:
"""
samtools \
index \
-@${threads} \
${input_bam}
"""
}
process human_variation_mods {
input:
tuple path(merged_bam), path(bai)
path(targets_bed)
path(reference)
val(sample)
val(outdir)
val(bam_min_coverage)
val(threads)
output:
path("*/*wf_mods.bedmethyl.gz"), emit: bedmethyl_gz
script:
"""
nextflow run epi2me-labs/wf-human-variation -r master \
-profile standard \
--ref ${reference} \
--mod \
--bam ${merged_bam} \
--bed ${targets_bed} \
--sample_name ${sample} \
--bam_min_coverage ${bam_min_coverage} \
--threads ${threads} \
"""
}
process human_variation_cnv {
// must use --use_qdnaseq for the CNV module as SPECTRE not suitable
// for data generated by adaptive sampling
// see https://github.com/epi2me-labs/wf-human-variation/issues/198
// low depth of coverage will cause this module to fail - not handled gracefully by the sub-workflow
// other than providing the CNV report, the outputs are not used and so errors can be ignored
errorStrategy 'ignore'
input:
path(input_bam)
path(targets_bed)
path(reference)
val(sample)
val(outdir)
val(bam_min_coverage)
val(threads)
publishDir("${params.outdir}", mode: 'copy')
output:
path("*/*wf-human-cnv-report.html"), emit: human_variation_cnv_report
script:
"""
nextflow run epi2me-labs/wf-human-variation -r master \
-profile standard \
--ref ${reference} \
--cnv \
--use_qdnaseq \
--bam ${input_bam} \
--out_dir wf-human-variation_reports \
--bed ${targets_bed} \
--sample_name ${sample} \
--bam_min_coverage ${bam_min_coverage} \
--threads ${threads}
"""
}
process human_variation_sv {
input:
path(input_bam)
path(targets_bed)
path(reference)
val(sample)
val(outdir)
val(bam_min_coverage)
path(indexed_bam)
val(threads)
publishDir("${params.outdir}", mode: 'copy')
output:
path("*/*wf-human-sv-report.html"), emit: human_variation_sv_report
script:
"""
nextflow run epi2me-labs/wf-human-variation -r master \
-profile standard \
--ref ${reference} \
--sv \
--bam ${input_bam} \
--bed ${targets_bed} \
--sample_name ${sample} \
--out_dir wf-human-variation_reports \
--bam_min_coverage ${bam_min_coverage} \
--threads ${threads} \
--sniffles_args="--non-germline"
"""
}
process subset_bam_by_bed {
input:
path(input_bam)
path(input_bed)
val(sample)
val(threads)
output:
path "*subset.bam", emit: subsetted_bam
script:
"""
samtools view -@{threads} \
-b \
-h \
-L ${input_bed} \
${input_bam} \
> ${sample}_subset.bam
"""
}
process get_wanted_read_ids {
input:
path(subset_bam)
val(threads)
output:
path "temp_ids.txt", emit: wanted_ids
script:
"""
samtools \
view \
-@${threads} \
${subset_bam} \
| cut -f 1 \
> temp_ids.txt
"""
}
process add_suppl_alignments_to_subset {
input:
path(subset_bam)
path(input_bam)
val(threads)
val(sample)
path(list_of_ids)
output:
path "*_subset.suppl.bam", emit: suppl_subset_bam
script:
"""
samtools \
view \
-@${threads} \
-h \
-f 2048 \
-N ${list_of_ids} \
${input_bam} \
| samtools \
merge \
-@${threads} \
-o ${sample}_subset.suppl.bam \
${subset_bam} \
-
"""
}
process index_suppl_subset_bam {
input:
path(input_bam)
val(threads)
output:
path "*.bai", emit: suppl_subset_indexed_bam
script:
"""
samtools \
index \
-@${threads} \
${input_bam}
"""
}
process human_variation_snp {
input:
path(input_bam)
path(targets_bed)
path(reference)
val(sample)
val(outdir)
val(bam_min_coverage)
val(threads)
publishDir("${params.outdir}", mode: 'copy', pattern: 'wf-human-variation_reports/*wf-human-snp-report.html')
output:
path("*/*wf-human-snp-report.html"), emit: human_variation_snp_report
path("*/*wf_snp.vcf.gz"), emit: human_variation_snp_vars
script:
"""
nextflow run epi2me-labs/wf-human-variation -r master \
-profile standard \
--ref ${reference} \
--snp \
--bam ${input_bam} \
--bed ${targets_bed} \
--sample_name ${sample} \
--bam_min_coverage ${bam_min_coverage} \
--out_dir wf-human-variation_reports \
--threads ${threads}
"""
}
process index_reference {
input:
path(reference)
output:
tuple path(reference), path("*.fai"), emit: reference_index
script:
"""
samtools faidx ${reference}
"""
}
process clairS_to_variants {
input:
tuple path(subsetted_bam), path(bai)
tuple path(reference), path(fai)
val(params.outdir)
val(threads)
output:
path("*/snv.vcf.gz"), emit: clairS_snv
path("*/indel.vcf.gz"), emit: clairS_indel
script:
"""
/opt/bin/run_clairs_to \
--tumor_bam ${subsetted_bam} \
--ref_fn ${reference} \
--threads ${threads} \
--platform ont_r10_guppy_hac_5khz \
--output_dir clairS_to_output
"""
}
process filter_to_somatic_variants_only {
input:
path(clairS_snv)
path(clairS_indel)
output:
path("snv.somatic.vcf.gz"), emit: clairS_somatic_snv
path("indel.somatic.vcf.gz"), emit: clairS_somatic_indel
script:
"""
bcftools view \
-f PASS \
${clairS_snv} \
| gzip > snv.somatic.vcf.gz
bcftools view \
-f PASS \
${clairS_indel} \
| gzip > indel.somatic.vcf.gz
"""
}
process igv_reports {
input:
path(clair3_report) // filter-report output
path(somatic_clair3_report) // filter-report somatic output
val(sample)
path(reference)
path(input_bam)
path(indexed_bam)
path(annotations)
output:
path("*_igv-report.html"), emit: igv_report
script:
"""
echo -e "Chr\tStart\tEnd\tFunc\tGene\tExonicFunc\tAAChange\tcytoBand\t1000g_EUR\tMUTATION_CLASS" > ${sample}_clair3_report.merged.csv
if [ -f ${somatic_clair3_report} ]; then
sed -e 's/,/\t/g' -e 's/\"//g' ${sample}_somatic_clair3_report.csv > ${sample}_somatic_clair3_report.fmt.csv
awk 'BEGIN {FS=OFS="\\t"} NR==1 {\$0=\$0 OFS "MUTATION_CLASS"} NR>1 {\$(NF+1)="SOMATIC"}1' ${sample}_somatic_clair3_report.fmt.csv > ${sample}_somatic_clair3_report.new.fmt.csv
sed 1,1d ${sample}_somatic_clair3_report.new.fmt.csv >> ${sample}_clair3_report.merged.csv
fi
if [ -f ${clair3_report} ]; then
sed -e 's/,/\t/g' -e 's/\"//g' ${sample}_clair3_report.csv > ${sample}_clair3_report.fmt.csv
awk 'BEGIN {FS=OFS="\\t"} NR==1 {\$0=\$0 OFS "MUTATION_CLASS"} NR>1 {\$(NF+1)="ALL"}1' ${sample}_clair3_report.fmt.csv > ${sample}_clair3_report.new.fmt.csv
sed 1,1d ${sample}_clair3_report.new.fmt.csv >> ${sample}_clair3_report.merged.csv
fi
if [ -f ${sample}_clair3_report.merged.csv ]; then
create_report ${sample}_clair3_report.merged.csv \
--fasta ${reference} \
--sequence 1 \
--begin 2 \
--end 3 \
--flanking 1000 \
--info-columns Chr Start End Func Gene ExonicFunc AAChange cytoBand 1000g_EUR MUTATION_CLASS \
--output ${sample}_igv-report.html \
--standalone \
--tracks ${input_bam} ${annotations}
fi
"""
}
process cnvpytor {
input:
val(sample)
path(input_bam)
val(threads)
output:
path("*_cnvpytor_100k.global.0000.png"), emit: cnv_plot
script:
"""
cnvpytor -root ${sample}_CNV.pytor -rd ${input_bam.toRealPath()} -j ${threads}
cnvpytor -root ${sample}_CNV.pytor -his 1000 10000 100000 -j ${threads}
cnvpytor -root ${sample}_CNV.pytor -partition 1000 10000 100000 -j ${threads}
cnvpytor -root ${sample}_CNV.pytor -call 1000 -j ${threads} > ${sample}.cnvpytor.calls.1000.tsv
cnvpytor -root ${sample}_CNV.pytor -call 10000 -j ${threads} > ${sample}.cnvpytor.calls.10000.tsv
cnvpytor -root ${sample}_CNV.pytor -call 100000 -j ${threads} > ${sample}.cnvpytor.calls.100000.tsv
cnvpytor -root ${sample}_CNV.pytor -plot manhattan 100000 -chrom chr1 chr2 chr3 chr4 chr5 chr6 chr7 chr8 chr9 chr10 chr11 chr12 chr13 chr14 chr15 chr16 chr17 chr18 chr19 chr20 chr21 chr22 chrX chrY -o ${sample}_cnvpytor_100k.png
"""
}
process vcftools {
maxRetries 3
errorStrategy { sleep(Math.pow(2, task.attempt) * 200 as long); return 'retry' }
input:
path(human_variation_vars) // human-variation SNP module
val(sample)
output:
path "*.vcf", emit: variants_out
script:
"""
vcftools \
--gzvcf ${human_variation_vars} \
--remove-filtered-all \
--recode \
--out ${sample}
"""
}
process vcftools_somatic {
maxRetries 3
errorStrategy { sleep(Math.pow(2, task.attempt) * 200 as long); return 'retry' }
input:
path(somatic_snv) // filtered snvs
path(somatic_indel) // filtered indels
val(sample)
output:
path "*snv.recode.vcf", emit: snv_somatic_variants_out
path "*indel.recode.vcf", emit: indel_somatic_variants_out
script:
"""
vcftools \
--gzvcf ${somatic_snv} \
--remove-filtered-all \
--recode \
--out ${sample}_snv
vcftools \
--gzvcf ${somatic_indel} \
--remove-filtered-all \
--recode \
--out ${sample}_indel
"""
}
process gzip {
input:
path(input_file)
output:
path "*.gz", emit: compressed_out
script:
"""
pigz \
-1 \
-c \
${input_file} \
> ${input_file}.gz
"""
}
process gzip_somatic {
input:
path(input_file_snv)
path(input_file_indel)
output:
path "*snv.recode.vcf.gz", emit: snv_compressed_out
path "*indel.recode.vcf.gz", emit: indel_compressed_out
script:
"""
pigz \
-1 \
-c \
${input_file_snv} \
> ${input_file_snv}.gz
cat ${input_file_indel} \
| grep -v ^# \
| gzip \
> ${input_file_indel}.gz
"""
}
process merge_somatic_snvs_and_indels {
input:
path(somatic_snvs)
path(somatic_indels)
val(sample)
output:
path "*all.somatic.recode.vcf.gz", emit: all_compressed_out
script:
"""
cat ${somatic_snvs} ${somatic_indels} > ${sample}.all.somatic.recode.vcf.gz
"""
}
process bedtools_intersect {
input:
path(input1)
path(input2)
val(output_file)
val(ext)
output:
path "*.vcf", emit: intersect_vcf
script:
"""
bedtools \
intersect \
-a ${input1} \
-b ${input2} > ${output_file}${ext}
"""
}
process bedtools_intersect_somatic {
input:
path(somatic_vars) // merged somatic snvs and indels
path(input2)
val(output_file)
val(ext)
output:
path "*.vcf", emit: intersect_vcf
script:
"""
bedtools intersect -a ${somatic_vars} -b ${input2} > ${output_file}${ext}
"""
}
process convert2annovar {
input:
path(input)
val(output_file)
val(ext)
output:
path "*.avinput", emit: annovar_input
script:
"""
/annovar/convert2annovar.pl \
-format vcf4 ${input} \
-withfreq \
-includeinfo \
> ${output_file}${ext}
"""
}
process convert2annovar_somatic {
input:
path(input)
val(output_file)
val(ext)
output:
path "*.avinput", emit: annovar_input
script:
"""
/annovar/convert2annovar.pl \
-format vcf4 ${input} \
-withfreq \
-includeinfo \
> ${output_file}${ext}
"""
}
process table_annovar {
input:
path(input)
val(annovar_ver)
val(output_file)
val(ext)
val(threads)
output:
path "*_multianno.csv", emit: clair3_output
script:
"""
/annovar/table_annovar.pl ${input} \
/annovar/humandb/ \
-buildver ${annovar_ver} \
-out ${output_file}${ext} \
-protocol refGene,cytoBand,avsnp147,dbnsfp30a,1000g2015aug_eur \
-operation gx,r,f,f,f \
-nastring . \
-csvout \
-polish \
-otherinfo \
-thread ${threads}
"""
}
process table_annovar_somatic {
input:
path(input)
val(annovar_ver)
val(output_file)
val(ext)
val(threads)
output:
path "*_somatic_clair3_panel.hg38_multianno.csv", emit: somatic_clair3_output
script:
"""
/annovar/table_annovar.pl ${input} \
/annovar/humandb/ \
-buildver ${annovar_ver} \
-out ${output_file}_somatic_${ext} \
-protocol refGene,cytoBand,avsnp147,dbnsfp30a,1000g2015aug_eur,cosmic70 \
-operation gx,r,f,f,f,f \
-nastring . \
-csvout \
-polish \
-otherinfo \
-thread ${threads}
"""
}
process bedtools_intersect2 {
input:
path(bed_methyl) // filtered bedmethyl file from filter to just 5mC
path(input2)
val(output_file)
val(ext)
val(sample)
output:
path "*.bed", emit: intersect_bed
script:
"""
bedtools \
intersect \
-a ${bed_methyl} \
-b ${input2} > ${output_file}.${ext}
"""
}
process mgmt_pred {
input:
path(mgmt_pred)
file(intersect_bed)
path(probes)
path(model)
val(sample)
val(threads)
val(mgmt_avg_cov)
val(minimum_mgmt_coverage)
output:
path "*mgmt_status.csv", emit: mgmt_status
script:
if ( mgmt_avg_cov.toFloat() > minimum_mgmt_coverage.toFloat() )
"""
Rscript ${mgmt_pred} \
--input ${intersect_bed} \
--probes ${probes} \
--model ${model} \
--sample ${sample} \
--threads ${threads}
"""
else
"""
echo "NA" > low_cov_mgmt_status.csv
"""
}
process rapid_cns2_meth_classification {
input:
path(meth_class)
val(sample)
path(topprobes)
path(trainingdata)
path(arrayfile)
val(threads)
path(bed_methyl) // output from human-variation mods
output:
path "*rf_details.tsv", emit: rf_details
path "*votes.tsv", emit: votes
script:
"""
Rscript ${meth_class} \
--sample ${sample} \
--in_file ${bed_methyl} \
--probes ${topprobes} \
--training_data ${trainingdata} \
--array_file ${arrayfile} \
--threads ${threads}
"""
}
process filter_report {
errorStrategy { sleep(Math.pow(2, task.attempt) * 200 as long); return 'retry' }
maxRetries 3
input:
path(filterreport)
path(clair3_multianno)
val(sample)
val(params.outdir)
output:
path "*_clair3_report.csv", emit: clair3_report_csv
script:
"""
Rscript ${filterreport} \
--input ${clair3_multianno} \
--sample ${sample} > ${sample}_clair3_report.csv \
--output ${sample}_clair3_report.csv
"""
}
process filter_report_somatic {
errorStrategy { sleep(Math.pow(2, task.attempt) * 200 as long); return 'retry' }
maxRetries 3
input:
path(filterreport)
path(clair3_multianno)
val(sample)
val(params.outdir)
output:
path "*_clair3_report.csv", emit: somatic_clair3_report_csv
script:
"""
Rscript ${filterreport} \
--input ${clair3_multianno} \
--sample ${sample} > ${sample}_somatic_clair3_report.csv \
--output ${sample}_somatic_clair3_report.csv
"""
}
process find_seq_platform {
input:
path(find_seq_platform_py)
path(input_bam)
output:
stdout emit: seq_platform
script:
"""
platform=\$(python3 ${find_seq_platform_py} -i ${input_bam})
echo -n "\$platform"
"""