-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpcangsd_hwe.sh
43 lines (38 loc) · 1.04 KB
/
pcangsd_hwe.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
#!/bin/bash
#
# Usage:
# pcangsd_hwe.sh <indir> <outdir> <min_maf> <ncpus>
#
# Description:
# Calculate a covariance matrix for SNPs filtering out those that
# strongly deviate from the Hardy-Weinberg equilibrium using PCAngsd.
#
# Requirements:
# pcangsd
# python3
# path to PCAngsd
pcangsd=${HOME}/software/pcangsd/pcangsd.py
# find genotype likelihoods (GL) file
gl=$(find $1 -name '*.beagle.gz')
# set output name and directory
out=$2/$(basename ${gl%.beagle.gz})
# calculate covariance matrix, estimate per-site inbreeding coefficients, and
# perform likehood ratio tests for HWE
python3 ${pcangsd} \
-beagle ${gl} \
-minMaf $3 \
-o ${out} \
-inbreedSites \
-threads $4 \
&> ${out}.pcangsd.log
# add delimiter between logs to 'pcangsd.log'
echo -e "\n---\n" >> ${out}.pcangsd.log
# calculate covariance matrix with HWE filter
python3 ${pcangsd} \
-beagle ${gl} \
-minMaf $3 \
-o ${out}.hwe_filter \
-hwe ${out}.lrt.sites.npy \
-hwe_tole 1e-6 \
-threads $4 \
&>> ${out}.pcangsd.log