forked from timknut/geno_imputation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalphaimpute_cluster_run.Rmd
357 lines (261 loc) · 9.02 KB
/
alphaimpute_cluster_run.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
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
### Scripts that run AlphaImpute on a cluster server
* The scripts can be modified
* Read the notes on the header of the following script
```bash
#!/bin/bash
#General code that runs AlphaImpute on a cluster server. It's very interactive so you can choose which part of alphaimpute you want to run. It requires the ende of the previous step in order to proceed with the following (e.g you need to wait until phasing is completed). I can add an hold option if you want so the script will keep the server constantly 'busy'. You can also have a script that will be able to operate in both ways....just let me know.
#Usually i prefer to do each step at a time because i can babysit the process and see if there are errors...but it's ok in both ways. The script will produce also a .log file for each step so you can track the errors.
#you can have the same directory or different directories. I used only one directory and i put all the executables as well as the Pedigree.txt file and the general AlphaImputeSpec.txt inside that directory.If you want two different directories you can put all the executables and the general AlphaImputeSpec.txt inside the home directory and the Pedigree.txt file inside the work directory.
#NOTE in this example i am using the version AlphaImputev1.5.5-57-gc610270 of AlphaImpute. You will need to change it if you are using another version.
#The qsub files (e.g. qsub301.sh) are files used to run the programs (AI,APhase,GeneProb). I made them instead of running the program directly from the script because doing so the code is more maintainable (aka you can change all the options you want inside the qsub file and the code will run without any problem)
export home="/exports/cmvm/eddie/eb/groups/hickey_group/pgottard/"
export work="/exports/cmvm/eddie/eb/groups/hickey_group/pgottard/"
export nCHR=29
#This script works for any nuber of chromosomes
echo "Choose the option:
1. Restart option 1
2. GeneProb
3. Restart option 2
4. Phasing
5. Restart option 3
6. GeneProb 2
7. Restart option 4
"
read PROG
if [ "$PROG" == "1" ]; then
echo "301 - Run AlphaImpute with restart option =1"
for ((i=1; i<=${nCHR}; i++)); do
(cd Chromosomes/ch${i}/ || exit
rm -f input.ped && ln -sf ${work}/Pedigree.txt input.ped
rm -f input.gen && ln -sf ch${i}_coded input.gen
rm -f AlphaImputev1.5.5-57-gc610270 && ln -sf ${home}/AlphaImputev1.5.5-57-gc610270 .
rm -f qsub301.sh && ln -sf ${home}/qsub301.sh .
a=`awk '{print NF}' ch${i}_coded | sort -nu | tail -n 1`
b=1
let c=$a-$b
cat ${home}/AlphaImputeSpec.txt | sed -e "s/XXNROFSNPXX/${c}/" \
-e "s/XXNRPROCAVXX/20/" \
-e "s/XXRESOPTXX/1/" \
-e "s/XXBYPASSXX/No/" > AlphaImputeSpec1.txt
ln -sf AlphaImputeSpec1.txt AlphaImputeSpec.txt
qsub -N S1ch${i} qsub301.sh )
done
cd ${work} || exit
elif [ "$PROG" == "2" ]; then
echo "302 - Run GeneProb"
echo
echo
for ((i=1; i<=${nCHR}; i++)); do
(cd Chromosomes/ch${i}/ || exit
for k in GeneProb/*; do
(if [ -d "${k}" ]; then
echo $k
cd ${k} || exit
rm -f GeneProbForAlphaImpute && ln -sf ${home}/GeneProbForAlphaImpute .
rm -f qsub302.sh && ln -sf ${home}/qsub302.sh .
G=$(echo $k | cut -c 18-)
qsub -N G1ch${i}${G} qsub302.sh
sleep 5s
fi )
done
cd ${work} || exit
)
done
cd ${work} || exit
elif [ "$PROG" == "3" ]; then
echo "303 - Run AlphaImpute with restart option =2"
echo
echo
for ((i=1; i<=${nCHR}; i++)); do
(cd Chromosomes/ch${i}/ || exit
rm -f input.ped && ln -sf ${work}/Pedigree.txt input.ped
rm -f input.gen && ln -sf ch${i}_coded input.gen
rm -f AlphaImputev1.5.5-57-gc610270 && ln -sf ${home}/AlphaImputev1.5.5-57-gc610270 .
rm -f qsub301.sh && ln -sf ${home}/qsub301.sh .
a=`awk '{print NF}' ch${i}_coded | sort -nu | tail -n 1`
b=1
let c=$a-$b
cat ${home}/AlphaImputeSpec.txt | sed -e "s/XXNROFSNPXX/${c}/" \
-e "s/XXNRPROCAVXX/20/" \
-e "s/XXRESOPTXX/2/" \
-e "s/XXBYPASSXX/No/" > AlphaImputeSpec2.txt
ln -sf AlphaImputeSpec2.txt AlphaImputeSpec.txt
qsub -N S2ch${i} qsub301.sh )
done
cd ${work} || exit
elif [ "$PROG" == "4" ]; then
echo "304 - Run alphaphase"
echo
echo
for ((i=1; i<=${nCHR}; i++)); do
(cd Chromosomes/ch${i}/ || exit
for p in Phasing/*; do
( if [ -d "${p}" ]; then
cd ${p} || exit
rm -f alphaphase && ln -sf ${home}/alphaphase .
rm -f qsub304.sh && ln -sf ${home}/qsub304.sh .
#while [ $(qstat | wc -l) -gt ${MAXJOBSPAR} ] || [ ! (grep FINISH ../../GeneProb_ch${j}.log ) ] ; do
#echo "Queue limit reached (${MAXJOBSPAR} jobs) or GeneProb not finish. Waiting ..."
#sleep 1m
#done
G=$(echo $p| cut -c 14-)
qsub -N AP2ch${i}p${G} qsub304.sh
sleep 3s
fi)
done
cd ${work} || exit
)
done
cd ${work} || exit
elif [ "$PROG" == "5" ]; then
echo "305 - Run AlphaImpute with restart option =3"
echo
echo
for ((i=1; i<=${nCHR}; i++)); do
(cd Chromosomes/ch${i}/ || exit
rm -f input.ped && ln -sf ${work}/Pedigree.txt input.ped
rm -f input.gen && ln -sf ch${i}_coded input.gen
rm -f AlphaImputev1.5.5-57-gc610270 && ln -sf ${home}/AlphaImputev1.5.5-57-gc610270 .
rm -f qsub301.sh && ln -sf ${home}/qsub301.sh .
a=`awk '{print NF}' ch${i}_coded | sort -nu | tail -n 1`
b=1
let c=$a-$b
cat ${home}/AlphaImputeSpec.txt | sed -e "s/XXNROFSNPXX/${c}/" \
-e "s/XXNRPROCAVXX/20/" \
-e "s/XXRESOPTXX/3/" \
-e "s/XXBYPASSXX/No/" > AlphaImputeSpec3.txt
ln -sf AlphaImputeSpec3.txt AlphaImputeSpec.txt
qsub -N S3ch${i} qsub301.sh )
done
cd ${work} || exit
elif [ "$PROG" == "6" ]; then
echo "305 - Run GeneProb...AGAIN -.-....why you are not using the HMM option ? :( "
echo
echo
for ((i=1; i<=${nCHR}; i++)); do
(cd Chromosomes/ch${i}/ || exit
for k in IterateGeneProb/*; do
(if [ -d "${k}" ]; then
echo $k
cd ${k} || exit
rm -f GeneProbForAlphaImpute && ln -sf ${home}/GeneProbForAlphaImpute .
rm -f qsub302.sh && ln -sf ${home}/qsub302.sh .
G=$(echo $k | cut -c 18-)
qsub -N G1ch${i}${G} qsub302.sh
sleep 5s
fi )
done
cd ${work} || exit
)
done
cd ${work} || exit
elif [ "$PROG" == "7" ]; then
echo "305 - Run AlphaImpute with restart option =4"
echo
echo
for ((i=1; i<=${nCHR}; i++)); do
(cd Chromosomes/ch${i}/ || exit
rm -f input.ped && ln -sf ${work}/Pedigree.txt input.ped
rm -f input.gen && ln -sf ch${i}_coded input.gen
rm -f AlphaImputev1.5.5-57-gc610270 && ln -sf ${home}/AlphaImputev1.5.5-57-gc610270 .
rm -f qsub301.sh && ln -sf ${home}/qsub301.sh .
a=`awk '{print NF}' ch${i}_coded | sort -nu | tail -n 1`
b=1
let c=$a-$b
cat ${home}/AlphaImputeSpec.txt | sed -e "s/XXNROFSNPXX/${c}/" \
-e "s/XXNRPROCAVXX/20/" \
-e "s/XXRESOPTXX/4/" \
-e "s/XXBYPASSXX/No/" > AlphaImputeSpec4.txt
ln -sf AlphaImputeSpec4.txt AlphaImputeSpec.txt
qsub -N S4ch${i} qsub301.sh )
done
cd ${work} || exit
fi
```
### The following scripts are used in the main script
* qsub301.sh runs AlphaImpute
* qsub302.sh runs GeneProb
* qsub304.sh runs AlphaPhase
## qsub301.sh
```bash
#!/bin/bash
########################################
# #
# GE job script for ECDF Cluster #
# #
########################################
#
# Grid Engine options
#$ -cwd
#$ -pe sharedmem 8
#$ -l h_vmem=32G
#$ -l h_rt=200:00:00
#$ -P roslin_hickey_group
# Standard report
echo "Working directory:"
pwd
date
export PATH=.:~/bin:$PATH
echo "Starting job:"
./AlphaImputev1.5.5-57-gc610270 > AlphaImpute.log
# Standard report
echo
pwd
date
```
## qsub302.sh
```bash
#!/bin/bash
########################################
# #
# GE job script for ECDF Cluster #
# #
########################################
#
# Grid Engine options
#$ -cwd
#$ -pe sharedmem 8
#$ -l h_vmem=32G
#$ -l h_rt=200:00:00
#$ -P roslin_hickey_group
# Standard report
echo "Working directory:"
pwd
date
export PATH=.:~/bin:$PATH
# Job
echo "Starting job:"
./GeneProbForAlphaImputeLinux > GeneProbForAlphaImputeLinux.log
# Standard report
echo
pwd
date
```
## qsub304.sh
```bash
#!/bin/bash
########################################
# #
# GE job script for ECDF Cluster #
# #
########################################
#
# Grid Engine options
#$ -cwd
#$ -pe sharedmem 8
#$ -l h_vmem=32G
#$ -l h_rt=200:00:00
#$ -P roslin_hickey_group
# Standard report
echo "Working directory:"
pwd
date
export PATH=.:~/bin:$PATH
# Job
echo "Starting job:"
./alphaphase> AlphaPhaseLinux.log
# Standard report
echo
pwd
date
```