-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathancestry
More file actions
executable file
·80 lines (53 loc) · 1.67 KB
/
ancestry
File metadata and controls
executable file
·80 lines (53 loc) · 1.67 KB
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
#!/bin/bash
# Step 1: Input Sanitation
# 1.1
REFPANEL=$1
# 1.2
# vcf/ped in current dir -> me.ped
input="$(ls | egrep -e ".vcf|.vcf.gz|.ped")"
echo $input
if [[ "$input" == *ped ]]
then
filename="$(echo $input | cut -f1 -d.)"
./plink --file $filename --recode --out me > run.log 2>error.log
elif [ "$input" == *vcf ] || [ "$input" == *gz ] ;
then
./plink --vcf $input --maf 0.05 --recode --out me > run.log 2>>error.log
else
echo No vcf/ped file found in the current directory
exit 1
fi
# 1.3
# me.ped -> me_binary.bed
./plink --file me --make-bed --out me_binary >> run.log 2>>error.log
# Step 2: Merging Efficiently
# me_binary.bed $REFPANEL.bed -> merge.bed
# 2.1
awk '{print $2;}' me_binary.bim | sort > me_binary.snps
awk '{print $2;}' reference_panel/$REFPANEL".bim" | sort > ref.snps
# 2.2
comm -12 me_binary.snps ref.snps > merging.snps
# 2.3
./plink --bfile reference_panel/$REFPANEL --bmerge me_binary --extract merging.snps -make-bed --out merge1 >>run.log 2>>error.log
# 2.4
./plink --bfile merge1 -geno 0.9 --make-bed --out merge >>run.log 2>>error.log
# Step 3: Preparing requisite files
# merge.bed -> merge.pop -> $pops
# 3.1
awk '{print $1}' merge.fam > merge1.pop
# 3.2
awk '{ if( $1=="FAM001" ) $1=" "; print $1; }' merge1.pop > merge.pop
# 3.3
pops="$(cat merge.pop | sort | uniq | wc -l)"
let pop=pops-1
# Step 4: Admixture analysis and plotting
# 4.1
./admixture -j5 --supervised merge.bed $pop >> run.log 2>>error.log >> run.log 2>>error.log
# 4.2
output="$(ls | egrep -e "$pop.Q")"
# 4.3
Rscript plots/plot.R $output 1>>error.log
# Review results and house keeping
open ancestry.png
echo
rm -f me_binary.snps ref.snps merging.snps