-
Notifications
You must be signed in to change notification settings - Fork 7
/
dee2_quant.sh
executable file
·228 lines (187 loc) · 8.77 KB
/
dee2_quant.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
#!/bin/bash
agg(){
awk '{array[$1]+=$2} END { for (i in array) {print i, array[i]}}'
}
export -f agg
main(){
set -x
SPECIES=$1
ORG=$(echo $SPECIES | cut -c-3)
################################
echo Run some simulations
################################
if [ $ORG == "ath" ] ; then
REF=Arabidopsis_thaliana.TAIR10.cdna.all.fa
wget -N "ftp://ftp.ensemblgenomes.org/pub/release-35/plants/fasta/arabidopsis_thaliana/cdna/Arabidopsis_thaliana.TAIR10.cdna.all.fa.gz"
gunzip -kf $REF.gz
elif [ $ORG == "cel" ] ; then
REF=Caenorhabditis_elegans.WBcel235.cdna.all.fa
wget -N "ftp://ftp.ensembl.org/pub/release-90/fasta/caenorhabditis_elegans/cdna/Caenorhabditis_elegans.WBcel235.cdna.all.fa.gz"
gunzip -kf $REF.gz
elif [ $ORG == "dme" ] ; then
REF=Drosophila_melanogaster.BDGP6.cdna.all.fa
wget -N "ftp://ftp.ensembl.org/pub/release-90/fasta/drosophila_melanogaster/cdna/Drosophila_melanogaster.BDGP6.cdna.all.fa.gz"
gunzip -kf $REF.gz
elif [ $ORG == "dre" ] ; then
REF=Danio_rerio.GRCz10.cdna.all.fa
wget -N "ftp://ftp.ensembl.org/pub/release-90/fasta/danio_rerio/cdna/Danio_rerio.GRCz10.cdna.all.fa.gz"
gunzip -kf $REF.gz
elif [ $ORG == "eco" ] ; then
REF=Escherichia_coli_str_k_12_substr_mg1655.ASM584v2.cdna.all.fa
wget -N "ftp://ftp.ensemblgenomes.org/pub/bacteria/release-36/fasta/bacteria_0_collection/escherichia_coli_str_k_12_substr_mg1655/cdna/Escherichia_coli_str_k_12_substr_mg1655.ASM584v2.cdna.all.fa.gz"
gunzip -kf $REF.gz
elif [ $ORG == "hsa" ] ; then
REF=Homo_sapiens.GRCh38.cdna.all.fa
wget -N "ftp://ftp.ensembl.org/pub/release-90/fasta/homo_sapiens/cdna/Homo_sapiens.GRCh38.cdna.all.fa.gz"
gunzip -kf $REF.gz
elif [ $ORG == "mmu" ] ; then
REF=Mus_musculus.GRCm38.cdna.all.fa
wget -N "ftp://ftp.ensembl.org/pub/release-90/fasta/mus_musculus/cdna/Mus_musculus.GRCm38.cdna.all.fa.gz"
gunzip -kf $REF.gz
elif [ $ORG == "rno" ] ; then
REF=Rattus_norvegicus.Rnor_6.0.cdna.all.fa
wget -N "ftp://ftp.ensembl.org/pub/release-90/fasta/rattus_norvegicus/cdna/Rattus_norvegicus.Rnor_6.0.cdna.all.fa.gz"
gunzip -kf $REF.gz
elif [ $ORG == "sce" ] ; then
REF=Saccharomyces_cerevisiae.R64-1-1.cdna.all.fa
wget -N "ftp://ftp.ensemblgenomes.org/pub/release-36/fungi/fasta/saccharomyces_cerevisiae/cdna/Saccharomyces_cerevisiae.R64-1-1.cdna.all.fa.gz"
gunzip -kf $REF.gz
fi
#check ART version art_bin_MountRainier is present
MD5=363ff45aa04df1ec28c7be46b9c437dd
ART=./art_illumina
if [ ! -r $ART ] ; then
echo ART simulator not present. Get version ART-MountRainier-2016-06-05
echo https://www.niehs.nih.gov/research/resources/software/biostatistics/art/index.cfm
exit
else
ARTMD5=$(md5sum $ART | cut -d ' ' -f1)
if [ $MD5 != $ARTMD5 ] ; then
echo ART simulator not present. Get version ART-MountRainier-2016-06-05
echo https://www.niehs.nih.gov/research/resources/software/biostatistics/art/index.cfm
exit
fi
fi
#check docker is installed
if [ -z $(which docker) ] ; then
echo docker not installed. Quitting.
exit
fi
#Run the simulation
PFX=${ORG}_art
SEED=1540165885
for LEN in 50 100 ; do
$ART -ss HS25 --rndSeed $SEED -sam -i $REF -l $LEN -f 2 -o ${PFX}_se_${LEN} &
done
for LEN in 50 100 ; do
$ART -ss HS25 --rndSeed $SEED -sam -i $REF -l $LEN -p -m 300 -s 30 -f 2 -o ${PFX}_pe_${LEN}_ &
done
wait
pigz -f *fq
rm *sam *aln
################################
echo establish simulated counts
################################
grep '>' $REF | sed 's/gene:/\n/' \
| cut -d ' ' -f1 | paste - - | sed 's/>//' | cut -d '.' -f-2 > ${ORG}_tx2gene.tsv
#tx counts
zcat ${ORG}_art_se_50.fq.gz | sed -n '1~4p' | cut -d '-' -f1 \
| sed 's/@//' | sort | uniq -c | awk '{print $2"\t"$1}' \
| sort -k 1b,1 > ${ORG}_art_se_50_tx.tsv
zcat ${ORG}_art_se_100.fq.gz | sed -n '1~4p' | cut -d '-' -f1 \
| sed 's/@//' | sort | uniq -c | awk '{print $2"\t"$1}' \
| sort -k 1b,1 > ${ORG}_art_se_100_tx.tsv
zcat ${ORG}_art_pe_50_1.fq.gz | sed -n '1~4p' | cut -d '-' -f1 \
| sed 's/@//' | sort | uniq -c | awk '{print $2"\t"$1}' \
| sort -k 1b,1 > ${ORG}_art_pe_50_tx.tsv
zcat ${ORG}_art_pe_100_1.fq.gz | sed -n '1~4p' | cut -d '-' -f1 \
| sed 's/@//' | sort | uniq -c | awk '{print $2"\t"$1}' \
| sort -k 1b,1 > ${ORG}_art_pe_100_tx.tsv
#gene counts
join -1 1 -2 1 <(sort -k 1b,1 ${ORG}_tx2gene.tsv) ${ORG}_art_se_50_tx.tsv | sort -k 2b,2 \
| cut -d ' ' -f2- | sort -k 1b,1 | agg | sort -k 1b,1 > ${ORG}_art_se_50_g.tsv
join -1 1 -2 1 <(sort -k 1b,1 ${ORG}_tx2gene.tsv) ${ORG}_art_se_100_tx.tsv | sort -k 2b,2 \
| cut -d ' ' -f2- | sort -k 1b,1 | agg | sort -k 1b,1 > ${ORG}_art_se_100_g.tsv
join -1 1 -2 1 <(sort -k 1b,1 ${ORG}_tx2gene.tsv) ${ORG}_art_pe_50_tx.tsv | sort -k 2b,2 \
| cut -d ' ' -f2- | sort -k 1b,1 | agg | sort -k 1b,1 > ${ORG}_art_pe_50_g.tsv
join -1 1 -2 1 <(sort -k 1b,1 ${ORG}_tx2gene.tsv) ${ORG}_art_pe_100_tx.tsv | sort -k 2b,2 \
| cut -d ' ' -f2- | sort -k 1b,1 | agg | sort -k 1b,1 > ${ORG}_art_pe_100_g.tsv
################################
echo Run mapping
################################
if [ $(docker images | grep -c mziemann/tallyup_${ORG}) -gt 0 ] ; then
docker run -v $(pwd):/dee2/mnt mziemann/tallyup_${ORG} ${SPECIES} \
-f ${ORG}_art_se_100.fq.gz,${ORG}_art_se_50.fq.gz
rm -rf ${ORG}_se
docker cp $(docker ps -alq):/dee2/data/ ${ORG}_se
docker run -v $(pwd):/dee2/mnt mziemann/tallyup_${ORG} ${SPECIES} \
-f ${ORG}_art_pe_100_1.fq.gz,${ORG}_art_pe_50_1.fq.gz ${ORG}_art_pe_100_2.fq.gz,${ORG}_art_pe_50_2.fq.gz
rm -rf ${ORG}_pe
docker cp $(docker ps -alq):/dee2/data/ ${ORG}_pe
else
docker run -v $(pwd):/dee2/mnt mziemann/tallyup ${SPECIES} \
-f ${ORG}_art_se_100.fq.gz,${ORG}_art_se_50.fq.gz
rm -rf ${ORG}_se
docker cp $(docker ps -alq):/dee2/data/ ${ORG}_se
docker run -v $(pwd):/dee2/mnt mziemann/tallyup ${SPECIES} \
-f ${ORG}_art_pe_100_1.fq.gz,${ORG}_art_pe_50_1.fq.gz ${ORG}_art_pe_100_2.fq.gz,${ORG}_art_pe_50_2.fq.gz
rm -rf ${ORG}_pe
docker cp $(docker ps -alq):/dee2/data/ ${ORG}_pe
fi
################################
echo join simulated and processed data
################################
#SINGLE END
#50 bp SE reads
#sim vs star
join -1 1 -2 1 ${ORG}_art_se_50_g.tsv <(sort -k 1b,1 ${ORG}_se/${SPECIES}/${ORG}_art_se_50/${ORG}_art_se_50.se.tsv) \
> ${ORG}_art_se_50_star.tsv
#sim vs kal transcripts
cut -f1,4 ${ORG}_se/${SPECIES}/${ORG}_art_se_50/${ORG}_art_se_50.ke.tsv | sed 1d \
| sort -k 1b,1 | join -1 1 -2 1 ${ORG}_art_se_50_tx.tsv - | tr ' ' '\t' > ${ORG}_art_se_50_kalt.tsv
#sim vs kal genes
cut -f1,4 ${ORG}_se/${SPECIES}/${ORG}_art_se_50/${ORG}_art_se_50.ke.tsv | sed 1d | sort -k 1b,1 \
| join -1 1 -2 1 - <(sort -k 1b,1 ${ORG}_tx2gene.tsv ) | awk '{print $3"\t"$2}' \
| sort | agg | sort -k 1b,1 \
| join -1 1 -2 1 ${ORG}_art_se_50_g.tsv - > ${ORG}_art_se_50_kalg.tsv
#100 bp SE reads
#sim vs star
join -1 1 -2 1 ${ORG}_art_se_100_g.tsv <(sort -k 1b,1 ${ORG}_se/${SPECIES}/${ORG}_art_se_100/${ORG}_art_se_100.se.tsv) \
> ${ORG}_art_se_100_star.tsv
#sim vs kal transcripts
cut -f1,4 ${ORG}_se/${SPECIES}/${ORG}_art_se_100/${ORG}_art_se_100.ke.tsv | sed 1d \
| sort -k 1b,1 | join -1 1 -2 1 ${ORG}_art_se_100_tx.tsv - | tr ' ' '\t' > ${ORG}_art_se_100_kalt.tsv
#sim vs kal genes
cut -f1,4 ${ORG}_se/${SPECIES}/${ORG}_art_se_100/${ORG}_art_se_100.ke.tsv | sed 1d | sort -k 1b,1 \
| join -1 1 -2 1 - <(sort -k 1b,1 ${ORG}_tx2gene.tsv ) | awk '{print $3"\t"$2}' \
| sort | agg | sort -k 1b,1 \
| join -1 1 -2 1 ${ORG}_art_se_100_g.tsv - > ${ORG}_art_se_100_kalg.tsv
##PAIRED END
#50 bp PE reads
join -1 1 -2 1 ${ORG}_art_pe_50_g.tsv <(sort -k 1b,1 ${ORG}_pe/${SPECIES}/${ORG}_art_pe_50_1/${ORG}_art_pe_50_1.se.tsv) \
> ${ORG}_art_pe_50_star.tsv
#sim vs kal transcripts
cut -f1,4 ${ORG}_pe/${SPECIES}/${ORG}_art_pe_50_1/${ORG}_art_pe_50_1.ke.tsv | sed 1d \
| sort -k 1b,1 | join -1 1 -2 1 ${ORG}_art_pe_50_tx.tsv - | tr ' ' '\t' > ${ORG}_art_pe_50_kalt.tsv
#sim vs kal genes
cut -f1,4 ${ORG}_pe/${SPECIES}/${ORG}_art_pe_50_1/${ORG}_art_pe_50_1.ke.tsv | sed 1d | sort -k 1b,1 \
| join -1 1 -2 1 - <(sort -k 1b,1 ${ORG}_tx2gene.tsv ) | awk '{print $3"\t"$2}' \
| sort | agg | sort -k 1b,1 \
| join -1 1 -2 1 ${ORG}_art_pe_50_g.tsv - > ${ORG}_art_pe_50_kalg.tsv
#100 bp SE reads
#sim vs star
join -1 1 -2 1 ${ORG}_art_pe_100_g.tsv <(sort -k 1b,1 ${ORG}_pe/${SPECIES}/${ORG}_art_pe_100_1/${ORG}_art_pe_100_1.se.tsv) \
> ${ORG}_art_pe_100_star.tsv
#sim vs kal transcripts
cut -f1,4 ${ORG}_pe/${SPECIES}/${ORG}_art_pe_100_1/${ORG}_art_pe_100_1.ke.tsv | sed 1d \
| sort -k 1b,1 | join -1 1 -2 1 ${ORG}_art_pe_100_tx.tsv - | tr ' ' '\t' > ${ORG}_art_pe_100_kalt.tsv
#sim vs kal genes
cut -f1,4 ${ORG}_pe/${SPECIES}/${ORG}_art_pe_100_1/${ORG}_art_pe_100_1.ke.tsv | sed 1d | sort -k 1b,1 \
| join -1 1 -2 1 - <(sort -k 1b,1 ${ORG}_tx2gene.tsv ) | awk '{print $3"\t"$2}' \
| sort | agg | sort -k 1b,1 \
| join -1 1 -2 1 ${ORG}_art_pe_100_g.tsv - > ${ORG}_art_pe_100_kalg.tsv
}
export -f main
for i in athaliana celegans dmelanogaster drerio ecoli hsapiens mmusculus rnorvegicus scerevisiae ; do
main $i
done