-
Notifications
You must be signed in to change notification settings - Fork 1
/
somatic-variantcalling.wdl
324 lines (301 loc) · 15 KB
/
somatic-variantcalling.wdl
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
version 1.0
# Copyright (c) 2018 Leiden University Medical Center
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
import "mutect2.wdl" as mutect2Workflow
import "tasks/gatk.wdl" as gatk
import "tasks/samtools.wdl" as samtools
import "tasks/somaticseq.wdl" as somaticSeqTask
import "strelka.wdl" as strelkaWorkflow
import "structs.wdl" as structs
import "vardict.wdl" as vardictWorkflow
workflow SomaticVariantcalling {
input {
String outputDir = "."
File referenceFasta
File referenceFastaFai
File referenceFastaDict
String tumorSample
File tumorBam
File tumorBamIndex
String? controlSample
File? controlBam
File? controlBamIndex
TrainingSet? trainingSet
File? regions
File? variantsForContamination
File? variantsForContaminationIndex
File? sitesForContamination
File? sitesForContaminationIndex
Boolean runStrelka = true
Boolean runVardict = true
Boolean runMutect2 = true
Boolean runManta = true
Boolean runCombineVariants = false
Map[String, String] dockerImages = {
"picard":"quay.io/biocontainers/picard:2.23.2--0",
"gatk4": "quay.io/biocontainers/gatk4:4.1.8.0--py38h37ae868_0",
"chunked-scatter": "quay.io/biocontainers/chunked-scatter:1.0.0--py_0",
"tabix":"quay.io/biocontainers/tabix:0.2.6--ha92aebf_0",
"manta": "quay.io/biocontainers/manta:1.4.0--py27_1",
"strelka": "quay.io/biocontainers/strelka:2.9.7--0",
"vardict-java": "quay.io/biocontainers/vardict-java:1.5.8--1",
"somaticseq": "lethalfang/somaticseq:3.1.0",
"samtools": "quay.io/biocontainers/samtools:1.10--h9402c20_2"
}
IndexedVcfFile? DONOTDEFINETHIS #FIXME
}
String mutect2Dir = outputDir + "/mutect2"
String strelkaDir = outputDir + "/strelka"
String vardictDir = outputDir + "/vardict"
String somaticSeqDir = outputDir + "/somaticSeq"
if (runMutect2) {
call mutect2Workflow.Mutect2 as mutect2 {
input:
tumorSample = tumorSample,
tumorBam = tumorBam,
tumorBamIndex = tumorBamIndex,
controlSample = controlSample,
controlBam = controlBam,
controlBamIndex = controlBamIndex,
referenceFasta = referenceFasta,
referenceFastaFai = referenceFastaFai,
referenceFastaDict = referenceFastaDict,
outputDir = mutect2Dir,
regions = regions,
variantsForContamination = variantsForContamination,
variantsForContaminationIndex = variantsForContaminationIndex,
sitesForContamination = sitesForContamination,
sitesForContaminationIndex = sitesForContaminationIndex,
dockerImages = dockerImages
}
}
if (runStrelka) {
call strelkaWorkflow.Strelka as strelka {
input:
controlBam = controlBam,
controlBamIndex = controlBamIndex,
tumorBam = tumorBam,
tumorBamIndex = tumorBamIndex,
referenceFasta = referenceFasta,
referenceFastaFai = referenceFastaFai,
referenceFastaDict = referenceFastaDict,
outputDir = strelkaDir,
basename = if defined(controlBam)
then "${tumorSample}-${controlSample}"
else tumorSample,
runCombineVariants = runCombineVariants,
runManta = runManta,
regions = regions,
dockerImages = dockerImages
}
}
if (runVardict) {
call vardictWorkflow.VarDict as vardict {
input:
tumorSample = tumorSample,
tumorBam = tumorBam,
tumorBamIndex = tumorBamIndex,
controlSample = controlSample,
controlBam = controlBam,
controlBamIndex = controlBamIndex,
referenceFasta = referenceFasta,
referenceFastaFai = referenceFastaFai,
referenceFastaDict = referenceFastaDict,
outputDir = vardictDir,
regions = regions,
dockerImages = dockerImages
}
}
if (runCombineVariants && runVardict &&
runMutect2 && defined(strelka.combinedVcf) && runStrelka) {
call gatk.CombineVariants as combineVariants {
input:
referenceFasta = referenceFasta,
referenceFastaFai = referenceFastaFai,
referenceFastaDict = referenceFastaDict,
identifiers = ["mutect2", "varDict", "Strelka"],
variantVcfs = select_all([mutect2.outputVcf, vardict.outputVcf, strelka.combinedVcf]),
variantIndexes = select_all([mutect2.outputVcfIndex, vardict.outputVcfIndex, strelka.combinedVcfIndex]),
outputPath = outputDir + "/combined-VCFs/combined_vcfs.vcf.gz"
}
}
if (defined(trainingSet) && defined(controlBam)) {
#FIXME workaround for faulty 'no such field' errors which occur when a Struct is optional
TrainingSet trainSetPaired = select_first([trainingSet])
call somaticSeqTask.ParallelPairedTrain as pairedTraining {
input:
truthSNV = trainSetPaired.truthSNV,
truthIndel = trainSetPaired.truthIndel,
outputDir = somaticSeqDir + "/train",
referenceFasta = referenceFasta,
referenceFastaFai = referenceFastaFai,
inclusionRegion = regions,
tumorBam = trainSetPaired.tumorBam,
tumorBamIndex = trainSetPaired.tumorBamIndex,
normalBam = select_first([trainSetPaired.normalBam]),
normalBamIndex = select_first([trainSetPaired.normalBamIndex]),
mutect2VCF = trainSetPaired.mutect2VCF,
varscanSNV = trainSetPaired.varscanSNV,
varscanIndel = trainSetPaired.varscanIndel,
jsmVCF = trainSetPaired.jsmVCF,
somaticsniperVCF = trainSetPaired.somaticsniperVCF,
vardictVCF = trainSetPaired.vardictVCF,
museVCF = trainSetPaired.museVCF,
lofreqSNV = trainSetPaired.lofreqSNV,
lofreqIndel = trainSetPaired.lofreqIndel,
scalpelVCF = trainSetPaired.scalpelVCF,
strelkaSNV = trainSetPaired.strelkaSNV,
strelkaIndel = trainSetPaired.strelkaIndel,
dockerImage = dockerImages["somaticseq"]
}
}
if (defined(controlBam)) {
call somaticSeqTask.ParallelPaired as pairedSomaticSeq {
input:
classifierSNV = pairedTraining.ensembleSNVClassifier,
classifierIndel = pairedTraining.ensembleIndelsClassifier,
outputDir = somaticSeqDir,
referenceFasta = referenceFasta,
referenceFastaFai = referenceFastaFai,
inclusionRegion = regions,
tumorBam = tumorBam,
tumorBamIndex = tumorBamIndex,
normalBam = select_first([controlBam]),
normalBamIndex = select_first([controlBamIndex]),
mutect2VCF = mutect2.outputVcf,
vardictVCF = vardict.outputVcf,
strelkaSNV = strelka.variantsVcf,
strelkaIndel = strelka.indelsVcf,
dockerImage = dockerImages["somaticseq"]
}
}
if (defined(trainingSet) && !defined(controlBam)) {
#FIXME workaround for faulty 'no such field' errors which occur when a Struct is optional
TrainingSet trainSetSingle = select_first([trainingSet])
call somaticSeqTask.ParallelSingleTrain as singleTraining {
input:
truthSNV = trainSetSingle.truthSNV,
truthIndel = trainSetSingle.truthIndel,
outputDir = somaticSeqDir + "/train",
referenceFasta = referenceFasta,
referenceFastaFai = referenceFastaFai,
inclusionRegion = regions,
bam = trainSetSingle.tumorBam,
bamIndex = trainSetSingle.tumorBamIndex,
mutect2VCF = trainSetSingle.mutect2VCF,
varscanVCF = trainSetSingle.varscanSNV,
vardictVCF = trainSetSingle.vardictVCF,
lofreqVCF = trainSetSingle.lofreqSNV,
scalpelVCF = trainSetSingle.scalpelVCF,
strelkaVCF = trainSetSingle.strelkaSNV,
dockerImage = dockerImages["somaticseq"]
}
}
if (!defined(controlBam)) {
call somaticSeqTask.ParallelSingle as singleSomaticSeq {
input:
classifierSNV = singleTraining.ensembleSNVClassifier,
classifierIndel = singleTraining.ensembleIndelsClassifier,
outputDir = somaticSeqDir,
referenceFasta = referenceFasta,
referenceFastaFai = referenceFastaFai,
inclusionRegion = regions,
bam = tumorBam,
bamIndex = tumorBamIndex,
mutect2VCF = mutect2.outputVcf,
vardictVCF = vardict.outputVcf,
strelkaVCF = strelka.variantsVcf,
dockerImage = dockerImages["somaticseq"]
}
}
call samtools.BgzipAndIndex as snvIndex {
input:
inputFile = select_first([if defined(controlBam)
then pairedSomaticSeq.snvs
else singleSomaticSeq.snvs]),
outputDir = somaticSeqDir,
dockerImage = dockerImages["tabix"]
}
call samtools.BgzipAndIndex as indelIndex {
input:
inputFile = select_first([if defined(controlBam)
then pairedSomaticSeq.indels
else singleSomaticSeq.indels]),
outputDir = somaticSeqDir,
dockerImage = dockerImages["tabix"]
}
output {
File somaticSeqSnvVcf = snvIndex.compressed
File somaticSeqSnvVcfIndex = snvIndex.index
File somaticSeqIndelVcf = indelIndex.compressed
File somaticSeqIndelVcfIndex = indelIndex.index
File? mutect2Vcf = mutect2.outputVcf
File? mutect2VcfIndex = mutect2.outputVcfIndex
File? vardictVcf = vardict.outputVcf
File? vardictVcfIndex = vardict.outputVcfIndex
File? strelkaSnvsVcf = strelka.variantsVcf
File? strelkaSnvsVcfIndex = strelka.variantsVcfIndex
File? strelkaIndelsVcf = strelka.indelsVcf
File? strelkaIndelsVcfIndex = strelka.indelsVcfIndex
File? strelkaCombinedVcf = strelka.combinedVcf
File? strelkaCombinedVcfIndex = strelka.combinedVcfIndex
File? mantaVcf = strelka.mantaVcf
File? mantaVcfIndex = strelka.mantaVcfIndex
File? combinedVcf = combineVariants.combinedVcf
File? combinedVcfIndex = combineVariants.combinedVcfIndex
File? ensembleIndelsClassifier = if defined(controlBam)
then pairedTraining.ensembleIndelsClassifier
else singleTraining.ensembleIndelsClassifier
File? ensembleSNVClassifier = if defined(controlBam)
then pairedTraining.ensembleSNVClassifier
else singleTraining.ensembleSNVClassifier
}
parameter_meta {
outputDir: {description: "The directory to which the outputs will be written.", category: "common"}
referenceFasta: {description: "The reference fasta file.", category: "required"}
referenceFastaFai: {description: "Fasta index (.fai) file of the reference.", category: "required"}
referenceFastaDict: {description: "Sequence dictionary (.dict) file of the reference.", category: "required"}
tumorSample: {description: "The name of the tumor/case sample.", category: "required"}
tumorBam: {description: "The BAM file for the tumor/case sample.", category: "required"}
tumorBamIndex: {description: "The index for the tumor/case sample's BAM file.", category: "required"}
controlSample: {description: "The name of the normal/control sample.", category: "common"}
controlBam: {description: "The BAM file for the normal/control sample.", category: "common"}
controlBamIndex: {description: "The index for the normal/control sample's BAM file.", category: "common"}
trainingSet: {description: "VCF files used to train somaticseq.", category: "advanced"}
regions: {description: "A bed file describing the regions to operate on.", category: "common"}
variantsForContamination: {description: "A VCF file with common variants.", category: "advanced"}
variantsForContaminationIndex: {description: "The index of the common variants VCF file.", category: "advanced"}
sitesForContamination: {description: "A bed file, vcf file or interval list with regions for GetPileupSummaries to operate on.", category: "advanced"}
sitesForContaminationIndex: {description: "The index for the vcf file provided to sitesForContamination.", category: "advanced"}
runStrelka: {description: "Whether or not to run Strelka.", category: "common"}
runManta: {description: "Whether or not manta should be run as part of the Strelka pipeline.", category: "common"}
runVardict: {description: "Whether or not to run VarDict.", category: "common"}
runMutect2: {description: "Whether or not to run Mutect2.", category: "common"}
runCombineVariants: {description: "Whether or not to combine the variant calling results into one VCF file.", category: "advanced"}
dockerImages: {description: "The docker images used. Changing this may result in errors which the developers may choose not to address.",
category: "advanced"}
}
meta {
WDL_AID: {
exclude: ["DONOTDEFINETHIS", "indelIndex.type", "snvIndex.type"]
}
allowNestedInputs: true
}
}