-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstarSolo.sh
executable file
·305 lines (236 loc) · 8.93 KB
/
starSolo.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
#!/bin/bash
usage(){
echo "Usage: bash" $0 "[-h] [-p arg] [-g arg] [-r arg]"
echo
echo "-------------------------------------------------------------------------------------------------------------------------------"
echo "[-h] --> Display Help"
echo "[-p] --> Project Identifier Number"
echo "[-g] --> Reference Genome < hg38, GRCh38, mm10, GRCm38, rat, cat, chicken, horse, ATCC_13047, grape, ercc, lonchura, goose >"
echo "[-r] --> <SE>, <SES>, <PE> or <PES> "
echo "-------------------------------------------------------------------------------------------------------------------------------"
}
se(){
cd trimmed_fastqs
for i in *_trimmed.fq.gz
do
iSUB=`echo $i | cut -d '_' -f5`
STAR \
--runThreadN 12 \
--genomeDir ${genomeDir[${DIR}]} \
--readFilesIn $i \
--readFilesCommand gunzip -c \
--outSAMstrandField intronMotif \
--outFilterIntronMotifs RemoveNoncanonical \
--outSAMtype BAM SortedByCoordinate \
--outFileNamePrefix $iSUB. \
--limitBAMsortRAM 61675612266 \
--quantMode GeneCounts
done
source activate RSC
multiqc -f -n ${PIN}.starSolo.multiqc.report .
mkdir STAR.SOLO.COUNTS STAR.SOLO.BAMS STAR.SOLO.LOGS
mv *.ReadsPerGene.out.tab STAR.SOLO.COUNTS
mv *.bam STAR.SOLO.BAMS
mv *.out *.tab *_STARtmp *.list *.multiqc.report_data STAR.SOLO.LOGS
mkdir STAR.SOLO
mv STAR.* *.html STAR.SOLO
mv STAR.SOLO ..
cd ..
}
se_split(){
cd trimmed_fastqs
for i in *_trimmed.fq.gz
do
iSUB=`echo $i | cut -d '_' -f5`
STAR \
--runThreadN 12 \
--genomeDir ${genomeDir[${DIR}]} \
--readFilesIn $i \
--readFilesCommand gunzip -c \
--outSAMstrandField intronMotif \
--outFilterIntronMotifs RemoveNoncanonical \
--outReadsUnmapped Fastx \
--outSAMtype BAM SortedByCoordinate \
--outFileNamePrefix $iSUB. \
--limitBAMsortRAM 61675612266 \
--quantMode GeneCounts
done
source activate RSC
multiqc -f -n ${PIN}.starSolo.multiqc.report .
mkdir STAR.SOLO.COUNTS STAR.SOLO.BAMS STAR.SOLO.LOGS STAR.SOLO.Unmapped
mv *Unmapped.out.mate* STAR.SOLO.Unmapped
cd STAR.SOLO.Unmapped
for i in *mate*
do
mv $i `echo $i | sed "s/Unmapped/not.$DIR/g"`
done
cd ..
mv *.ReadsPerGene.out.tab STAR.SOLO.COUNTS
mv *.bam STAR.SOLO.BAMS
mv *.out *.tab *_STARtmp *.list *.multiqc.report_data STAR.SOLO.LOGS
mkdir STAR.SOLO
mv STAR.* *.html STAR.SOLO
mv STAR.SOLO ..
cd ..
}
pe(){
cd trimmed_fastqs
ls -1 *_R1_val_1.fq.gz > .trR1
ls -1 *_R2_val_2.fq.gz > .trR2
paste -d " " .trR1 .trR2 > Trimmed.list
readarray trimmedFastqs < Trimmed.list
for i in "${trimmedFastqs[@]}"
do
iSUB=`echo $i | cut -d '_' -f5`
STAR \
--runThreadN 12 \
--genomeDir ${genomeDir[${DIR}]} \
--readFilesIn $i \
--readFilesCommand gunzip -c \
--outSAMstrandField intronMotif \
--outFilterIntronMotifs RemoveNoncanonical \
--outSAMtype BAM SortedByCoordinate \
--outFileNamePrefix ${iSUB}. \
--limitBAMsortRAM 61675612266 \
--quantMode GeneCounts
done
source activate RSC
multiqc -f -n ${PIN}.starSolo.multiqc.report .
mkdir STAR.SOLO.COUNTS STAR.SOLO.BAMS STAR.SOLO.LOGS
mv *.ReadsPerGene.out.tab STAR.SOLO.COUNTS
mv *.bam STAR.SOLO.BAMS
mv *.out *.tab *_STARtmp *.list *.multiqc.report_data STAR.SOLO.LOGS
mkdir STAR.SOLO
mv STAR.* *.html STAR.SOLO
mv STAR.SOLO ..
cd ..
}
pe_split(){
cd trimmed_fastqs
ls -1 *_R1_val_1.fq.gz > .trR1
ls -1 *_R2_val_2.fq.gz > .trR2
paste -d " " .trR1 .trR2 > Trimmed.list
readarray trimmedFastqs < Trimmed.list
for i in "${trimmedFastqs[@]}"
do
iSUB=`echo $i | cut -d '_' -f5`
STAR \
--runThreadN 12 \
--genomeDir ${genomeDir[${DIR}]} \
--readFilesIn $i \
--readFilesCommand gunzip -c \
--outSAMstrandField intronMotif \
--outFilterIntronMotifs RemoveNoncanonical \
--outSAMtype BAM SortedByCoordinate \
--outReadsUnmapped Fastx \
--outFileNamePrefix ${iSUB}. \
--limitBAMsortRAM 61675612266 \
--quantMode GeneCounts
done
source activate RSC
multiqc -f -n ${PIN}.starSolo.multiqc.report .
mkdir STAR.SOLO.COUNTS STAR.SOLO.BAMS STAR.SOLO.LOGS STAR.SOLO.Unmapped
mv *Unmapped.out.mate* STAR.SOLO.Unmapped
cd STAR.SOLO.Unmapped
for i in *mate*
do
mv $i `echo $i | sed "s/Unmapped/not.$DIR/g"`
done
cd ..
mv *.ReadsPerGene.out.tab STAR.SOLO.COUNTS
mv *.bam STAR.SOLO.BAMS
mv *.out *.tab *_STARtmp *.list *.multiqc.report_data STAR.SOLO.LOGS
mkdir STAR.SOLO
mv STAR.* *.html STAR.SOLO
mv STAR.SOLO ..
cd ..
}
declare -A genomeDir
genomeDir=( ["hg38"]="/workdir/genomes/Homo_sapiens/hg38/UCSC/hg38.star" \
["mm10"]="/workdir/genomes/Mus_musculus/mm10/UCSC/mm10.star" \
["GRCh38"]="/workdir/genomes/Homo_sapiens/hg38/ENSEMBL/GRCh38.star" \
["GRCm38"]="/workdir/genomes/Mus_musculus/mm10/ENSEMBL/GRCm38.star" \
["cat"]="/workdir/genomes/Felis_catus/Felis_catus9.0/Ensembl/genomeDir" \
["chicken"]="/workdir/genomes/Gallus_gallus/Galgal5/ENSEMBL/galgal5.star" \
["horse"]="/workdir/genomes/Equus_caballus/ENSEMBL/Equus_caballus.star" \
["ATCC_13047"]="/workdir/genomes/Enterobacter_cloacae/ATCC_13047/custom/ATCC_13047.GTF" \
["grape"]="/workdir/genomes/Vitis_vinifera/GCA_000003745.2/ENSEMBL/Vitis_vinifera.12X.43.bed12" \
["rat"]="/workdir/genomes/Rattus_norvegicus/rn6/ENSEMBL/rat.star" \
["ercc"]="/workdir/genomes/contaminants/ERCC_spikeIns/ercc.star" \
["lonchura"]="/workdir/genomes/Lonchura_striata/LonStrDom1/ENSEMBL/lonchura.star" \
["goose"]="/workdir/genomes/Anser_brachyrhynchus/ASM259213v1/ENSEMBL/goose.star" )
while getopts "hp:g:r:" opt; do
case ${opt} in
h )
echo
echo
echo
usage
echo
echo
exit 1
;;
p )
PIN=$OPTARG
echo "Project Identifier = " $PIN
;;
r )
RUN=$OPTARG
;;
g )
DIR=$OPTARG
;;
\? )
echo
echo
echo
usage
;;
esac
done
#-------------------------------------------------------------------------------------------------------------
#-------------------------------------------------------------------------------------------------------------
## check if genomeDir provided
if [[ ! -z "${DIR+x}" ]]; then
if [ ${genomeDir[${DIR}]+_} ]; then
echo Reference genome selected = $DIR
echo
if [[ ! -z "${RUN+x}" ]] && [[ $RUN == "PE" ]]; then
pe
elif [[ ! -z "${RUN+x}" ]] && [[ $RUN == "PES" ]]; then
pe_split
elif [[ ! -z "${RUN+x}" ]] && [[ $RUN == "SE" ]]; then
se
elif [[ ! -z "${RUN+x}" ]] && [[ $RUN == "SES" ]]; then
se_split
else
echo "missing -r option "
usage
exit 1
fi
else
echo "The reference genome provided '"$DIR"' is not available"
echo " OR missing -r "
exit 1
fi
fi
#-------------------------------------------------------------------------------------------------------------
#-------------------------------------------------------------------------------------------------------------
if [[ -z $1 ]] || [[ $1 = "help" ]] ; then
#statements
echo
echo
usage
echo
echo
exit 1
else
echo >> solo.run.log
echo -------------------------------------------------------------------------------------------------- >> solo.run.log
echo `date` >> solo.run.log
echo "Project Identifier Specified = " $PIN >> solo.run.log
echo "Reference Genome Specified = " $DIR >> solo.run.log
echo "SE, SES, PE or PES = " $RUN >> solo.run.log
echo >> solo.run.log
echo -------------------------------------------------------------------------------------------------- >> solo.run.log
fi