-
Notifications
You must be signed in to change notification settings - Fork 3
/
filter.sh
executable file
·36 lines (25 loc) · 956 Bytes
/
filter.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
#!/bin/bash
#$ -N filter
#$ -t 1-22
#$ -S /bin/bash
#$ -cwd
#$ -o job_reports/
#$ -e job_reports/
#$ -l h_vmem=20G
# This script will take a binary plink file and:
# 1. extract chromosome to text file
# 2. align to reference
set -e
if [[ -n "${1}" ]]; then
echo ${1}
SGE_TASK_ID=${1}
fi
chr=${SGE_TASK_ID}
wd=`pwd`"/"
source parameters.sh
# Filter based on maf and info thresholds
# gzip ${impdatadir}${plink1kg}_info.txt
zcat ${impdatadir}${plink1kg}_info.txt.gz | awk -v minmaf=${filterMAF} -v mininfo=${filterInfo} '{ if(NR == 1 || ($4 >= minmaf && $4 <= (1-minmaf) && $5 >= mininfo)) {print $0}}' | gzip > ${impdatadir}${filtername}_info.txt.gz
# Extract SNPs for plink to use
zcat ${impdatadir}${filtername}_info.txt.gz | tail -n +2 | cut -d " " -f 2 | uniq > ${impdatadir}${filtername}.keepsnps
${plink} --noweb --bfile ${impdatadir}${plink1kg} --extract ${impdatadir}${filtername}.keepsnps --make-bed --out ${impdatadir}${filtername}