-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdoMAGMA_windows_onlygenes.sh
executable file
·41 lines (32 loc) · 1.42 KB
/
doMAGMA_windows_onlygenes.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
#!/usr/bin/env bash
#refgen is reference genome (.bim)
#genloc is location of genes
#pvalfile is the SNP/PVAL file
#genesets is the gene sets file
#outname is the output name
#myN is the sample number
homeDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [ "$(uname)" == "Darwin" ]; then
magmaDir=$homeDir/magma_mac
else
magmaDir=$homeDir/magma
fi
refgen=$1
genloc=$2
pvalfile=$3
outname=$4
myN=$5
#example:
#./doMAGMA.sh g1000.bim genloc pvalfile outname 16731
filename=$(basename "$refgen")
extension="${filename##*.}"
refgenbis="${refgen%.*}"
window1=$6
window2=$7
$magmaDir --annotate window=$window1,$window2 --snp-loc ${refgen} --gene-loc ${genloc} --out ${outname}
$magmaDir --bfile ${refgenbis} --pval ${pvalfile} N=$myN --gene-annot ${outname}.genes.annot --gene-model multi=snp-wise --out ${outname} --gene-settings snp-min-maf=0.01
awk '{if (f==1) {r[$1]=$5"\t"$6"\t"$8"\t"$9} else if (($1 in r)){print r[$1]"\t"$0}}' f=1 ${outname}.genes.out f=2 $homeDir/biomart_noLRG > ${outname}.genes.out.names
awk '{print $4"\t"$5"\t"$6"\t"$7"\t"$8"\t"$9"\t"$10"\t"$11"\t"$1}' ${outname}.genes.out.names | perl -e 'print sort { $a <=> $b } <>' - > ${outname}.gene_results;
grep "protein_coding" ${outname}.genes.out.names > ${outname}.genes.out.names.proteins
awk '{print $6"\t"$7"\t"$11"\t"$4}' ${outname}.genes.out.names.proteins > ${outname}.prot.tmp
mv ${outname}.prot.tmp ${outname}.genes.out.names.proteins