-
-
Notifications
You must be signed in to change notification settings - Fork 20
/
ikra_Ion_SRR.sh
218 lines (171 loc) · 5.34 KB
/
ikra_Ion_SRR.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
#! bin/bash
set -xeu
<<COMMENTOUT
$ bash ikura_SRR.sh tpTregTconv_rnaseq_experiment_table.csv outdir mouse
- fastqかSRRの判別
- trimmomatic
- gtf, transcript file をGENCODEから
- salmon
COMMENTOUT
# 実験テーブル.csv
EX_MATRIX_FILE=$1
RUNINDOCKER=1
THREADS=4
REF_SPIECE=$2
DOCKER=docker
# DOCKER=udocker # udockerも指定できる。
SCRIPT_DIR=$(cd $(dirname $0); pwd)
OUTPUT_FILE=output.tsv
if [[ $REF_SPIECE = mouse ]]; then
BASE_REF_TRANSCRIPT=ftp://ftp.ebi.ac.uk/pub/databases/gencode/Gencode_mouse/release_M19
REF_TRANSCRIPT=gencode.vM19.transcripts.fa.gz
SALMON_INDEX=salmon_index_mouse
# REF_GTF=gencode.vM19.annotation.gtf.gz
TX2SYMBOL=gencode.vM19.metadata.MGI.gz
elif [[ $REF_SPIECE = human ]]; then
BASE_REF_TRANSCRIPT=ftp://ftp.ebi.ac.uk/pub/databases/gencode/Gencode_human/release_29
# REF_TRANSCRIPT=gencode.v29.pc_translations.fa.gz
REF_TRANSCRIPT=gencode.v29.transcripts.fa.gz
SALMON_INDEX=salmon_index_human
# REF_GTF=gencode.v29.annotation.gtf.gz
TX2SYMBOL=gencode.v29.metadata.HGNC.gz
else
echo No reference speice!
exit
fi
COWSAY=cowsay
PREFETCH=prefetch
PFASTQ_DUMP=pfastq-dump
FASTQ_DUMP=fastq-dump
FASTQC=fastqc
MULTIQC=multiqc
FASTXTRIMMER=fastx_trimmer
FASTQQUALITYTRIMMER=fastq_quality_trimmer
# TRIMMOMATIC=trimmomatic
SALMON=salmon
RSCRIPT_TXIMPORT=Rscript
if [[ "$RUNINDOCKER" -eq "1" ]]; then
echo "RUNNING IN DOCKER"
# docker を走らせ終わったらコンテナを削除。(-rm)ホストディレクトリをコンテナにマウントする。(-v)
DRUN="$DOCKER run --rm -v $PWD:/home --workdir /home -i"
#--user=biodocker
# 危険!
chmod 777 .
COWSAY_IMAGE=docker/whalesay
SRA_TOOLKIT_IMAGE=inutano/sra-toolkit
FASTQC_IMAGE=biocontainers/fastqc:v0.11.5_cv2
MULTIQC_IMAGE=maxulysse/multiqc
FASTXTOOLS_IMAGE=biocontainers/fastxtools:v0.0.14_cv2
# TRIMMOMATIC_IMAGE=fjukstad/trimmomatic
# TRIMMOMATIC_IMAGR=comics/trimmomatic
SALMON_IMAGE=combinelab/salmon:latest
# SALMON_IMAGE=fjukstad/salmon
RSCRIPT_TXIMPORT_IMAGE=fjukstad/tximport
$DOCKER pull $COWSAY_IMAGE
$DOCKER pull $SRA_TOOLKIT_IMAGE
$DOCKER pull $FASTQC_IMAGE
$DOCKER pull $MULTIQC_IMAGE
$DOCKER pull $FASTXTOOLS_IMAGE
# $DOCKER pull $TRIMMOMATIC_IMAGE
$DOCKER pull $SALMON_IMAGE
$DOCKER pull $RSCRIPT_TXIMPORT_IMAGE
COWSAY="$DRUN $COWSAY_IMAGE $COWSAY"
PREFETCH="$DRUN -v $PWD:/root/ncbi/public/sra $SRA_TOOLKIT_IMAGE $PREFETCH"
PFASTQ_DUMP="$DRUN $SRA_TOOLKIT_IMAGE $PFASTQ_DUMP"
FASTQ_DUMP="$DRUN $SRA_TOOLKIT_IMAGE $FASTQ_DUMP"
FASTQC="$DRUN $FASTQC_IMAGE $FASTQC"
MULTIQC="$DRUN $MULTIQC_IMAGE $MULTIQC"
FASTXTRIMMER="$DRUN $FASTXTOOLS_IMAGE $FASTXTRIMMER"
FASTQQUALITYTRIMMER="$DRUN $FASTXTOOLS_IMAGE $FASTQQUALITYTRIMMER"
# TRIMMOMATIC="$DRUN $TRIMMOMATIC_IMAGE $TRIMMOMATIC"
# TRIMMOMATIC="$DRUN $TRIMMOMATIC_IMAGE " # fjukstad/trimmomaticのentrypointのため
SALMON="$DRUN $SALMON_IMAGE $SALMON"
# SALMON="$DRUN $SALMON_IMAGE"
RSCRIPT_TXIMPORT="$DRUN $RSCRIPT_TXIMPORT_IMAGE $RSCRIPT_TXIMPORT"
# docker run --rm -v $PWD:/data -v $PWD:/root/ncbi/public/sra --workdir /data -it inutano/sra-toolkit bash
else
echo "RUNNING LOCAL"
fi
# 十分大きなものにする。
MAXSIZE=20G
SRA_ROOT=$HOME/ncbi/public/sra
# テスト用。ダウンロードするread数。全部使うときは0に
MAX_SPOT_ID=5000000
if [ $MAX_SPOT_ID = 0 ]; then
MAX_SPOT_ID=""
else
$COWSAY "test mode( MAX_SPOT_ID is set)"
MAX_SPOT_ID="-X $MAX_SPOT_ID"
fi
echo ${1}
cat $1
# tximport_R.Rを取ってくる。
cp $SCRIPT_DIR/tximport_R.R ./
# fastq_dump
for i in `tail -n +2 $1`
do
name=`echo $i | cut -d, -f1`
SRR=`echo $i | cut -d, -f2`
# fastq_dump
if [[ ! -f "$SRR.fastq.gz" ]]; then
$FASTQ_DUMP $SRR $MAX_SPOT_ID --gzip
fi
# fastqc
if [[ ! -f "${SRR}_fastqc.zip" ]]; then
$FASTQC -t $THREADS ${SRR}.fastq.gz
fi
# fastx-toolkit
if [[ ! -f "${SRR}_trimmed.fastq.gz" ]]; then
gunzip -c ${SRR}.fastq.gz | $FASTXTRIMMER -Q33 -f 1 -l 220 | $FASTQQUALITYTRIMMER -z -Q33 -t 18 -l 20 -o ${SRR}_trimmed.fastq.gz
fi
# fastqc
if [[ ! -f "${SRR}_trimmed_fastqc.zip" ]]; then
$FASTQC -t $THREADS ${SRR}_trimmed.fastq.gz
fi
done
if [[ ! -f "multiqc_report_raw_reads.html" ]]; then
$MULTIQC -n multiqc_report_raw_reads.html .
fi
# download $REF_TRANSCRIPT
if [[ ! -f "$REF_TRANSCRIPT" ]]; then
wget $BASE_REF_TRANSCRIPT/$REF_TRANSCRIPT
fi
# # download $REF_GTF
# if [[ ! -f "$REF_GTF" ]]; then
# wget $BASE_REF_TRANSCRIPT/$REF_GTF
# fi
# instance salmon index
if [[ ! -d "$SALMON_INDEX" ]]; then
$SALMON index --threads $THREADS --transcripts $REF_TRANSCRIPT --index $SALMON_INDEX --type quasi -k 31 --gencode
fi
for i in `tail -n +2 $1`
do
name=`echo $i | cut -d, -f1`
SRR=`echo $i | cut -d, -f2`
LAYOUT=`echo $i | cut -d, -f3`
if [[ ! -f "salmon_output_${SRR}/quant.sf" ]]; then
mkdir salmon_output_${SRR}
# libtype auto detection mode
$SALMON quant -i $SALMON_INDEX \
-l A \
-r ${SRR}_trimmed.fastq.gz \
-p $THREADS \
-o salmon_output_${SRR} \
# -g $REF_GTF
fi
done
# multiqc
if [[ ! -f "multiqc_report.html" ]]; then
$MULTIQC -n multiqc_report.html .
fi
# download $TX2SYMBOL
if [[ ! -f "$TX2SYMBOL" ]]; then
wget $BASE_REF_TRANSCRIPT/$TX2SYMBOL
fi
# tximport
if [[ ! -f "$OUTPUT_FILE" ]]; then
$RSCRIPT_TXIMPORT tximport_R.R $TX2SYMBOL $EX_MATRIX_FILE $OUTPUT_FILE
fi
if [[ "$RUNINDOCKER" -eq "1" ]]; then
chmod 755 .
fi