-
Notifications
You must be signed in to change notification settings - Fork 1
/
quality-control-gwas.wdl
221 lines (180 loc) · 5.15 KB
/
quality-control-gwas.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
task inc {
Int i
File inputVCF
String inputVCF_name
Int threads
Float memory
Int diskGB
command{
bcftools index -f ${inputVCF} > "${inputVCF_name}.csi"
bcftools view ${inputVCF} -r "${i}" | bgzip > "chr${i}.vcf.gz"
}
output {
File outputVCF= "chr${i}.vcf.gz"
File index= "${inputVCF_name}.csi"
}
runtime {
docker: "gargk/bcftools:v1.8"
cpu: "${threads}"
memory: "${memory} GB"
preemptible: 3
disks: "local-disk " + diskGB + " HDD"
}
}
task bcfstats{
File inputVCF
Int threads
command{
bcftools stats -s- ${inputVCF} > "bcfstats.tsv"
grep "#" -v "bcfstats.tsv" | grep "PSC" > "psc.tsv"
}
runtime{
docker: "gargk/bcftools:v1.8"
cpu: "${threads}"
memory: "20 GB"
preemptible: 3
}
output{
File bcfstats = "bcfstats.tsv"
File psc = "psc.tsv"
}
}
task missingness_plink{
File inputVCF
Int threads
command{
plink1.9 --vcf ${inputVCF} --const-fid 0 -missing --out data_miss
}
runtime{
docker : "biocontainers/plink1.9:v1.90b6.6-181012-1-deb_cv1"
cpu: "${threads}"
memory: "20 GB"
preemptible: 3
}
output{
File data_miss = "data_miss.imiss"
}
}
task run_rscript {
File statPlot
Int threads
File data_miss
File psc
command {
mv ${statPlot} script.R
mv ${data_miss} data_miss.imiss
mv ${psc} psc.tsv
R -e "source('script.R'); a=statPlot(missingness_file='data_miss.imiss',psc_file='psc.tsv'); write_tsv(a, 'samples_to_keep.txt', col_names = FALSE)"
}
runtime{
docker : "rocker/tidyverse"
cpu: "${threads}"
memory: "20 GB"
preemptible: 3
}
output{
File to_keep = "samples_to_keep.txt"
}
}
task remove_qc_failed_samples{
File inputVCF
File to_keep
Int threads
String inputVCF_name
command{
bcftools index ${inputVCF} > "${inputVCF_name}.csi"
bcftools view ${inputVCF} -S ${to_keep} |
bgzip > "${inputVCF_name}_modified.vcf.gz"
}
runtime{
docker: "gargk/bcftools:v1.8"
cpu: "${threads}"
memory: "20 GB"
preemptible: 3
continueOnReturnCode: true
}
output{
File modified_vcf_01 = "${inputVCF_name}_modified.vcf.gz"
}
}
task plink_qc_steps{
Int threads
File modified_vcf_01
command{
plink1.9 --vcf ${modified_vcf_01} --maf 0.01 --geno 0.001 --indep-pairwise 50 5 0.2 --const-fid --recode vcf
}
runtime{
docker : "biocontainers/plink1.9:v1.90b6.6-181012-1-deb_cv1"
cpu: "${threads}"
memory: "20 GB"
preemptible: 3
}
output{
File outputVCF = "plink.vcf"
}
}
task merge{
Int threads
Array[File] vcf
command{
bcftools concat ${sep=' ' vcf} > "outputVCF.vcf"
}
runtime{
docker: "gargk/bcftools:v1.8"
cpu: "${threads}"
memory: "20 GB"
preemptible: 3
continueOnReturnCode: true
}
output{
File mergedOutput = "outputVCF.vcf"
}
}
workflow wf {
File statPlot
#Runtime parameters
Int threads
File inputVCF
Int diskGB = ceil(size(inputVCF, "GB") + 75)
Array[Int] integers = [5,6]
scatter(i in integers) {
call inc{
input:
inputVCF=inputVCF,
i=i,
diskGB=diskGB
}
call bcfstats {
input:
inputVCF=inc.outputVCF,
threads=threads
}
call missingness_plink {
input:
inputVCF=inc.outputVCF,
threads=threads
}
call run_rscript{
input:
statPlot=statPlot,
data_miss=missingness_plink.data_miss,
psc=bcfstats.psc,
threads=threads
}
call remove_qc_failed_samples{
input:
inputVCF=inc.outputVCF,
to_keep=run_rscript.to_keep,
threads=threads
}
call plink_qc_steps{
input:
threads=threads,
modified_vcf_01=remove_qc_failed_samples.modified_vcf_01
}}
call merge{
input:
threads=threads,
vcf=plink_qc_steps.outputVCF,
}
}