-
Notifications
You must be signed in to change notification settings - Fork 6
/
somatic.wdl
444 lines (407 loc) · 22.3 KB
/
somatic.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
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
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 "gatk-CNVcalling/pairedCnvCalling.wdl" as pairedCnvCalling
import "gatk-CNVcalling/CNV-PON.wdl" as cnvPon
import "sample.wdl" as sampleWorkflow
import "somatic-variantcalling/somatic-variantcalling.wdl" as somaticVariantcallingWorkflow
import "structs.wdl" as structs
import "tasks/biowdl.wdl" as biowdl
import "tasks/bwa.wdl" as bwa
import "tasks/common.wdl" as common
import "tasks/multiqc.wdl" as multiqc
import "tasks/samtools.wdl" as samtools
import "tasks/chunked-scatter.wdl" as chunkedScatter
workflow Somatic {
input {
File sampleConfigFile
String outputDir = "."
File referenceFasta
File? referenceFastaFai
File? referenceFastaDict
BwaIndex? bwaIndex
File dbsnpVCF
File? dbsnpVCFIndex
Boolean umiDeduplication = false
Boolean collectUmiStats = false
Boolean performCnvCalling = false
String platform = "illumina"
Boolean useBwaKit = false
Boolean runStrelka = true
Boolean runVardict = true
Boolean runMutect2 = true
Boolean runManta = true
Boolean runCombineVariants = false
Int scatterSizeMillions = 1000
File? regions
File? cnvPanelOfNormals
File? preprocessedIntervals
String? adapterForward
String? adapterReverse
Int? cnvMinimumContigLength
Int? scatterSize
File? commonVariantSites
File? commonVariantSitesIndex
Int bwaThreads = 4
File dockerImagesFile
File? DONOTDEFINETHISFILE
String? DONOTDEFINETHISSTRING
}
meta {
allowNestedInputs: true
WDL_AID: {
exclude: ["DONOTDEFINETHISFILE", "DONOTDEFINETHISSTRING"]
}
}
if (!defined(referenceFastaFai) || !defined(referenceFastaDict)) {
call samtools.DictAndFaidx as fidx {
input:
inputFile = referenceFasta
}
}
File refFasta = select_first([fidx.outputFasta, referenceFasta])
File refFastaDict = select_first([fidx.outputFastaDict, referenceFastaDict])
File refFastaFai = select_first([fidx.outputFastaFai, referenceFastaFai])
if (!defined(dbsnpVCFIndex)) {
call samtools.Tabix as tabix {
input:
inputFile = dbsnpVCF,
type = "vcf"
}
}
File dbsnpVcf = select_first([tabix.indexedFile, dbsnpVCF])
File dbsnpVcfIndex = select_first([tabix.index, dbsnpVCFIndex])
if (!defined(bwaIndex)) {
call bwa.Index as bwaIndexTask {
input:
fasta = refFasta
}
}
BwaIndex bwidx = select_first([bwaIndexTask.index, bwaIndex])
# Parse docker Tags configuration and sample sheet.
call common.YamlToJson as convertDockerImagesFile {
input:
yaml = dockerImagesFile,
outputJson = "dockerImages.json"
}
Map[String, String] dockerImages = read_json(convertDockerImagesFile.json)
call biowdl.InputConverter as convertSampleConfig {
input:
samplesheet = sampleConfigFile,
dockerImage = dockerImages["biowdl-input-converter"]
}
SampleConfig sampleConfig = read_json(convertSampleConfig.json)
call chunkedScatter.ScatterRegions as scatterList {
input:
inputFile = select_first([regions, refFastaFai]),
scatterSize = scatterSize,
scatterSizeMillions = scatterSizeMillions,
dockerImage = dockerImages["chunked-scatter"]
}
# Running sample subworkflow.
scatter (sample in sampleConfig.samples) {
call sampleWorkflow.SampleWorkflow as sampleWorkflow {
input:
sampleDir = outputDir + "/samples/" + sample.id,
sample = sample,
referenceFasta = refFasta,
referenceFastaFai = refFastaFai,
referenceFastaDict = refFastaDict,
bwaIndex = bwidx,
dbsnpVCF = dbsnpVcf,
dbsnpVCFIndex = dbsnpVcfIndex,
adapterForward = adapterForward,
adapterReverse = adapterReverse,
useBwaKit = useBwaKit,
dockerImages = dockerImages,
scatters = scatterList.scatters,
bwaThreads = bwaThreads,
platform = platform,
umiDeduplication = umiDeduplication,
collectUmiStats = collectUmiStats
}
String sampleIds = sample.id
if (!defined(sample.control)) {
File controlBams = sampleWorkflow.recalibratedBam
File controlBamIndexes = sampleWorkflow.recalibratedBamIndex
}
}
if (performCnvCalling && (! defined(cnvPanelOfNormals) || ! defined(preprocessedIntervals))) {
call cnvPon.PanelOfNormals as generateCnvPanelOfNormals {
input:
inputBams = select_all(controlBams),
inputBamIndexes = select_all(controlBamIndexes),
referenceFasta = refFasta,
referenceFastaFai = refFastaFai,
referenceFastaDict = refFastaDict,
regions = regions,
outputDir = outputDir + "/PON/",
dockerImages = {"gatk": dockerImages["gatk-broad"]} # These tasks will run into trouble with the biocontainers.
}
}
scatter (sample in sampleConfig.samples) {
call GetSamplePositionInArray as casePosition {
input:
sampleIds = sampleIds,
sample = sample.id,
}
File tumorBam = sampleWorkflow.recalibratedBam[casePosition.position]
File tumorBamIndex = sampleWorkflow.recalibratedBamIndex[casePosition.position]
if (defined(sample.control)) {
call GetSamplePositionInArray as controlPostition {
input:
sampleIds = sampleIds,
sample = select_first([sample.control])
}
}
Int controlPos = select_first([controlPostition.position, 0])
String? controlSample = if (defined(sample.control)) then sampleIds[controlPos] else DONOTDEFINETHISSTRING
File? controlBam = if (defined(sample.control)) then sampleWorkflow.recalibratedBam[controlPos] else DONOTDEFINETHISFILE
File? controlBamIndex = if (defined(sample.control)) then sampleWorkflow.recalibratedBamIndex[controlPos] else DONOTDEFINETHISFILE
call somaticVariantcallingWorkflow.SomaticVariantcalling as somaticVariantcalling {
input:
outputDir = outputDir + "/samples/" + sample.id + "/somatic-variantcalling/",
referenceFasta = refFasta,
referenceFastaFai = refFastaFai,
referenceFastaDict = refFastaDict,
tumorSample = sample.id,
tumorBam = tumorBam,
tumorBamIndex = tumorBamIndex,
controlSample = controlSample,
controlBam = controlBam,
controlBamIndex =controlBamIndex,
regions = regions,
dockerImages = dockerImages,
runStrelka = runStrelka,
runVardict = runVardict,
runMutect2 = runMutect2,
runManta = runManta,
runCombineVariants = runCombineVariants
}
if (performCnvCalling && defined(sample.control)) {
call pairedCnvCalling.PairedCnvCalling as CNVs {
input:
caseSampleName = sample.id,
caseBam = tumorBam,
caseBamIndex = tumorBamIndex,
controlSampleName = select_first([controlSample]),
controlBam = select_first([controlBam]),
controlBamIndex = select_first([controlBamIndex]),
PON = select_first([cnvPanelOfNormals, generateCnvPanelOfNormals.PON]),
preprocessedIntervals = select_first([preprocessedIntervals,
generateCnvPanelOfNormals.preprocessedIntervals]),
commonVariantSites = select_first([commonVariantSites, dbsnpVCF]),
commonVariantSitesIndex = select_first([commonVariantSitesIndex, dbsnpVCFIndex]),
outputDir = outputDir + "/samples/" + sample.id + "/CNVcalling/",
referenceFasta = refFasta,
referenceFastaFai = refFastaFai,
referenceFastaDict = refFastaDict,
minimumContigLength = cnvMinimumContigLength,
dockerImages = {"gatk": dockerImages["gatk-broad"]} # These tasks will run into trouble with the biocontainers
}
}
}
call multiqc.MultiQC as multiqcTask {
input:
reports = flatten(sampleWorkflow.reports),
outDir = outputDir,
dockerImage = dockerImages["multiqc"]
}
output {
File dockerImagesList = convertDockerImagesFile.json
File multiqcReport = multiqcTask.multiqcReport
Array[File] recalibratedBams = sampleWorkflow.recalibratedBam
Array[File] reports = flatten(sampleWorkflow.reports)
Array[File] recalibratedBamIndexes = sampleWorkflow.recalibratedBamIndex
Array[File] markdupBams = sampleWorkflow.markdupBam
Array[File] markdupBamIndex = sampleWorkflow.markdupBamIndex
Array[File?] somaticSeqSnvVcf = somaticVariantcalling.somaticSeqSnvVcf
Array[File?] somaticSeqSnvVcfIndex = somaticVariantcalling.somaticSeqSnvVcfIndex
Array[File?] somaticSeqIndelVcf = somaticVariantcalling.somaticSeqIndelVcf
Array[File?] somaticSeqIndelVcfIndex = somaticVariantcalling.somaticSeqIndelVcfIndex
Array[File?] mutect2Vcf = somaticVariantcalling.mutect2Vcf
Array[File?] mutect2VcfIndex = somaticVariantcalling.mutect2VcfIndex
Array[File?] vardictVcf = somaticVariantcalling.vardictVcf
Array[File?] vardictVcfIndex = somaticVariantcalling.vardictVcfIndex
Array[File?] strelkaSnvsVcf = somaticVariantcalling.strelkaSnvsVcf
Array[File?] strelkaSnvsVcfIndex = somaticVariantcalling.strelkaSnvsVcfIndex
Array[File?] strelkaIndelsVcf = somaticVariantcalling.strelkaIndelsVcf
Array[File?] strelkaIndelsVcfIndex = somaticVariantcalling.strelkaIndelsVcfIndex
Array[File?] strelkaCombinedVcf = somaticVariantcalling.strelkaCombinedVcf
Array[File?] strelkaCombinedVcfIndex = somaticVariantcalling.strelkaCombinedVcfIndex
Array[File?] mantaVcf = somaticVariantcalling.mantaVcf
Array[File?] mantaVcfIndex = somaticVariantcalling.mantaVcfIndex
Array[File?] combinedVcf = somaticVariantcalling.combinedVcf
Array[File?] combinedVcfIndex = somaticVariantcalling.combinedVcfIndex
Array[File?] ensembleIndelsClassifier = somaticVariantcalling.ensembleIndelsClassifier
Array[File?] ensembleSNVClassifier = somaticVariantcalling.ensembleSNVClassifier
File? generatedpreProcessedIntervals = generateCnvPanelOfNormals.preprocessedIntervals
File? generatedPON = generateCnvPanelOfNormals.PON
Array[File?] caseAllelicCounts = CNVs.caseAllelicCounts
Array[File?] caseReadCounts = CNVs.caseReadCounts
Array[File?] caseStandardizedCopyRatios = CNVs.caseStandardizedCopyRatios
Array[File?] caseDenoisedCopyRatios = CNVs.caseDenoisedCopyRatios
Array[File?] caseHetrozygousAllelicCounts = CNVs.caseHetrozygousAllelicCounts
Array[File?] caseNormalHetrozygousAllelicCounts = CNVs.caseNormalHetrozygousAllelicCounts
Array[File?] caseCopyRatioSegments = CNVs.caseCopyRatioSegments
Array[File?] caseCopyRatioCBS = CNVs.caseCopyRatioCBS
Array[File?] caseAlleleFractionCBS = CNVs.caseAlleleFractionCBS
Array[File?] caseCalledSegments = CNVs.caseCalledSegments
Array[File?] caseCalledSegmentsIgv = CNVs.caseCalledSegmentsIgv
Array[File?] caseDenoisedCopyRatiosPlot = CNVs.caseDenoisedCopyRatiosPlot
Array[File?] caseDenoisedCopyRatiosLimitedPlot = CNVs.caseDenoisedCopyRatiosLimitedPlot
Array[File?] caseModeledSegmentsPlot = CNVs.caseModeledSegmentsPlot
Array[File?] controlAllelicCounts = CNVs.controlAllelicCounts
Array[File?] controlReadCounts = CNVs.controlReadCounts
Array[File?] controlStandardizedCopyRatios = CNVs.controlStandardizedCopyRatios
Array[File?] controlDenoisedCopyRatios = CNVs.controlDenoisedCopyRatios
Array[File?] controlHetrozygousAllelicCounts = CNVs.controlHetrozygousAllelicCounts
Array[File?] controlCopyRatioSegments = CNVs.controlCopyRatioSegments
Array[File?] controlCopyRatioCBS = CNVs.controlCopyRatioCBS
Array[File?] controlAlleleFractionCBS = CNVs.controlAlleleFractionCBS
Array[File?] controlCalledSegments = CNVs.controlCalledSegments
Array[File?] controlCalledSegmentsIgv = CNVs.controlCalledSegmentsIgv
Array[File?] controlDenoisedCopyRatiosPlot = CNVs.controlDenoisedCopyRatiosPlot
Array[File?] controlDenoisedCopyRatiosLimitedPlot = CNVs.controlDenoisedCopyRatiosLimitedPlot
Array[File?] controlModeledSegmentsPlot = CNVs.controlModeledSegmentsPlot
}
parameter_meta {
# inputs
sampleConfigFile: {description: "The samplesheet, including sample ids, library ids, readgroup ids and fastq file locations.", category: "required"}
outputDir: {description: "The directory the output should be written to.", category: "common"}
referenceFasta: {description: "The reference fasta file.", category: "required"}
referenceFastaFai: {description: "Fasta index (.fai) file of the reference. Will be created automatically if not present.", category: "common"}
referenceFastaDict: {description: "Sequence dictionary (.dict) file of the reference.", category: "common"}
bwaIndex: {description: "The BWA index files. Will be created automatically if not present.", category: "common"}
dbsnpVCF: {description: "dbsnp VCF file used for checking known sites.", category: "required"}
dbsnpVCFIndex: {description: "Index (.tbi) file for the dbsnp VCF. Will be created automatically if not present.", category: "common"}
performCnvCalling: {description: "Whether or not CNV calling should be performed.", category: "common"}
platform: {description: "The platform used for sequencing.", category: "advanced"}
useBwaKit: {description: "Whether or not BWA kit should be used. If false BWA mem will be used.", category: "advanced"}
runStrelka: {description: "Whether or not to run Strelka.", category: "common"}
runVardict: {description: "Whether or not to run VarDict.", category: "common"}
runMutect2: {description: "Whether or not to run Mutect2.", category: "common"}
runManta: {description: "Whether or not manta should be run as part of the Strelka pipeline.", category: "common"}
runCombineVariants: {description: "Whether or not to combine the variant calling results into one VCF file.", category: "advanced"}
scatterSizeMillions:{description: "Same as scatterSize, but is multiplied by 1000000 to get scatterSize. This allows for setting larger values more easily.", category: "advanced"}
regions: {description: "A bed file describing the regions to call variants for.", category: "common"}
cnvPanelOfNormals: {description: "The panel of normals file to be used for CNV calling. If not provided (and performCnvCalling is set to true) then this will be generated on the fly using the samples lacking a control sample in the samplesheet.", category: "common"}
preprocessedIntervals: {description: "The preprocessed intervals to be used for CNV calling. If not provided (and performCnvCalling is set to true) then this will be generated on the fly.", category: "common"}
adapterForward: {description: "The adapter to be removed from the reads first or single end reads.", category: "common"}
adapterReverse: {description: "The adapter to be removed from the reads second end reads.", category: "common"}
cnvMinimumContigLength: {description: "The minimum length for a contig to be included in the CNV plots.", category: "advanced"}
scatterSize: {description: "The size of the scattered regions in bases for the GATK subworkflows. Scattering is used to speed up certain processes. The genome will be seperated into multiple chunks (scatters) which will be processed in their own job, allowing for parallel processing. Higher values will result in a lower number of jobs. The optimal value here will depend on the available resources.", category: "advanced"}
bwaThreads: {description: "The amount of threads for the alignment process", category: "advanced"}
dockerImagesFile: {description: "A YAML file describing the docker image used for the tasks. The dockerImages.yml provided with the pipeline is recommended.", category: "advanced"}
umiDeduplication: {description: "Whether or not UMI based deduplication should be performed.", category: "common"}
collectUmiStats: {description: "Whether or not UMI deduplication stats should be collected. This will potentially cause a massive increase in memory usage of the deduplication step.", category: "advanced"}
commonVariantSites: {description: "Alternative to dnSNP for specifying common variant sites used for allelic counts collection in CNV detection. Can be a picard-style interval list or a VCf.", category: "advanced"}
commonVariantSitesIndex: {description: "The index for the commonVariantSitesIndex VCF.", category: "advanced"}
# outputs
dockerImagesList: {description: "Json file describing the docker images used by the pipeline."}
multiqcReport: {description: ""}
recalibratedBams: {description: ""}
reports: {description: ""}
recalibratedBamIndexes: {description: ""}
markdupBams: {description: ""}
markdupBamIndex: {description: ""}
somaticSeqSnvVcf: {description: ""}
somaticSeqSnvVcfIndex: {description: ""}
somaticSeqIndelVcf: {description: ""}
somaticSeqIndelVcfIndex: {description: ""}
mutect2Vcf: {description: ""}
mutect2VcfIndex: {description: ""}
vardictVcf: {description: ""}
vardictVcfIndex: {description: ""}
strelkaSnvsVcf: {description: ""}
strelkaSnvsVcfIndex: {description: ""}
strelkaIndelsVcf: {description: ""}
strelkaIndelsVcfIndex: {description: ""}
strelkaCombinedVcf: {description: ""}
strelkaCombinedVcfIndex: {description: ""}
mantaVcf: {description: ""}
mantaVcfIndex: {description: ""}
combinedVcf: {description: ""}
combinedVcfIndex: {description: ""}
ensembleIndelsClassifier: {description: ""}
ensembleSNVClassifier: {description: ""}
generatedpreProcessedIntervals: {description: ""}
generatedPON: {description: ""}
caseAllelicCounts: {description: ""}
caseReadCounts: {description: ""}
caseStandardizedCopyRatios: {description: ""}
caseDenoisedCopyRatios: {description: ""}
caseHetrozygousAllelicCounts: {description: ""}
caseNormalHetrozygousAllelicCounts: {description: ""}
caseCopyRatioSegments: {description: ""}
caseCopyRatioCBS: {description: ""}
caseAlleleFractionCBS: {description: ""}
caseCalledSegments: {description: ""}
caseCalledSegmentsIgv: {description: ""}
caseDenoisedCopyRatiosPlot: {description: ""}
caseDenoisedCopyRatiosLimitedPlot: {description: ""}
caseModeledSegmentsPlot: {description: ""}
controlAllelicCounts: {description: ""}
controlReadCounts: {description: ""}
controlStandardizedCopyRatios: {description: ""}
controlDenoisedCopyRatios: {description: ""}
controlHetrozygousAllelicCounts: {description: ""}
controlCopyRatioSegments: {description: ""}
controlCopyRatioCBS: {description: ""}
controlAlleleFractionCBS: {description: ""}
controlCalledSegments: {description: ""}
controlCalledSegmentsIgv: {description: ""}
controlDenoisedCopyRatiosPlot: {description: ""}
controlDenoisedCopyRatiosLimitedPlot: {description: ""}
controlModeledSegmentsPlot: {description: ""}
}
}
task GetSamplePositionInArray {
input {
Array[String] sampleIds
String sample
# python:3.7-slim's sha256 digest. This image is based on debian buster.
String dockerImage = "python@sha256:e0f6a4df17d5707637fa3557ab266f44dddc46ebfc82b0f1dbe725103961da4e"
}
command <<<
python <<CODE
for i, sample in enumerate(['~{sep="','" sampleIds}']):
if sample == '~{sample}':
print(i)
exit()
CODE
>>>
output {
Int position = read_int(stdout())
}
runtime {
# 4 gigs of memory to be able to build the docker image in singularity.
memory: "4G"
docker: dockerImage
}
parameter_meta {
# inputs
sampleIds: {description: "A list of sample ids.", category: "required"}
sample: {description: "The sample for which the position is wanted.", category: "required"}
dockerImage: {description: "The docker image used for this task. Changing this may result in errors which the developers may choose not to address.", category: "advanced"}
# outputs
position: {description: ""}
}
}