-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun
More file actions
executable file
·119 lines (102 loc) · 3.54 KB
/
run
File metadata and controls
executable file
·119 lines (102 loc) · 3.54 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/bash
set -euo pipefail # Set bash options to exit on error, unset variable or failed command in a pipeline
function on_failure {
echo "The script" "${0##*/}" "has failed" 2>&1 \
| tee -a "$APP_PATH"/"$ANN_OUT_DIR"/celltypist-log.txt
}
trap on_failure ERR # Set a trap to call the on_failure function if an error occurs
source src/getopts # Source the getopts script to parse command line options
APP_PATH=$(pwd -P) # Get the absolute path of the current working directory
if [[ -z "${INPUT:-}" || -z "${MODEL:-}" ]]
then
echo "ERROR: Both INPUT (-i) and MODEL (-m) arguments must be provided" 2>&1 \
| tee -a "$APP_PATH"/"$ANN_OUT_DIR"/celltypist-log.txt
exit 1
fi
SUFFIX="${MODEL##*.}"
TIMESTAMP=$(date +"%Y-%m-%d_%H.%M.%S") # Get the current date and time in a specific format
ANN_OUT_DIR="output/output_$TIMESTAMP" # Set the output directory path
mkdir -p "$ANN_OUT_DIR" "$ANN_OUT_DIR"/tmp # Create the output and temporary directories
echo ""
echo "Housekeeping complete" 2>&1 \
| tee -a "$APP_PATH"/"$ANN_OUT_DIR"/celltypist-log.txt
echo ""
# Executing matrix conversion
singularity run \
--no-home \
--pwd "$APP_PATH" \
-B "$APP_PATH":"$APP_PATH" \
-B "${INPUT}":"${INPUT}" \
docker://public.ecr.aws/chobiolab/seurat-base:v4-r2 \
Rscript "$APP_PATH"/src/matrix-convert.R \
"$APP_PATH"/"$ANN_OUT_DIR"/tmp \
"${INPUT}" 2>&1 \
| tee -a "$APP_PATH"/"$ANN_OUT_DIR"/celltypist-log.txt
echo ""
echo "Counts sparse matrix to expression matrix conversion complete" 2>&1 \
| tee -a "$APP_PATH"/"$ANN_OUT_DIR"/celltypist-log.txt
echo ""
# Executing celltypist
if [[ -f "${MODEL}" ]]
then
MODEL_FILE="${MODEL##*/}"
MODEL_PATH="${MODEL%/*}"
singularity run \
-B "$APP_PATH":/data \
-B "${MODEL_PATH}":/opt/celltypist/data/models \
docker://quay.io/teichlab/celltypist:latest \
celltypist \
--indata /data/"$ANN_OUT_DIR"/tmp/counts.csv \
--model "${MODEL_FILE}" \
--outdir /data/"$ANN_OUT_DIR" \
--majority-voting 2>&1 \
| tee -a "$APP_PATH"/"$ANN_OUT_DIR"/celltypist-log.txt
else
singularity run \
-B "$APP_PATH":/data \
docker://quay.io/teichlab/celltypist:latest \
celltypist \
--indata /data/"$ANN_OUT_DIR"/tmp/counts.csv \
--model "${MODEL}".pkl \
--outdir /data/"$ANN_OUT_DIR" \
--majority-voting 2>&1 \
| tee -a "$APP_PATH"/"$ANN_OUT_DIR"/celltypist-log.txt
fi
echo ""
echo "CellTypist annotation prediction complete" 2>&1 \
| tee -a "$APP_PATH"/"$ANN_OUT_DIR"/celltypist-log.txt
echo ""
# Executing application of predicted labels back onto input object
singularity run \
--no-home \
--pwd "$APP_PATH" \
-B "$APP_PATH":"$APP_PATH" \
-B "${INPUT}":"${INPUT}" \
docker://public.ecr.aws/chobiolab/seurat-base:v4-r2 \
Rscript "$APP_PATH"/src/apply-ann.R \
"$APP_PATH"/"$ANN_OUT_DIR" \
"${INPUT}" \
"$WORKERS" \
"$RAM" 2>&1 \
| tee -a "$APP_PATH"/"$ANN_OUT_DIR"/celltypist-log.txt
echo ""
echo "Application of predicted labels back onto input object complete" 2>&1 \
| tee -a "$APP_PATH"/"$ANN_OUT_DIR"/celltypist-log.txt
echo ""
singularity run \
--no-home \
--pwd "$APP_PATH" \
-B "$APP_PATH":"$APP_PATH" \
docker://public.ecr.aws/chobiolab/seurat-base:v4-r2 \
Rscript "$APP_PATH"/src/qc.R \
"$APP_PATH"/"$ANN_OUT_DIR" \
| tee -a "$APP_PATH"/"$ANN_OUT_DIR"/celltypist-log.txt
echo ""
echo "QC metrics generated" 2>&1 \
| tee -a "$APP_PATH"/"$ANN_OUT_DIR"/celltypist-log.txt
echo ""
rm -rf "$ANN_OUT_DIR"/tmp # Remove the temporary directory
echo ""
echo "Annotation routine complete" 2>&1 \
| tee -a "$APP_PATH"/"$ANN_OUT_DIR"/celltypist-log.txt
echo ""