This repository has been archived by the owner on Apr 20, 2024. It is now read-only.
forked from llandsmeer/QTLToolKit2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prepare_QTL.sh
executable file
·179 lines (168 loc) · 11.7 KB
/
prepare_QTL.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
#!/bin/bash
#
# You can use the variables below (indicated by "#$") to set some things for the
# submission system.
#$ -S /bin/bash # the type of BASH you'd like to use
#$ -N prepare_QTL_v1_1_0 # the name of this script
# -hold_jid some_other_basic_bash_script # the current script (basic_bash_script) will hold until some_other_basic_bash_script has finished
#$ -o /hpc/dhl_ec/svanderlaan/projects/prepare_QTL_v1_1_0.log # the log file of this job
#$ -e /hpc/dhl_ec/svanderlaan/projects/prepare_QTL_v1_1_0.errors # the error file of this job
#$ -l h_rt=04:00:00 # h_rt=[max time, e.g. 02:02:01] - this is the time you think the script will take
#$ -l h_vmem=16G # h_vmem=[max. mem, e.g. 45G] - this is the amount of memory you think your script will use
# -l tmpspace=64G # this is the amount of temporary space you think your script will use
#$ -M [email protected] # you can send yourself emails when the job is done; "-M" and "-m" go hand in hand
#$ -m ea # you can choose: b=begin of job; e=end of job; a=abort of job; s=suspended job; n=no mail is send
#$ -cwd # set the job start to the current directory - so all the things in this script are relative to the current directory!!!
#
# Another useful tip: you can set a job to run after another has finished. Name the job
# with "-N SOMENAME" and hold the other job with -hold_jid SOMENAME".
# Further instructions: https://wiki.bioinformatics.umcutrecht.nl/bin/view/HPC/HowToS#Run_a_job_after_your_other_jobs
#
# It is good practice to properly name and annotate your script for future reference for
# yourself and others. Trust me, you'll forget why and how you made this!!!
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo " PREPARE DATA FOR QTL ANALYSES"
echo ""
echo ""
echo "* Written by : Sander W. van der Laan"
echo "* E-mail : [email protected]"
echo "* Last update : 2018-07-26"
echo "* Version : v1.3.1"
echo ""
echo "* Description : This script will prepare biobank data for use with QTLTool."
echo ""
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo "Today's: "$(date)
echo ""
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo "The following directories are set."
SOFTWARE="/hpc/local/CentOS7/dhl_ec/software"
QCTOOL=$SOFTWARE/qctool_v1.5
SNPTEST25=$SOFTWARE/snptest_v2.5.2
AEGSORIGINALS="/hpc/dhl_ec/data/_ae_originals"
AAAGSORIGINALS="/hpc/dhl_ec/data/_aaa_originals"
CTMMGSORIGINALS="/hpc/dhl_ec/data/_ctmm_originals"
AEGSIMPUTEDDATA=${AEGSORIGINALS}/AEGS_COMBINED_IMPUTE2_1000Gp3_GoNL5
AAAGSIMPUTEDDATA=${AAAGSORIGINALS}/AAAGS_IMPUTE2_1000Gp3_GoNL5
CTMMGSIMPUTEDDATA=${CTMMGSORIGINALS}/CTMMAxiomTX_IMPUTE2_1000Gp3_GoNL5
PHENOTYPESAEMS450K1=${AEGSORIGINALS}/AEMS450K1
PHENOTYPESAEMS450K2=${AEGSORIGINALS}/AEMS450K2
MYDIR="/hpc/dhl_ec/svanderlaan"
ROOTDIR=${MYDIR}/projects
### SETTINGS QSUB
QSUBTIME="08:00:00"
QSUBMEM="16G"
QSUBMAIL="[email protected]"
QSUBMAILSETTINGS="ea"
echo "Original AEGS data directory________________ ${AEGSORIGINALS}"
echo "Original AAAGS data directory_______________ ${AAAGSORIGINALS}"
echo "Original CTMMGS data directory______________ ${CTMMGSORIGINALS}"
echo "Imputed AEGS data directory_________________ ${AEGSIMPUTEDDATA}"
echo "Imputed AAAGS data directory________________ ${AAAGSIMPUTEDDATA}"
echo "Imputed CTMMGS data directory_______________ ${CTMMGSIMPUTEDDATA}"
echo "Phenotype data directory AEMS450K1__________ ${PHENOTYPESAEMS450K1}"
echo "Phenotype data directory AEMS450K2__________ ${PHENOTYPESAEMS450K2}"
echo "SNPTEST directory___________________________ ${SNPTEST25}"
echo "Software directory__________________________ ${SOFTWARE}"
echo "Where \"qctool\" resides______________________ ${QCTOOL}"
echo ""
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo "Convert the phenotype files and index these..."
echo "* AEMS450K1..."
echo " >>> copying data <<<"
echo ""
cp -v ${ROOTDIR}/mQTL/aems450k1_QC_443872_plaques.bed ${PHENOTYPESAEMS450K1}/
cp -v ${ROOTDIR}/mQTL/aems450k1_QC_443872_blood.bed ${PHENOTYPESAEMS450K1}/
echo ""
echo " >>> plaque data <<<"
echo ""
${SOFTWARE}/bgzip_v1.3 ${PHENOTYPESAEMS450K1}/aems450k1_QC_443872_plaques.bed && ${SOFTWARE}/tabix_v1.3 -p bed ${PHENOTYPESAEMS450K1}/aems450k1_QC_443872_plaques.bed.gz
echo " --- heads ---"
zcat ${PHENOTYPESAEMS450K1}/aems450k1_QC_443872_plaques.bed.gz | head
echo " --- tails ---"
zcat ${PHENOTYPESAEMS450K1}/aems450k1_QC_443872_plaques.bed.gz | tail
echo ""
echo " >>> blood data <<<"
${SOFTWARE}/bgzip_v1.3 ${PHENOTYPESAEMS450K1}/aems450k1_QC_443872_blood.bed && ${SOFTWARE}/tabix_v1.3 -p bed ${PHENOTYPESAEMS450K1}/aems450k1_QC_443872_blood.bed.gz
echo " --- heads ---"
zcat ${PHENOTYPESAEMS450K1}/aems450k1_QC_443872_blood.bed.gz | tail
echo " --- tails ---"
zcat ${PHENOTYPESAEMS450K1}/aems450k1_QC_443872_blood.bed.gz | tail
echo ""
echo "* AEMS450K2..."
echo " >>> plaque data <<<"
${SOFTWARE}/bgzip_v1.3 ${PHENOTYPESAEMS450K2}/aems450k2_QC_443872_plaques.bed && ${SOFTWARE}/tabix_v1.3 -p bed ${PHENOTYPESAEMS450K2}/aems450k2_QC_443872_plaques.bed.gz
echo " --- heads ---"
zcat ${PHENOTYPESAEMS450K2}/aems450k2_QC_443872_plaques.bed.gz | head
echo " --- tails ---"
zcat ${PHENOTYPESAEMS450K2}/aems450k2_QC_443872_plaques.bed.gz | tail
echo ""
echo " >>> blood data <<<"
${SOFTWARE}/bgzip_v1.3 ${PHENOTYPESAEMS450K2}/aems450k2_QC_443872_blood.bed && ${SOFTWARE}/tabix_v1.3 -p bed ${PHENOTYPESAEMS450K2}/aems450k2_QC_443872_blood.bed.gz
echo " --- heads ---"
zcat ${PHENOTYPESAEMS450K2}/aems450k2_QC_443872_blood.bed.gz | tail
echo " --- tails ---"
zcat ${PHENOTYPESAEMS450K2}/aems450k2_QC_443872_blood.bed.gz | tail
echo ""
echo ""
echo "Converting to VCF...."
echo "* AEGS..."
for CHR in $(seq 1 22) X; do
echo "* submitting conversion job for chromosome ${CHR}..."
echo "${QCTOOL} -g ${AEGSIMPUTEDDATA}/aegs_combo_1kGp3GoNL5_RAW_chr${CHR}.bgen -s ${AEGSIMPUTEDDATA}/aegs_combo_1kGp3GoNL5_RAW_chr${CHR}.sample -og ${AEGSIMPUTEDDATA}/aegs_combo_1kGp3GoNL5_RAW_chr${CHR}.vcf" > ${AEGSIMPUTEDDATA}/prep.QTL.makeVCF.aegs_combo_1kGp3GoNL5_RAW.chr${CHR}.sh
qsub -S /bin/bash -N prep.QTL.makeVCF.aegs_combo_1kGp3GoNL5_RAW.chr${CHR} -e ${AEGSIMPUTEDDATA}/prep.QTL.makeVCF.aegs_combo_1kGp3GoNL5_RAW.chr${CHR}.errors -o ${AEGSIMPUTEDDATA}/prep.QTL.makeVCF.aegs_combo_1kGp3GoNL5_RAW.chr${CHR}.log -l h_rt=${QSUBTIME} -l h_vmem=${QSUBMEM} -M ${QSUBMAIL} -m ${QSUBMAILSETTINGS} -cwd ${AEGSIMPUTEDDATA}/prep.QTL.makeVCF.aegs_combo_1kGp3GoNL5_RAW.chr${CHR}.sh
echo ""
done
echo "* AAAGS..."
for CHR in $(seq 1 22) X; do
echo "* submitting conversion job for chromosome ${CHR}..."
echo "${QCTOOL} -g ${AAAGSIMPUTEDDATA}/aaags_1kGp3GoNL5_RAW_chr${CHR}.bgen -s ${AAAGSIMPUTEDDATA}/aaags_1kGp3GoNL5_RAW_chr${CHR}.sample -og ${AAAGSIMPUTEDDATA}/aaags_1kGp3GoNL5_RAW_chr${CHR}.vcf" > ${AAAGSIMPUTEDDATA}/prep.QTL.makeVCF.aaags_1kGp3GoNL5_RAW.chr${CHR}.sh
qsub -S /bin/bash -N prep.QTL.makeVCF.aaags_1kGp3GoNL5_RAW.chr${CHR} -e ${AAAGSIMPUTEDDATA}/prep.QTL.makeVCF.aaags_1kGp3GoNL5_RAW.chr${CHR}.errors -o ${AAAGSIMPUTEDDATA}/prep.QTL.makeVCF.aaags_1kGp3GoNL5_RAW.chr${CHR}.log -l h_rt=${QSUBTIME} -l h_vmem=${QSUBMEM} -M ${QSUBMAIL} -m ${QSUBMAILSETTINGS} -cwd ${AAAGSIMPUTEDDATA}/prep.QTL.makeVCF.aaags_1kGp3GoNL5_RAW.chr${CHR}.sh
echo ""
done
echo "* CTMMGS..."
for CHR in $(seq 1 22) X; do
echo "* submitting conversion job for chromosome ${CHR}..."
echo "${QCTOOL} -g ${CTMMGSIMPUTEDDATA}/ctmm_1kGp3GoNL5_RAW_chr${CHR}.bgen -s ${CTMMGSIMPUTEDDATA}/ctmm_1kGp3GoNL5_RAW_chr${CHR}.sample -og ${CTMMGSIMPUTEDDATA}/ctmm_1kGp3GoNL5_RAW_chr${CHR}.vcf" > ${CTMMGSIMPUTEDDATA}/prep.QTL.makeVCF.ctmm_1kGp3GoNL5_RAW.chr${CHR}.sh
qsub -S /bin/bash -N prep.QTL.makeVCF.ctmm_1kGp3GoNL5_RAW.chr${CHR} -e ${CTMMGSIMPUTEDDATA}/prep.QTL.makeVCF.ctmm_1kGp3GoNL5_RAW.chr${CHR}.errors -o ${CTMMGSIMPUTEDDATA}/prep.QTL.makeVCF.ctmm_1kGp3GoNL5_RAW.chr${CHR}.log -l h_rt=${QSUBTIME} -l h_vmem=${QSUBMEM} -M ${QSUBMAIL} -m ${QSUBMAILSETTINGS} -cwd ${CTMMGSIMPUTEDDATA}/prep.QTL.makeVCF.ctmm_1kGp3GoNL5_RAW.chr${CHR}.sh
echo ""
done
echo ""
echo "Indexing VCF..."
echo "* AEGS..."
for CHR in $(seq 1 22) X; do
echo "* submitting indexing job for chromosome ${CHR}..."
echo "${SOFTWARE}/bgzip_v1.3 ${AEGSIMPUTEDDATA}/aegs_combo_1kGp3GoNL5_RAW_chr${CHR}.vcf && ${SOFTWARE}/tabix_v1.3 -p vcf ${AEGSIMPUTEDDATA}/aegs_combo_1kGp3GoNL5_RAW_chr${CHR}.vcf.gz" > ${AEGSIMPUTEDDATA}/prep.QTL.indexVCF.aegs_combo_1kGp3GoNL5_RAW.chr${CHR}.sh
qsub -S /bin/bash -N prep.QTL.indexVCF.aegs_combo_1kGp3GoNL5_RAW.chr${CHR} -hold_jid prep.QTL.makeVCF.aegs_combo_1kGp3GoNL5_RAW.chr${CHR} -e ${AEGSIMPUTEDDATA}/prep.QTL.indexVCF.aegs_combo_1kGp3GoNL5_RAW.chr${CHR}.errors -o ${AEGSIMPUTEDDATA}/prep.QTL.indexVCF.aegs_combo_1kGp3GoNL5_RAW.chr${CHR}.log -l h_rt=${QSUBTIME} -l h_vmem=${QSUBMEM} -M ${QSUBMAIL} -m ${QSUBMAILSETTINGS} -cwd ${AEGSIMPUTEDDATA}/prep.QTL.indexVCF.aegs_combo_1kGp3GoNL5_RAW.chr${CHR}.sh
echo ""
done
echo "* AAAGS..."
for CHR in $(seq 1 22) X; do
echo "* submitting indexing job for chromosome ${CHR}..."
echo "${SOFTWARE}/bgzip_v1.3 ${AAAGSIMPUTEDDATA}/aaags_1kGp3GoNL5_RAW_chr${CHR}.vcf && ${SOFTWARE}/tabix_v1.3 -p vcf ${AAAGSIMPUTEDDATA}/aaags_1kGp3GoNL5_RAW_chr${CHR}.vcf.gz" > ${AAAGSIMPUTEDDATA}/prep.QTL.indexVCF.aaags_1kGp3GoNL5_RAW.chr${CHR}.sh
qsub -S /bin/bash -N prep.QTL.indexVCF.aaags_1kGp3GoNL5_RAW.chr${CHR} -hold_jid prep.QTL.makeVCF.aaags_1kGp3GoNL5_RAW.chr${CHR} -e ${AAAGSIMPUTEDDATA}/prep.QTL.indexVCF.aaags_1kGp3GoNL5_RAW.chr${CHR}.errors -o ${AAAGSIMPUTEDDATA}/prep.QTL.indexVCF.aaags_1kGp3GoNL5_RAW.chr${CHR}.log -l h_rt=${QSUBTIME} -l h_vmem=${QSUBMEM} -M ${QSUBMAIL} -m ${QSUBMAILSETTINGS} -cwd ${AAAGSIMPUTEDDATA}/prep.QTL.indexVCF.aaags_1kGp3GoNL5_RAW.chr${CHR}.sh
echo ""
done
echo "* CTMMGS..."
for CHR in $(seq 1 22) X; do
echo "* submitting indexing job for chromosome ${CHR}..."
echo "${SOFTWARE}/bgzip_v1.3 ${CTMMGSIMPUTEDDATA}/ctmm_1kGp3GoNL5_RAW_chr${CHR}.vcf && ${SOFTWARE}/tabix_v1.3 -p vcf ${CTMMGSIMPUTEDDATA}/ctmm_1kGp3GoNL5_RAW_chr${CHR}.vcf.gz" > ${CTMMGSIMPUTEDDATA}/prep.QTL.indexVCF.ctmm_1kGp3GoNL5_RAW.chr${CHR}.sh
qsub -S /bin/bash -N prep.QTL.indexVCF.ctmm_1kGp3GoNL5_RAW.chr${CHR} -hold_jid prep.QTL.makeVCF.ctmm_1kGp3GoNL5_RAW.chr${CHR} -e ${CTMMGSIMPUTEDDATA}/prep.QTL.indexVCF.ctmm_1kGp3GoNL5_RAW.chr${CHR}.errors -o ${CTMMGSIMPUTEDDATA}/prep.QTL.indexVCF.ctmm_1kGp3GoNL5_RAW.chr${CHR}.log -l h_rt=${QSUBTIME} -l h_vmem=${QSUBMEM} -M ${QSUBMAIL} -m ${QSUBMAILSETTINGS} -cwd ${CTMMGSIMPUTEDDATA}/prep.QTL.indexVCF.ctmm_1kGp3GoNL5_RAW.chr${CHR}.sh
echo ""
done
### Reference:
### https://stackoverflow.com/questions/39221524/how-to-sort-out-duplicates-from-a-massive-list-using-sort-uniq-or-awk?rq=1
echo "* First grep all variants from input and extract *duplicated* variants, because these are multi-allelic, "
echo " these will be excluded. "
echo " > extracting... "
zcat ${CTMMGSIMPUTEDDATA}/ctmm_1kGp3GoNL5_RAW.stats.gz | awk '{ print $2 }' | tail -n +2 > ${CTMMGSIMPUTEDDATA}/ctmm_1kGp3GoNL5_RAW.allvariants.txt
echo " > sorting... "
sort ${CTMMGSIMPUTEDDATA}/ctmm_1kGp3GoNL5_RAW.allvariants.txt > ${CTMMGSIMPUTEDDATA}/ctmm_1kGp3GoNL5_RAW.allvariants.sorted.txt
echo " > printing duplicate, multi-allelic variants... "
uniq -d ${CTMMGSIMPUTEDDATA}/ctmm_1kGp3GoNL5_RAW.allvariants.sorted.txt > ${CTMMGSIMPUTEDDATA}/ctmm_1kGp3GoNL5_RAW.allvariants.duplicates.txt
echo " > removing intermediate files, keeping unique, duplicate, multi-allelic variant lists... "
rm -v ${CTMMGSIMPUTEDDATA}/ctmm_1kGp3GoNL5_RAW.allvariants.txt ${CTMMGSIMPUTEDDATA}/ctmm_1kGp3GoNL5_RAW.allvariants.sorted.txt
echo ""
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo "Wow. I'm all done buddy. What a job! let's have a beer!"
date