-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstep6-regionMatrix.sh
executable file
·98 lines (75 loc) · 1.87 KB
/
step6-regionMatrix.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
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
#!/bin/sh
## Usage
# sh step6-regionMatrix.sh brainspan
# Define variables
EXPERIMENT=$1
SHORT="regMat-${EXPERIMENT}"
# Directories
ROOTDIR=/dcl01/lieber/ajaffe/derRuns/derSupplement
MAINDIR=${ROOTDIR}/${EXPERIMENT}
WDIR=${MAINDIR}/regionMatrix
if [[ "${EXPERIMENT}" == "brainspan" ]]
then
CUTOFFS="0.1 0.25"
RLENGTH=100
else
echo "Specify a valid experiment: brainspan"
fi
# Construct shell files
for CUTOFF in ${CUTOFFS}
do
for chrnum in 22 21 Y 20 19 18 17 16 15 14 13 12 11 10 9 8 X 7 6 5 4 3 2 1
do
chr="chr${chrnum}"
sname="${SHORT}-cut-${CUTOFF}-${chr}"
echo "Creating script ${sname}"
cat > ${ROOTDIR}/.${sname}.sh <<EOF
#!/bin/bash
#$ -cwd
#$ -m e
#$ -l mem_free=70G,h_vmem=90G,h_fsize=30G
#$ -N ${sname}
#$ -hold_jid fullCov-${EXPERIMENT}
echo "**** Job starts ****"
date
# Make logs directory
mkdir -p ${WDIR}/logs
# Load coverage & get region matrix
cd ${WDIR}
module load R/3.3
Rscript ${ROOTDIR}/step6-regionMatrix.R -m "${MAINDIR}" -c "${chr}" -r ${RLENGTH} -t ${CUTOFF}
## Move log files into the logs directory
mv ${ROOTDIR}/${sname}.* ${WDIR}/logs/
echo "**** Job ends ****"
date
EOF
call="qsub .${sname}.sh"
echo $call
$call
done
sname="${SHORT}-cut-${CUTOFF}-merge"
echo "Creating script for merging the regionMatrix results for cutoff ${CUTOFF}"
cat > ${ROOTDIR}/.${sname}.sh <<EOF
#!/bin/bash
#$ -cwd
#$ -m e
#$ -l mem_free=100G,h_vmem=120G,h_fsize=40G
#$ -N ${sname}
#$ -hold_jid ${SHORT}-cut-${CUTOFF}-chr*
echo "**** Job starts ****"
date
# Make logs directory
mkdir -p ${WDIR}/logs
# Combine results
cd ${WDIR}
module load R/3.3
Rscript ${ROOTDIR}/step6b-regionMatrix-merge.R -t ${CUTOFF}
## Move log files into the logs directory
mv ${ROOTDIR}/${sname}.* ${WDIR}/logs/
echo "**** Job ends ****"
date
EOF
call="qsub .${sname}.sh"
echo $call
$call
done