-
Notifications
You must be signed in to change notification settings - Fork 1
/
callMolQTLS.Rmd
322 lines (219 loc) · 12.7 KB
/
callMolQTLS.Rmd
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
---
title: "Call aditional molecular QTLs"
author: "Briana Mittleman"
date: "9/25/2018"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
I will use this analysis file to recall the other molecular QTLs using the same VCF files I am using for the APAqtls. This is important because we want to overlap QTLs called with the same genotype information.
* processed (WASP+normalized) 4sU-seq (30m)
* processed (WASP+normalized) 4sU-seq (60m)
* processed (WASP+normalized) RNA-seq (Pickrell)
* processed (WASP+normalized) RNA-seq (GEUVADIS)
* processed (WASP+normalized) ribo-seq
* LiftOver from (Battle et al., 2015) protein
I am download the processed data from http://eqtl.uchicago.edu/jointLCL/ and putting it in /project2/gilad/briana/threeprimeseq/data/molecular_phenos.
The protein file is already in the format needed for fastQTL. I need to change the headers to include the NA before the individuals.I will need to use:
`export PATH=/project/gilad/software/midway1/qtltools-1.0:$PATH`
###RiboQTL
```bgzip phenotypes.bed && tabix -p bed phenotypes.bed.gz```
To index the file for the program.
I will create a python script that adds the NA to the individuals.
```{bash, eval=F}
def main(inF, outF):
infile= open(inF, "r")
fout = open(outF,'w')
for i, line in enumerate(infile):
if i == 0:
linelist=line.split()
for i, item in enumerate(linelist):
if i > 3:
linelist[i]="NA" + item
fout.write(" ".join(linelist) + '\n' )
else:
fout.write(line)
fout.close()
if __name__ == "__main__":
import sys
inF = sys.argv[1]
outF= sys.argv[2]
main(inF, outF)
```
Next step is to get the PCs to use as covariates in the analysis.
https://qtltools.github.io/qtltools/
This package is in /project/gilad/software/midway1/ and was installed by Peter Carbaneto from the RCC. I can add this to my path with:
```
export PATH=/project/gilad/software/midway1/qtltools-1.0:$PATH
```
I am going to use the QTLtools pca function. I need to run this on midway1.
```{bash, eval=F}
QTLtools pca --bed /project2/gilad/briana/threeprimeseq/data/molecular_phenos/fastqtl_qqnorm_ribo_phase2.fixed.bed.gz --scale --center --out /project2/gilad/briana/threeprimeseq/data/molecular_phenos/fastqtl_qqnorm_ribo_phase2.fixed.bed.PC.txt
#keep top 5 PCs for analysis
head -n 6 fastqtl_qqnorm_ribo_phase2.fixed.bed.PC.txt.pca > fastqtl_qqnorm_ribo_phase2.fixed.bed.5PCs.txt.pca
```
I then make a samples file wit the head of the PCA file. Remove 19192,19193 from sample file
I need to make 1 vcf file with all of the chroms to run this.
riboQTL.nom.sh
```{bash,eval=F}
#!/bin/bash
#SBATCH --job-name=riboQTL.nom
#SBATCH --account=pi-yangili1
#SBATCH --time=24:00:00
#SBATCH --output=riboQTL.nom.out
#SBATCH --error=riboQTL.nom.err
#SBATCH --partition=broadwl
#SBATCH --mem=12G
#SBATCH --mail-type=END
for i in $(seq 1 30)
do
/home/brimittleman/software/bin/FastQTL/bin/fastQTL.static --vcf /project2/gilad/briana/YRI_geno_hg19/allChrom.dose.filt.vcf.gz --cov /project2/gilad/briana/threeprimeseq/data/molecular_phenos/fastqtl_qqnorm_ribo_phase2.fixed.bed.5PCs_tab.txt.pca --bed /project2/gilad/briana/threeprimeseq/data/molecular_phenos/fastqtl_qqnorm_ribo_phase2.fixed.noChr.bed.gz --out /project2/gilad/briana/threeprimeseq/data/molecular_QTLs/nom/fastqtl_qqnorm_ribo_phase2.fixed.nominal.out --chunk $i 30 --window 5e4 --include-samples /project2/gilad/briana/threeprimeseq/data/molecular_phenos/samples.txt
done
```
problem chr in pheno file and not in vcf
```{bash,eval=F}
sed 's/^chr//' fastqtl_qqnorm_ribo_phase2.fixed.bed > fastqtl_qqnorm_ribo_phase2.fixed.noChr.bed
```
try changing /project2/gilad/briana/threeprimeseq/data/molecular_phenos/fastqtl_qqnorm_ribo_phase2.fixed.bed.5PCs.txt.pca first part of header to id like in the FastQTL site. and use tr to make it tap deliminated from " "
riboQTL.perm.sh
```{bash, eval=F}
#!/bin/bash
#SBATCH --job-name=riboQTL.perm
#SBATCH --account=pi-yangili1
#SBATCH --time=24:00:00
#SBATCH --output=riboQTL.perm.out
#SBATCH --error=riboQTL.perm.err
#SBATCH --partition=broadwl
#SBATCH --mem=12G
#SBATCH --mail-type=END
for i in $(seq 1 30)
do
/home/brimittleman/software/bin/FastQTL/bin/fastQTL.static --permute 1000 --vcf /project2/gilad/briana/YRI_geno_hg19/allChrom.dose.filt.vcf.gz --cov /project2/gilad/briana/threeprimeseq/data/molecular_phenos/fastqtl_qqnorm_ribo_phase2.fixed.bed.5PCs_tab.txt.pca --bed /project2/gilad/briana/threeprimeseq/data/molecular_phenos/fastqtl_qqnorm_ribo_phase2.fixed.noChr.bed.gz --out /project2/gilad/briana/threeprimeseq/data/molecular_QTLs/perm/fastqtl_qqnorm_ribo_phase2.fixed.perm.chunk$i.out --chunk $i 30 --window 5e4 --include-samples /project2/gilad/briana/threeprimeseq/data/molecular_phenos/samples.txt
done
```
I can process these to by generalizing my script from the apaQTLsAllInd.Rmd
###Eqtl
I need to remove the Chr and add the NA.
fastqtl_qqnorm_RNAseq_phase2.txt
```{bash,eval=F}
python addNAphenohead.py /project2/gilad/briana/threeprimeseq/data/molecular_phenos/fastqtl_qqnorm_RNAseq_phase2.txt /project2/gilad/briana/threeprimeseq/data/molecular_phenos/fastqtl_qqnorm_RNAseq_phase2.fixed.txt
sed 's/^chr//' /project2/gilad/briana/threeprimeseq/data/molecular_phenos/fastqtl_qqnorm_RNAseq_phase2.fixed.txt > /project2/gilad/briana/threeprimeseq/data/molecular_phenos/fastqtl_qqnorm_RNAseq_phase2.fixed.noChr.txt
bgzip /project2/gilad/briana/threeprimeseq/data/molecular_phenos/fastqtl_qqnorm_RNAseq_phase2.fixed.noChr.txt
tabix /project2/gilad/briana/threeprimeseq/data/molecular_phenos/fastqtl_qqnorm_RNAseq_phase2.fixed.noChr.txt.gz
#midway1
QTLtools pca --bed /project2/gilad/briana/threeprimeseq/data/molecular_phenos/fastqtl_qqnorm_RNAseq_phase2.fixed.noChr.txt.gz --scale --center --out /project2/gilad/briana/threeprimeseq/data/molecular_phenos/fastqtl_qqnorm_RNAseq_phase2.fixed.noChr.PC.txt
#keep top 5 PCs for analysis
head -n 6 fastqtl_qqnorm_RNAseq_phase2.fixed.noChr.PC.txt.pca > fastqtl_qqnorm_RNAseq_phase2.fixed.noChr.5PC.txt.pca
less fastqtl_qqnorm_RNAseq_phase2.fixed.noChr.5PC.txt.pca | tr " " "\t" > fastqtl_qqnorm_RNAseq_phase2.fixed.noChr.5PC_tab.txt.pca
```
I want to create a script that checks the samples in the file and then makes a samples.txt file if they are in the VCF.
First create a file with the names of the individuals in the vcf files. /project2/gilad/briana/YRI_geno_hg19/vcf.samples.txt
create_molQTLSamplefile.py
```{bash, eval=F}
#infile is the pheno PCA file (because it is not zipped)
#outfile is the samples for that pheno if they are in the vcf samples
def main(inF, outF):
vcf_samp=open("/project2/gilad/briana/YRI_geno_hg19/vcf.samples.txt", "r")
for line in vcf_samp:
vcf_list=line.split()
infile= open(inF, "r")
fout = open(outF,'w')
for i, line in enumerate(infile):
if i ==0:
mol_samples=line.split()[1:]
final_samps=[]
for i in mol_samples:
if i in vcf_list:
final_samps.append(i)
fout.write("\n".join(final_samps))
if __name__ == "__main__":
import sys
inF = sys.argv[1]
outF= sys.argv[2]
main(inF, outF)
```
Run in the code dir:
```{bash,eval=F}
python create_molQTLSamplefile.py ../data/molecular_phenos/fastqtl_qqnorm_RNAseq_phase2.fixed.noChr.5PC_tab.txt.pca ../data/molecular_phenos/fastqtl_qqnorm_RNAseq_phase2.Samples.txt
```
rnaQTL.nom.sh
```{bash,eval=F}
#!/bin/bash
#SBATCH --job-name=rnaQTL.nom
#SBATCH --account=pi-yangili1
#SBATCH --time=24:00:00
#SBATCH --output=rnaQTL.nom.out
#SBATCH --error=rnaQTL.nom.err
#SBATCH --partition=broadwl
#SBATCH --mem=12G
#SBATCH --mail-type=END
for i in $(seq 1 30)
do
/home/brimittleman/software/bin/FastQTL/bin/fastQTL.static --vcf /project2/gilad/briana/YRI_geno_hg19/allChrom.dose.filt.vcf.gz --cov /project2/gilad/briana/threeprimeseq/data/molecular_phenos/fastqtl_qqnorm_RNAseq_phase2.fixed.noChr.5PC_tab.txt.pca --bed /project2/gilad/briana/threeprimeseq/data/molecular_phenos/fastqtl_qqnorm_RNAseq_phase2.fixed.noChr.txt.gz --out /project2/gilad/briana/threeprimeseq/data/molecular_QTLs/nom/fastqtl_qqnorm_RNAseq_phase2.fixed.nominal.chunk$i.out --chunk $i 30 --window 5e4 --include-samples /project2/gilad/briana/threeprimeseq/data/molecular_phenos/fastqtl_qqnorm_RNAseq_phase2.Samples.txt
done
```
rnaQTL.perm.sh
```{bash,eval=F}
#!/bin/bash
#SBATCH --job-name=rnaQTL.perm
#SBATCH --account=pi-yangili1
#SBATCH --time=24:00:00
#SBATCH --output=rnaQTL.perm.out
#SBATCH --error=rnaQTL.perm.err
#SBATCH --partition=broadwl
#SBATCH --mem=12G
#SBATCH --mail-type=END
for i in $(seq 1 30)
do
/home/brimittleman/software/bin/FastQTL/bin/fastQTL.static --permute 1000 --vcf /project2/gilad/briana/YRI_geno_hg19/allChrom.dose.filt.vcf.gz --cov /project2/gilad/briana/threeprimeseq/data/molecular_phenos/fastqtl_qqnorm_RNAseq_phase2.fixed.noChr.5PC_tab.txt.pca --bed /project2/gilad/briana/threeprimeseq/data/molecular_phenos/fastqtl_qqnorm_RNAseq_phase2.fixed.noChr.txt.gz --out /project2/gilad/briana/threeprimeseq/data/molecular_QTLs/perm/fastqtl_qqnorm_RNAseq_phase2.fixed.perm.chunk$i.out --chunk $i 30 --window 5e4 --include-samples /project2/gilad/briana/threeprimeseq/data/molecular_phenos/fastqtl_qqnorm_RNAseq_phase2.Samples.txt
done
```
###ProteinQTL
http://eqtl.uchicago.edu/jointLCL/fastqtl_qqnorm_prot.txt.gz
```{bash,eval=F}
python /project2/gilad/briana/threeprimeseq/code/addNAphenohead.py /project2/gilad/briana/threeprimeseq/data/molecular_phenos/fastqtl_qqnorm_prot.txt /project2/gilad/briana/threeprimeseq/data/molecular_phenos/fastqtl_qqnorm_prot.fixed.txt
sed 's/^chr//' /project2/gilad/briana/threeprimeseq/data/molecular_phenos/fastqtl_qqnorm_prot.fixed.txt > /project2/gilad/briana/threeprimeseq/data/molecular_phenos/fastqtl_qqnorm_prot.fixed.noChr.txt
bgzip /project2/gilad/briana/threeprimeseq/data/molecular_phenos/fastqtl_qqnorm_prot.fixed.noChr.txt
tabix -p bed /project2/gilad/briana/threeprimeseq/data/molecular_phenos/fastqtl_qqnorm_prot.fixed.noChr.txt.gz
#midway1
QTLtools pca --bed /project2/gilad/briana/threeprimeseq/data/molecular_phenos/fastqtl_qqnorm_prot.fixed.noChr.txt.gz --scale --center --out /project2/gilad/briana/threeprimeseq/data/molecular_phenos/fastqtl_qqnorm_prot.fixed.noChr.PC.txt
#keep top 5 PCs for analysis
head -n 6 /project2/gilad/briana/threeprimeseq/data/molecular_phenos/fastqtl_qqnorm_prot.fixed.noChr.PC.txt.pca > /project2/gilad/briana/threeprimeseq/data/molecular_phenos/fastqtl_qqnorm_prot.fixed.noChr.5PC.txt.pca
less /project2/gilad/briana/threeprimeseq/data/molecular_phenos/fastqtl_qqnorm_prot.fixed.noChr.5PC.txt.pca | tr " " "\t" > /project2/gilad/briana/threeprimeseq/data/molecular_phenos/fastqtl_qqnorm_prot.fixed.noChr.5PC_tab.txt.pca
```
```{bash,eval=F}
python create_molQTLSamplefile.py /project2/gilad/briana/threeprimeseq/data/molecular_phenos/fastqtl_qqnorm_prot.fixed.noChr.5PC_tab.txt.pca /project2/gilad/briana/threeprimeseq/data/molecular_phenos/fastqtl_qqnorm_prot.fixed.noChr.SAMP.txt
```
protQTL.nom.sh
```{bash,eval=F}
#!/bin/bash
#SBATCH --job-name=protQTL.nom
#SBATCH --account=pi-yangili1
#SBATCH --time=24:00:00
#SBATCH --output=protQTL.nom.out
#SBATCH --error=protQTL.nom.err
#SBATCH --partition=broadwl
#SBATCH --mem=12G
#SBATCH --mail-type=END
for i in $(seq 1 30)
do
/home/brimittleman/software/bin/FastQTL/bin/fastQTL.static --vcf /project2/gilad/briana/YRI_geno_hg19/allChrom.dose.filt.vcf.gz --cov /project2/gilad/briana/threeprimeseq/data/molecular_phenos/fastqtl_qqnorm_prot.fixed.noChr.5PC_tab.txt.pca --bed /project2/gilad/briana/threeprimeseq/data/molecular_phenos/fastqtl_qqnorm_prot.fixed.noChr.txt.gz --out /project2/gilad/briana/threeprimeseq/data/molecular_QTLs/nom/fastqtl_qqnorm_prot.fixed.nominal.chunk$i.out --chunk $i 30 --window 5e4 --include-samples /project2/gilad/briana/threeprimeseq/data/molecular_phenos/fastqtl_qqnorm_prot.fixed.noChr.SAMP.txt
done
```
protQTL.perm.sh
```{bash,eval=F}
#!/bin/bash
#SBATCH --job-name=protQTL.perm
#SBATCH --account=pi-yangili1
#SBATCH --time=24:00:00
#SBATCH --output=protQTL.perm.out
#SBATCH --error=protQTL.perm.err
#SBATCH --partition=broadwl
#SBATCH --mem=12G
#SBATCH --mail-type=END
for i in $(seq 1 30)
do
/home/brimittleman/software/bin/FastQTL/bin/fastQTL.static --permute 1000 --vcf /project2/gilad/briana/YRI_geno_hg19/allChrom.dose.filt.vcf.gz --cov /project2/gilad/briana/threeprimeseq/data/molecular_phenos/fastqtl_qqnorm_prot.fixed.noChr.5PC_tab.txt.pca --bed /project2/gilad/briana/threeprimeseq/data/molecular_phenos/fastqtl_qqnorm_prot.fixed.noChr.txt.gz --out /project2/gilad/briana/threeprimeseq/data/molecular_QTLs/perm/fastqtl_qqnorm_prot.fixed.nominal.chunk$i.out --chunk $i 30 --window 5e4 --include-samples /project2/gilad/briana/threeprimeseq/data/molecular_phenos/fastqtl_qqnorm_prot.fixed.noChr.SAMP.txt
done
```