forked from xwang234/BEACON
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbca_extract_genotype2.sh
executable file
·68 lines (59 loc) · 2.41 KB
/
bca_extract_genotype2.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
#!/usr/bin/env bash
#split each chr into 2
plink=/fh/fast/stanford_j/Xiaoyu/Tools/plink-1.07-x86_64/plink1.9/plink
prefix="$1"
outfolder=/fh/fast/dai_j/BEACON/BEACON_GRANT/result/$prefix
if [[ ! -d "$outfolder" ]]; then mkdir "$outfolder"; fi
extract_vcf1(){
local chr="$1"
echo $chr
tabixreg=$outfolder/prediction_snps_tabix_chr${chr}_1.txt
#tabix -H /fh/fast/dai_j/BEACON/BEACON_GRANT/data/imputation/bca_1000g/chr${chr}.dose.vcf.gz >$outfolder/chr${chr}.select.dose.vcf
#xargs -a $tabixreg -I {} echo {} |more
xargs -a $tabixreg -I {} tabix -f /fh/fast/dai_j/BEACON/BEACON_GRANT/data/imputation/bca_1000g/chr${chr}.dose.vcf.gz {} >> $outfolder/chr${chr}_1.select.dose.vcf
}
extract_vcf2(){
local chr="$1"
echo $chr
tabixreg=$outfolder/prediction_snps_tabix_chr${chr}_2.txt
#tabix -H /fh/fast/dai_j/BEACON/BEACON_GRANT/data/imputation/bca_1000g/chr${chr}.dose.vcf.gz >$outfolder/chr${chr}.select.dose.vcf
#xargs -a $tabixreg -I {} echo {} |more
xargs -a $tabixreg -I {} tabix -f /fh/fast/dai_j/BEACON/BEACON_GRANT/data/imputation/bca_1000g/chr${chr}.dose.vcf.gz {} >> $outfolder/chr${chr}_2.select.dose.vcf
}
plink_geno(){
local chr="$1"
#echo $chr
vcffile=$outfolder/chr${chr}.test.select.dose.vcf
$plink --vcf $vcffile --const-fid 0 --snps-only --make-bed --out $outfolder/chr${chr}_select --memory 64
#cut -f 2 /fh/fast/dai_j/BEACON/BEACON_GRANT/data/imputation/bca_1000g/chr${chr}_select.bim | sort | uniq -d > plink.dups
#$plink --bfile $outfolder/chr${chr}_select --exclude plink.dups --make-bed --out $outfolder/chr${chr}_select
$plink --bfile $outfolder/chr${chr}_select --recodeA --out $outfolder/chr${chr}_select --memory 640
}
for chr in {1..22};
do
if [[ -f "$outfolder/prediction_snps_tabix_chr${chr}_1.txt" ]];
then
tabix -H /fh/fast/dai_j/BEACON/BEACON_GRANT/data/imputation/bca_1000g/chr${chr}.dose.vcf.gz >$outfolder/chr${chr}.head.select.dose.vcf
extract_vcf1 $chr &
extract_vcf2 $chr &
fi
done
wait
#combine 2 pieces in each chr
for chr in {1..22};
do
if [[ -f "$outfolder/prediction_snps_tabix_chr${chr}_1.txt" ]];
then
cat $outfolder/chr${chr}.head.select.dose.vcf $outfolder/chr${chr}_1.select.dose.vcf $outfolder/chr${chr}_2.select.dose.vcf >$outfolder/chr${chr}.test.select.dose.vcf
fi
done
#generate plink form
for chr in {1..22}
do
if [[ -f "$outfolder/prediction_snps_tabix_chr${chr}_1.txt" ]];
then
echo $chr
plink_geno $chr &
fi
done
wait