-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmutect2_workflow.nf
More file actions
65 lines (54 loc) · 1.89 KB
/
Copy pathmutect2_workflow.nf
File metadata and controls
65 lines (54 loc) · 1.89 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
include {
splitReference;
mutect2;
mergeVcfAndStatsFiles;
markPassVcfs
} from './mutect2_processes.nf'
include {
mergeVcfFiles;
createPassVcfs;
splitVcfsIntoSnvsAndIndels;
gatkIndexFeature
} from './mutect2_processes.nf'
// main workflow
workflow mutect2Wf {
take:
samples
reference_ch
dict_index
fai_index
main:
// get the coords for the gatk split work
createSplitCoordsWf(reference_ch, dict_index, fai_index, params.gatk_bin_size)
/* Make a big matrix combining all of the needed files and a bed range to pass into each
Mutect2 job. Put all the information into a tuple to cross with the bed entries. */
for_mutect = samples.combine(createSplitCoordsWf.out)
// run the variant calling jobs
split_vcfs = mutect2(for_mutect, reference_ch, dict_index, fai_index)
// collect VCFs from the same samples
collected_vcfs = split_vcfs.groupTuple(by: [0, 1, 2])
// merge and filter the results
merged_vcfs = mergeVcfFiles(collected_vcfs)
marked_vcfs = markPassVcfs(merged_vcfs, reference_ch, fai_index, dict_index)
pass_vcfs = createPassVcfs(marked_vcfs)
index_vcfs = gatkIndexFeature(pass_vcfs)
split_vcfs = splitVcfsIntoSnvsAndIndels(index_vcfs)
emit:
split_vcfs
}
// creates a channel where each entry is the bed coords of a region to use for splitting
workflow createSplitCoordsWf {
take:
reference_ch
dict_index
fai_index
gatk_bin_size
main:
// set up the coordinate ranges
split_bed = splitReference(reference_ch, dict_index, fai_index, gatk_bin_size)
bed_entries = split_bed
.splitCsv(sep: "\t", header: ['chr', 'start', 'end', 'NA1', 'NA2', 'NA3'])
.map{ row -> tuple(row.chr, row.start, row.end) }
emit:
bed_entries
}