-
Notifications
You must be signed in to change notification settings - Fork 5
/
format.sh
executable file
·278 lines (258 loc) · 8.31 KB
/
format.sh
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
# 4-4-2020 JHZ
export threads=6
function ARISTOTLE()
{
export rt=/data/niceri/ARISTOTLE_INFL/infl_rnorm_lod_for_meta
ls ${rt} | \
sed 's/ARISTOTLE.infl.//g;s/.20200120.chr/ /g;s/.txt.gz//g' | \
cut -d' ' -f1 | \
uniq | \
parallel -j${threads} -C' ' --env rt '
(
gunzip -c ${rt}/ARISTOTLE.infl.{}.20200120.chr1.txt.gz | \
head -1;
for i in $(seq 22)
do
gunzip -c ${rt}/ARISTOTLE.infl.{}.20200120.chr${i}.txt.gz | \
awk -v OFS="\t" -f tryggve/ARISTOTLE.awk | \
awk "a[\$1]++==0" | \
sort -k2,2n -k3,3n -t$""\t""
done
) | \
gzip -f > ARISTOTLE.{}.txt.gz
'
}
ln -sf ARISTOTLE.hGDNF.txt.gz ARISTOTLE.GDNF.txt.gz
ln -sf ARISTOTLE.TGFA.txt.gz ARISTOTLE.TGF.alpha.txt.gz
ln -sf ARISTOTLE.CCL3.txt.gz ARISTOTLE.MIP.1.alpha.txt.gz
function BioFinder()
{
grep -v -w TNF sumstats/BioFinder.list | \
parallel -j$threads -C' ' '
awk -f tryggve/BioFinder.awk /data/andmala/biofinder_inf/rsannot_runGwas_plasmaImp.{1}_zre_INFI.glm.linear | \
awk -f tryggve/order.awk | \
gzip -f > sumstats/BioFinder/BioFinder.{3}.gz'
# version with complete data
gunzip -c /data/jinhua/data/BioFinder/rsannot_runGwas_plasmaImp.TNF_zre_INFI.glm.linear.gz | \
awk -f tryggve/BioFinder.awk | \
awk -f tryggve/order.awk | \
gzip -f > sumstats/BioFinder/BioFinder.TNF.gz
}
function EDCUT()
{
# SNPID has prefix esv for non-rsids
cat sumstats/EGCUT.list | \
parallel -j$threads -C' ' '
gunzip -c /data/anekal/EGCUT_INF/EGCUT_autosomal_{1}_inf_280918.txt.gz | \
awk "{if(NR>1&&(index(\$1,\"esv\")||index(\$1,\"ss\"))) \$1=\"chr\" \$2 \":\" \$3;if(\$13>0.4) print}" | \
awk -f tryggve/order.awk | \
gzip -f > sumstats/EGCUT/EGCUT.{2}.gz'
}
function INTERVAL()
{
cat sumstats/INTERVAL.list | \
parallel -j$threads -C' ' '
/usr/bin/gunzip -c /data/jampet/upload-20170920/INTERVAL_inf1_{1}___{2}_chr_merged.gz | \
awk -f tryggve/INTERVAL.awk | \
awk -f tryggve/order.awk | \
gzip -f > sumstats/INTERVAL/INTERVAL.{1}.gz'
}
function LifeLinesDeep()
{
# SNPID has no "chr" prefix for non-rsids
cat sumstats/LifeLinesDeep.list | \
sed 's/_/\t/g' | \
cut -f2 | \
sort | \
join -11 -23 - inf1_gene | \
parallel -j$threads -C' ' 'gunzip -c /data/darzhe/LifeLinesDeep.cistranspQTLs.20171220.txt.gz | \
awk -vprotein={1} -vFS="\t" -vOFS="\t" "(NR==1||index(\$1,protein))" | \
cut -f2-14 | \
sort -k2,2n -k3,3n | \
awk "{if (NR>1&&substr(\$1,1,2)!=\"rs\") \$1=\"chr\" \$2 \":\" \$3; print}" | \
awk -f tryggve/order.awk | \
gzip -f > sumstats/LifeLinesDeep/LifeLinesDeep.{1}.gz'
}
function KORA()
{
# 91 proteins without BDNF P23560 BDNF
cat sumstats/KORA.list | \
parallel -j$threads -C' ' '
gunzip -c KORA/{1}.gz | \
awk -f tryggve/KORA.awk | \
awk -f tryggve/order.awk | \
gzip -f > sumstats/KORA/KORA.{3}.gz'
}
function MadCam()
{
cat sumstats/MadCam.list | \
parallel -j$threads -C' ' '
cut -f1-14 /data/andmala/madcam/MadCAM.{1}.{2}.txt | \
sed 's/CODE_ALLELE_FQ/CODE_ALL_FQ/g' | \
awk "\$13>0.3" | \
awk -f tryggve/order.awk | \
gzip -f > sumstats/MadCam/MadCam.{3}.gz'
}
function NSPHS()
{
export NSPHS=/data/stefane/NSPHS_INF
cat sumstats/NSPHS.list | \
parallel -j$threads --env NSPHS -C' ' '
gunzip -c $NSPHS/NSPHS_inf1_{3}_{1}.txt.gz | \
awk -f tryggve/NSPHS.awk | \
awk -f tryggve/order.awk | \
gzip -f > sumstats/NSPHS/NSPHS.{2}.gz'
}
function PIVUS_ULSAM()
{
# SNPID has :I/D suffix and VG prefix
ls /data/stefang/pivus_ulsam/pivus* | \
xargs -l -x basename | \
sed 's/pivus.all.//g;s/.20161128.txt.gz//g' | \
sort | \
join - inf1_gene | \
cut -d ' ' -f1,3 | \
parallel -j$threads -C' ' '
gunzip -c /data/stefang/pivus_ulsam/pivus.all.{1}.20161128.txt.gz | \
awk "{if(NR>1&&substr(\$1,1,2)!=\"rs\") \$1=\"chr\" \$2 \":\" \$3;print}" | \
awk -f tryggve/order.awk | \
gzip -f > sumstats/PIVUS/PIVUS.{2}.gz'
ls /data/stefang/pivus_ulsam/ulsam* | \
xargs -l -x basename | sed 's/ulsam.all.//g;s/.20161128.txt.gz//g' | \
sort | \
join - inf1_gene | \
cut -d ' ' -f1,3 | \
parallel -j$threads -C' ' '
gunzip -c /data/stefang/pivus_ulsam/ulsam.all.{1}.20161128.txt.gz | \
awk "{if(NR>1&&substr(\$1,1,2)!=\"rs\") \$1=\"chr\" \$2 \":\" \$3;print}" | \
awk -f tryggve/order.awk | \
gzip -f > sumstats/ULSAM/ULSAM.{2}.gz'
}
function ORCADES()
{
cat sumstats/ORCADES.list | \
parallel -j$threads -C' ' '
gunzip -c /data/erimac/ORCADES/ORCADES.INF1.{1}_rank.tsv.gz | \
awk "NR==1||\$13>0.4" | \
awk -f tryggve/order.awk | \
gzip -f > sumstats/ORCADES/ORCADES.{2}.gz'
}
function VIS()
{
cat sumstats/VIS.list | \
parallel -j$threads -C' ' '
gunzip -c /data/erimac/VIS/VIS.INF1.{1}_rank.tsv.gz | \
awk "NR==1||\$13>0.4" | \
awk -f tryggve/order.awk | \
gzip -f > sumstats/VIS/VIS.{2}.gz'
}
function RECOMBINE()
{
export rt=/data/jinhua/data/RECOMBINE/RECOMBINE_pQTLs__meta_scallop
export rt=/data/jinhua/data/RECOMBINE/RECOMBINE_INF1_pQTLs_updated_13thMarch_19
sort -k2,2 inf1.list > inf1.tmp
sort -k3,3 sumstats/RECOMBINE.list | \
join -13 -22 - inf1.tmp | \
parallel -j$threads --env rt -C' ' '
(
for chr in `seq 22`
do
if [ $chr -eq 1 ]; then
gunzip -c $rt/{2}_{3}___{1}_chr${chr}_RECOMBINE.txt.gz | \
awk "NR == 1"
fi
gunzip -c $rt/{2}_{3}___{1}_chr${chr}_RECOMBINE.txt.gz | \
awk "NR > 1"
done
) | \
awk "NR==1||(\$16>0.3){sub(/EFFECT_ALL_FQ/,\"CODE_ALL_FQ\",\$11);print}" | \
sed "s/ /\t/g" | \
cut -f3-7,9-17 | \
awk -f tryggve/order.awk | \
gzip -f > sumstats/RECOMBINE/RECOMBINE.{4}.gz'
}
function STABILITY()
{
export STABILITY=/data/niceri/Stability_INF1
sort -k3,3 sumstats/STABILITY.list | \
join -13 -21 - work/STABILITY.N | \
parallel -j$threads --env STABILITY -C' ' '
(
for chr in `seq 22`; do zgrep -v -w SNPID $STABILITY/STABILITY_{2}_{3}_chr${chr}.txt.gz; done
) | \
awk -vOFS="\t" -vN={4} -f tryggve/STABILITY.awk | \
awk -f tryggve/order.awk | \
gzip -f > sumstats/STABILITY/STABILITY.{1}.gz'
}
function STANLEY_lah1()
{
export STANLEY_lah1=/data/andmala/STANLEY_20180911
export N=344
cut -d' ' -f1-3 sumstats/STANLEY.list | \
parallel -j$threads --env STANLEY_lah1 --env N -C' ' '
(
for chr in `seq 22`; do gunzip -c $STANLEY_lah1/STANLEY_lah1_inf_chr${chr}_pheno{1}.txt.assoc.dosage.gz; done
) | \
awk "NR==1||\$2!=SNP" | \
awk -vN=$N -f tryggve/STANLEY.awk | \
awk -f tryggve/order.awk | \
gzip -f > sumstats/STANLEY/STANLEY_lah1.{2}.gz'
}
function STANLEY_swe6()
{
export STANLEY_swe6=/data/andmala/STANLEY_20180911//swe6_inf
export N=300
cut -d' ' -f1-3 sumstats/STANLEY.list | \
parallel -j$threads --env STANLEY_swe6 --env N -C' ' '
(
for chr in `seq 22`; do gunzip -c $STANLEY_swe6/STANLEY_swe6_inf_chr${chr}_pheno{1}.txt.assoc.dosage.gz; done
) | \
awk "NR==1||\$2!=SNP" | \
awk -vN=$N -f tryggve/STANLEY.awk | \
awk -f tryggve/order.awk | \
gzip -f > sumstats/STANLEY/STANLEY_swe6.{2}.gz'
}
function checklines()
# to check for number of SNPs for all proteins in a particular study
# usage checklines KORA 3
# where the protein names are the 3rd column in KORA.list
{
export study=$1
export col=$2
parallel --env study --env col -C' ' '
echo $study-{}
gunzip -c sumstats/$study/${study}.{}.gz | \
wc -l' ::: $(cut -d" " -f$col sumstats/$study.list)
}
function turbo()
{
parallel -j5 -C' ' '
export s={1}
export p={2}
export g=$(grep -w {2} inf1.gene | cut -d" " -f3)
zcat sumstats/${s}/${s}.${p}.gz | \
awk "NR>1&&!/CHR/{print \$2,\$3,\$11}" | \
gzip -f > ${s}.${p}.gz
(
zcat glist.gz | \
head -1
zgrep -w $g glist.gz
) | \
gzip -f > ${s}.${p}.glist.gz
# Manhattan
R --slave --vanilla --args \
input_data_path=${s}.${p}.gz \
output_data_rootname=${s}.${p}.manhattan \
custom_peak_annotation_file_path=${s}.${p}.glist.gz \
reference_file_path=cardio/turboman_hg19_reference_data.rda \
pvalue_sign=5e-10 \
plot_title="Manhattan plot" < cardio/turboman.r
# QQ
R --slave --vanilla --args \
input_data_path=${s}.${p}.gz \
output_data_rootname=${s}.${p}.qq \
plot_title="Q-Q plot" < cardio/turboqq.r
rm ${s}.${p}.gz ${s}.${p}.glist.gz
' ::: INTERVAL BioFinder EGCUT MadCam KORA NSPHS ORCADES RECOMBINE STABILITY STANLEY VIS ::: $(cut -d' ' -f1 prot.list)
}
$1