comparison isoDE2.sh @ 14:007e2dd3fe8b draft

Bug fix in output files headers
author saharlcc
date Mon, 03 Apr 2017 17:55:22 -0400
parents
children
comparison
equal deleted inserted replaced
13:cff0a5f324d4 14:007e2dd3fe8b
1 #!/bin/bash
2
3 isoEMDir=/galaxy/galaxy/tools-dependencies/bin/isoem2/
4 toolpath=${isoEMDir}/bin
5 isoDEPath=${isoEMDir}/bin
6 supportCalcPath=${isoEMDir}/src/calc
7 fpkmGeneCommand=""
8 fpkmIsoformCommand=""
9 tpmGeneCommand=""
10 tpmIsoformCommand=""
11
12 numberOfBootstrapIterationsPerSample=199
13
14 arg=($*)
15 i=0
16 while [ $i -lt $# ]
17 do
18 a=${arg[i]}
19 if [ "$a" == "-c1" ]; then
20 fpkmGeneCommand="$fpkmGeneCommand -c1"
21 fpkmIsoformCommand="$fpkmIsoformCommand -c1"
22 tpmGeneCommand="$tpmGeneCommand -c1"
23 tpmIsoformCommand="$tpmIsoformCommand -c1"
24
25 ((i++))
26 a=${arg[i]}
27 rep=1
28 while [[ `expr index "$a" "/"` -ne 0 && $i -lt $# ]]
29 do
30 condition1File=$a
31 ${toolpath}/convertToisoDEFormatWithIsoforms $condition1File c1_rep${rep}
32
33 fpkmGeneCommand="$fpkmGeneCommand c1_rep${rep}_fpkm_G"
34 fpkmIsoformCommand="$fpkmIsoformCommand c1_rep${rep}_fpkm_I"
35 tpmGeneCommand="$tpmGeneCommand c1_rep${rep}_tpm_G"
36 tpmIsoformCommand="$tpmIsoformCommand c1_rep${rep}_tpm_I"
37 ((rep++))
38
39 ((i++))
40 a=${arg[i]}
41 done
42 elif [ "$a" == "-c2" ]; then
43 fpkmGeneCommand="$fpkmGeneCommand -c2"
44 fpkmIsoformCommand="$fpkmIsoformCommand -c2"
45 tpmGeneCommand="$tpmGeneCommand -c2"
46 tpmIsoformCommand="$tpmIsoformCommand -c2"
47
48 ((i++))
49 a=${arg[i]}
50 rep=1
51 while [[ `expr index "$a" "/"` -ne 0 && $i -lt $# ]]
52 do
53 condition1File=$a
54 #echo $condition1File
55 ${toolpath}/convertToisoDEFormatWithIsoforms $condition1File c2_rep${rep}
56
57 fpkmGeneCommand="$fpkmGeneCommand c2_rep${rep}_fpkm_G"
58 fpkmIsoformCommand="$fpkmIsoformCommand c2_rep${rep}_fpkm_I"
59 tpmGeneCommand="$tpmGeneCommand c2_rep${rep}_tpm_G"
60 tpmIsoformCommand="$tpmIsoformCommand c2_rep${rep}_tpm_I"
61 ((rep++))
62
63 ((i++))
64 a=${arg[i]}
65 done
66 elif [ "$a" == "-pval" ]; then
67 ((i++))
68 pval=${arg[i]}
69 ((i++))
70
71
72 elif [ "$a" == "-geneFPKMout" ]; then
73 ((i++))
74 geneFPKMout_file=${arg[i]}
75 ((i++))
76
77
78 elif [ "$a" == "-geneTPMout" ]; then
79 ((i++))
80 geneTPMout_file=${arg[i]}
81 ((i++))
82
83 elif [ "$a" == "-isoFPKMout" ]; then
84 ((i++))
85 isoFPKMout_file=${arg[i]}
86 ((i++))
87
88 elif [ "$a" == "-isoTPMout" ]; then
89 ((i++))
90 isoTPMout_file=${arg[i]}
91 ((i++))
92 else
93
94 ((i++))
95 fi
96
97 done
98 ((rep--))
99 bootstrap=$(($rep*$numberOfBootstrapIterationsPerSample))
100 echo boostrap iterations $bootstrap
101 #support=`java -cp ${supportCalcPath} support 200 200 $pval`
102 #support=`java -cp ${supportCalcPath} support $bootstrap $bootstrap $pval`
103 #Calculator assumes IsoDE does all pairs when calculation the number of ratios. It multiplies the number of bootstrap samples per condition
104 # changed the second parameter to make the number of ratios equal to the number of bootstrap samples (match, not all pairs)
105 echo calculate support based on p-value and number or replicates
106 support=`java -cp ${supportCalcPath} support $bootstrap 1 $pval`
107 fpkmGeneCommand="$fpkmGeneCommand -b $support"
108 fpkmIsoformCommand="$fpkmIsoformCommand -b $support"
109 tpmGeneCommand="$tpmGeneCommand -b $support"
110 tpmIsoformCommand="$tpmIsoformCommand -b $support"
111
112 fpkmGeneCommand="$fpkmGeneCommand -dfc 2"
113 fpkmIsoformCommand="$fpkmIsoformCommand -dfc 2"
114 tpmGeneCommand="$tpmGeneCommand -dfc 2"
115 tpmIsoformCommand="$tpmIsoformCommand -dfc 2"
116
117
118 #if [ "${out_prefix}" == "$(basename ${out_prefix} )" ]; then
119 # pth=`pwd`
120 # out_prefix=${pth}/${out_prefix}
121 #fi
122
123
124 echo GENE FPKM
125 echo moving start
126 date
127
128 mkdir fpkm_G
129 cd fpkm_G
130 mv ../c*_fpkm_G .
131
132
133 echo isoDE start
134 date
135
136
137 ${isoDEPath}/isodecalls $fpkmGeneCommand -out "output.txt"
138 #awk '{for (f=1; f<=NF; f++) {if (f == NF) printf "%s",$f; else printf "%s\t", $f }; print ""}' Bootstrap_Merge1_DIR/output.txt | sed 1,1d > ${geneFPKMout_file}
139
140 echo awk command
141 date
142
143
144 awk '{if (NR == 1) {print "Gene ID\tConfident log2 FC\t Single run log2 FC\t c1 average FPKM\tc2 average FPKM";} else {if ($6 == 0 && $7 == 0) {two="0";} else {two=$2;} print $1 "\t" two "\t" $5 "\t" $6 "\t" $7}}' Bootstrap_Merge1_DIR/output.txt > ${geneFPKMout_file}
145
146 cd ..
147
148
149 echo ISOFORM FPKM
150
151 echo moving start
152 date
153
154 mkdir fpkm_I
155 cd fpkm_I
156 mv ../c*_fpkm_I .
157
158
159 echo isoDE start
160 date
161
162 ${isoDEPath}/isodecalls $fpkmIsoformCommand -out "output.txt"
163
164 echo awk command
165 date
166 pwd
167 awk '{if (NR == 1) {print "Isoform ID\tConfident log2 FC\t Single run log2 FC\t c1 average FPKM\tc2 average FPKM";} else {if ($6 == 0 && $7 == 0) {two="0";} else {two=$2;} print $1 "\t" two "\t" $5 "\t" $6 "\t" $7}}' Bootstrap_Merge1_DIR/output.txt > ${isoFPKMout_file}
168 cd ..
169
170
171 echo ISOFORM TPM
172 echo moving start
173 date
174
175 mkdir tpm_G
176 cd tpm_G
177 mv ../c*_tpm_G .
178
179 echo isoDE start
180 date
181
182 ${isoDEPath}/isodecalls $tpmGeneCommand -out "output.txt"
183
184 echo awk command
185 date
186 pwd
187 awk '{if (NR == 1) {print "Gene ID\tConfident log2 FC\t Single run log2 FC\t c1 average TPM\tc2 average TPM";} else {if ($6 == 0 && $7 == 0) {two="0";} else {two=$2;} print $1 "\t" two "\t" $5 "\t" $6 "\t" $7}}' Bootstrap_Merge1_DIR/output.txt > ${geneTPMout_file}
188 cd ..
189
190
191 echo ISOFORM TPM
192 echo moving start
193 date
194
195 mkdir tpm_I
196 cd tpm_I
197 mv ../c*_tpm_I .
198
199 echo isoDE start
200 date
201
202 ${isoDEPath}/isodecalls $tpmIsoformCommand -out "output.txt"
203
204 echo awk command
205 date
206
207 awk '{if (NR == 1) {print "Isoform ID\tConfident log2 FC\t Single run log2 FC\t c1 average TPM\tc2 average TPM";} else {if ($6 == 0 && $7 == 0) {two="0";} else {two=$2;} print $1 "\t" two "\t" $5 "\t" $6 "\t" $7}}' Bootstrap_Merge1_DIR/output.txt > ${isoTPMout_file}
208
209 cd ..
210
211
212 echo final cleanup
213 date
214 rm -fr fpkm_G fpkm_I tpm_G cd tpm_I
215 echo done
216 date
217
218