-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathproject_pc.sh
executable file
·66 lines (58 loc) · 1.7 KB
/
project_pc.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
#!/bin/bash
set -eu
################################################################################
# Please fill in the below variables
################################################################################
# Metadata
STUDY_NAME=""
ANALYST_LAST_NAME=""
DATE="$(date +'%Y%m%d')"
OUTNAME="${STUDY_NAME}.${ANALYST_LAST_NAME}.${DATE}"
################################################################################
# Location of downloaded input files
PCA_LOADINGS=""
PCA_AF=""
################################################################################
# Location of imputed genotype files
# [Recommended]
# PLINK 2 binary format: a prefix (with directories) of .pgen/.pvar/.psam files
PFILE=""
# [Acceptable]
# PLINK 1 binary format: a prefix of .bed/.bim/.fam files
BFILE=""
################################################################################
function error_exit() {
echo "${1:-"Unknown Error"}" 1>&2
exit 1
}
# Input checks
if [[ -z "${STUDY_NAME}" ]]; then
error_exit "Please specify \$STUDY_NAME."
fi
if [[ -z "${ANALYST_LAST_NAME}" ]]; then
error_exit "Please specify \$ANALYST_LAST_NAME."
fi
if [[ -z "${PCA_LOADINGS}" ]]; then
error_exit "Please specify \$PCA_LOADINGS."
fi
if [[ -z "${PCA_AF}" ]]; then
error_exit "Please specify \$PCA_AF."
fi
if [[ -n "${PFILE}" ]]; then
input_command="--pfile ${PFILE}"
elif [[ -n "${BFILE}" ]]; then
input_command="--bfile ${BFILE}"
else
error_exit "Either \$PFILE or \$BFILE should be specified"
fi
# Run plink2 --score
plink2 \
${input_command} \
--score ${PCA_LOADINGS} \
variance-standardize \
cols=-scoreavgs,+scoresums \
list-variants \
header-read \
--score-col-nums 3-12 \
--read-freq ${PCA_AF} \
--out ${OUTNAME}