comparison wrapper.sh @ 0:ed6885c85660 draft

Uploaded
author davidvanzessen
date Wed, 31 Aug 2016 05:31:47 -0400
parents
children 75853bceec00
comparison
equal deleted inserted replaced
-1:000000000000 0:ed6885c85660
1 #!/bin/bash
2
3 inputFile=$1
4 outputFile=$2
5 outputDir=$3
6 min_freq=$4
7 min_cells=$5
8 merge_on="$6"
9
10 dir="$(cd "$(dirname "$0")" && pwd)"
11 mkdir $outputDir
12
13
14 Rscript --verbose $dir/RScript.r $inputFile $outputDir $outputFile $min_freq $min_cells "${merge_on}" 2>&1
15 cp $dir/jquery-1.11.0.min.js $outputDir
16 cp $dir/script.js $outputDir
17 cp $dir/style.css $outputDir
18 cp $dir/tabber.js $outputDir
19 mv "$outputFile" "$outputDir/log.html"
20
21 echo "<html><center><h1><a href='index.html'>Click here for the results</a></h1>Tip: Open it in a new tab (middle mouse button or right mouse button -> 'open in new tab' on the link above)</center></html>" > $outputFile
22
23 cd $outputDir
24
25 header="<html><head><script type='text/javascript' src='jquery-1.11.0.min.js'></script><script type='text/javascript' src='tabber.js'></script><script type='text/javascript' src='script.js'></script><link rel='stylesheet' type='text/css' href='style.css'></head><div id='hidden_div' style='display: none;'></div>"
26 singles=()
27 pairs_BM_PB=()
28 pairs_Left_Right=()
29 pairs_R_Dx=()
30 while read patient sample1 sample2 type
31 do
32 echo "$patient"
33 html="${patient}.html"
34 echo "$header" > "$html"
35 if [[ "$type" == *pair* ]] ; then
36 if [[ "$sample1" == *_BM* ]] || [[ "$sample1" == *_PB* ]] ; then
37 pairs_BM_PB+=( "$patient" )
38 elif [[ "$sample1" == *_Left* ]] || [[ "$sample1" == *_Right* ]] ; then
39 pairs_Left_Right+=( "$patient" )
40 else
41 pairs_R_Dx+=( "$patient" )
42 fi
43 else
44 singles+=( "$patient" )
45 fi
46 oldLocus=""
47 sample1="$(echo ${sample1} | tr -d '\r' | tr -d '\n')"
48 sample2="$(echo ${sample2} | tr -d '\r' | tr -d '\n')"
49 tail -n+2 ${patient}_freq.txt | sed "s/>//" > tmp.txt
50 echo "<div class='tabber'>" >> "$html"
51 echo "<div class='tabbertab' title='Data frequency'>" >> "$html"
52 echo "<table><tr><td style='vertical-align:top;'>" >> "$html"
53 echo "<table border = 1 class='result_table summary_table' id='summary_table_${patient}_freq'>" >> "$html"
54 echo "<thead><th>Ig/TCR gene rearrangement type</th><th>Proximal gene segment</th><th>Distal gene segment</th><th>Cut off value</th><th>Number of sequences ${patient}_Both</th><th>Number of sequences_$sample1</th><th>Read Count $sample1</th><th>Number of sequences_$sample2</th><th>Read Count $sample2</th><th>Sum number of sequences $patient</th><th>Percentage of sequences ${patient}_both</th></thead>" >> "$html"
55 echo "<tbody>" >> "$html"
56 scatterplot_tab="<div class='tabbertab' title='Scatter Plots Frequency'><table border='0'><tr>"
57 while read locus j_segment v_segment cut_off_value both one read_count1 two read_count2 sum percent locusreadsum1 locusreadsum2
58 do
59 if [ "$locus" != "$oldLocus" ] ; then
60 echo "<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr>" >> "$html"
61 echo "<tr><td><b>$locus</b></td>" >> "$html"
62 else
63 echo "<td></td>" >> "$html"
64 fi
65 echo "<td>$v_segment</td>" >> "$html"
66 echo "<td>$j_segment</td>" >> "$html"
67 echo "<td>>$cut_off_value</td>" >> "$html"
68 if [ "$both" != "0" ] ; then
69 echo "<td data-patient='${patient}' style='cursor:pointer' onclick='javascript:loadfile(\"${sample1}_${sample2}_${locus}_${cut_off_value}.txt\", \"$patient\", \"freq\")'>$both</td>" >> "$html"
70 else
71 echo "<td>$both</td>" >> "$html"
72 fi
73 if [ "$one" != "0" ] && [ "$cut_off_value" != "0" ] ; then
74 echo "<td data-patient='${patient}' style='cursor:pointer' onclick='javascript:loadfile(\"${sample1}_${locus}_${cut_off_value}.txt\", \"$patient\", \"freq\")'>$one</td>" >> "$html"
75 else
76 echo "<td>$one</td>" >> "$html"
77 fi
78 echo "<td>$read_count1</td>" >> "$html"
79 if [ "$two" != "0" ] && [ "$cut_off_value" != "0" ] ; then
80 echo "<td data-patient='${patient}' style='cursor:pointer' onclick='javascript:loadfile(\"${sample2}_${locus}_${cut_off_value}.txt\", \"$patient\", \"freq\")'>$two</td>" >> "$html"
81 else
82 echo "<td>$two</td>" >> "$html"
83 fi
84 echo "<td>$read_count2</td>" >> "$html"
85 echo "<td>$sum</td>" >> "$html"
86 echo "<td>${percent}&#37;</td>" >> "$html"
87 echo "</tr>" >> "$html"
88 oldLocus="$locus"
89 if [ "${cut_off_value}" == "0" ] ; then
90 scatterplot_tab="${scatterplot_tab}<td><img src='${patient}_${sample1}_${sample2}_freq_${locus}_scatter.png' /></td>"
91 fi
92 done < tmp.txt
93 echo "</tbody></table>" >> "$html"
94 echo "</td><td style='vertical-align:top;'><div id='result_div_${patient}_freq'></div></td></tr></table>" >> "$html"
95 echo "</div>" >> "$html"
96 echo "<div class='tabbertab' title='Graphs frequency'>" >> "$html"
97 echo "<a href='${patient}_freq.png'><img src='${patient}_freq.png' width='1280' height='720' /></a><br />" >> "$html"
98 echo "<a href='${patient}_freq_both.png'><img src='${patient}_freq_both.png' width='1280' height='720' /></a><br />" >> "$html"
99 echo "<a href='${patient}_percent_freq.png'><img src='${patient}_percent_freq.png' width='1280' height='720' /></a></div>" >> "$html"
100 echo "${scatterplot_tab}</tr></table></div>" >> "$html"
101
102 tail -n+2 ${patient}_reads.txt | sed "s/>//" > tmp.txt
103 echo "<div class='tabbertab' title='Data reads'>" >> "$html"
104 echo "<table><tr><td style='vertical-align:top;'>" >> "$html"
105 echo "<table border = 1 class='result_table summary_table' id='summary_table_${patient}_reads'>" >> "$html"
106 echo "<thead><th>Ig/TCR gene rearrangement type</th><th>Proximal gene segment</th><th>Distal gene segment</th><th>Cut off value</th><th>Number of sequences ${patient}_Both</th><th>Number of sequences_$sample1</th><th>Read Count $sample1</th><th>Number of sequences_$sample2</th><th>Read Count $sample2</th><th>Sum number of sequences $patient</th><th>Percentage of sequences ${patient}_both</th></thead>" >> "$html"
107 echo "<tbody>" >> "$html"
108 scatterplot_tab="<div class='tabbertab' title='Scatter Plots Reads'><table border='0'><tr>"
109 while read locus j_segment v_segment cut_off_value both one read_count1 two read_count2 sum percent locusreadsum1 locusreadsum2
110 do
111 if [ "$locus" != "$oldLocus" ] ; then
112 echo "<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr>" >> "$html"
113 echo "<tr><td><b>$locus</b></td>" >> "$html"
114 else
115 echo "<td></td>" >> "$html"
116 fi
117 echo "<td>$v_segment</td>" >> "$html"
118 echo "<td>$j_segment</td>" >> "$html"
119 echo "<td>>$cut_off_value</td>" >> "$html"
120 if [ "$both" != "0" ] ; then
121 echo "<td data-patient='${patient}' style='cursor:pointer' onclick='javascript:loadfile(\"${sample1}_${sample2}_${locus}_${cut_off_value}.txt\", \"$patient\", \"reads\")'>$both</td>" >> "$html"
122 else
123 echo "<td>$both</td>" >> "$html"
124 fi
125 if [ "$one" != "0" ] && [ "$cut_off_value" != "0" ] ; then
126 echo "<td data-patient='${patient}' style='cursor:pointer' onclick='javascript:loadfile(\"${sample1}_${locus}_${cut_off_value}.txt\", \"$patient\", \"reads\")'>$one</td>" >> "$html"
127 else
128 echo "<td>$one</td>" >> "$html"
129 fi
130 echo "<td>$read_count1</td>" >> "$html"
131 if [ "$two" != "0" ] && [ "$cut_off_value" != "0" ] ; then
132 echo "<td data-patient='${patient}' style='cursor:pointer' onclick='javascript:loadfile(\"${sample2}_${locus}_${cut_off_value}.txt\", \"$patient\", \"reads\")'>$two</td>" >> "$html"
133 else
134 echo "<td>$two</td>" >> "$html"
135 fi
136 echo "<td>$read_count2</td>" >> "$html"
137 echo "<td>$sum</td>" >> "$html"
138 echo "<td>${percent}&#37;</td>" >> "$html"
139 echo "</tr>" >> "$html"
140 oldLocus="$locus"
141 if [ "${cut_off_value}" == "0" ] ; then
142 scatterplot_tab="${scatterplot_tab}<td><img src='${patient}_${sample1}_${sample2}_reads_${locus}_scatter.png' /></td>"
143 fi
144 done < tmp.txt
145 echo "</tbody></table>" >> "$html"
146 echo "</td><td style='vertical-align:top;'><div id='result_div_${patient}_reads'></div></td></tr></table>" >> "$html"
147 echo "</div>" >> "$html"
148 echo "<div class='tabbertab' title='Graphs reads'>" >> "$html"
149 echo "<a href='${patient}_reads.png'><img src='${patient}_reads.png' width='1280' height='720' /></a><br />" >> "$html"
150 echo "<a href='${patient}_reads_both.png'><img src='${patient}_reads_both.png' width='1280' height='720' /></a><br />" >> "$html"
151 echo "<a href='${patient}_percent_reads.png'><img src='${patient}_percent_reads.png' width='1280' height='720' /></a></div>" >> "$html"
152 echo "${scatterplot_tab}</tr></table></div>" >> "$html"
153 echo "</div>" >> "$html"
154 echo "</div>" >> "$html"
155 echo "</html>" >> "$html"
156 done < patients.txt
157
158 html="index.html"
159 echo "<html>" > $html
160 echo "<table>" >> "$html"
161 echo "<tr><td><b>Singles (<a href='singles_freq_scatterplot.png'>Frequency scatterplot</a>, <a href='singles_reads_scatterplot.png'>Reads scatterplot</a>):</b></td></tr>" >> "$html"
162 for patient in "${singles[@]}"
163 do
164 echo "<tr><td><a href='${patient}.html'>$patient</a></td></tr>" >> "$html"
165 done
166 echo "<tr><td><b>Pairs (Left & Right):</b></td></tr>" >> "$html"
167 for patient in "${pairs_Left_Right[@]}"
168 do
169 echo "<tr><td><a href='${patient}.html'>$patient</a></td></tr>" >> "$html"
170 done
171 echo "<tr><td><b>Pairs (BM & PB):</b></td></tr>" >> "$html"
172 for patient in "${pairs_BM_PB[@]}"
173 do
174 echo "<tr><td><a href='${patient}.html'>$patient</a></td></tr>" >> "$html"
175 done
176 echo "<tr><td><b>Pairs (Dx & R):</b></td></tr>" >> "$html"
177 for patient in "${pairs_R_Dx[@]}"
178 do
179 echo "<tr><td><a href='${patient}.html'>$patient</a></td></tr>" >> "$html"
180 done
181 echo "<tr><td><b>Triplets:</b></td></tr>" >> "$html"
182
183 while read sample1 sample2 sample3
184 do
185 sample1="$(echo ${sample1} | tr -d '\r' | tr -d '\n')"
186 sample2="$(echo ${sample2} | tr -d '\r' | tr -d '\n')"
187 sample3="$(echo ${sample3} | tr -d '\r' | tr -d '\n')"
188 patient="${sample1}_${sample2}_${sample3}"
189 echo "$patient"
190 html="${patient}.html"
191 echo "<tr><td><a href='${patient}.html'>$patient</a></td></tr>" >> "index.html"
192 echo "$header" > $html
193 oldLocus=""
194 tail -n+2 ${patient}_freq.txt | sed "s/>//" > tmp.txt
195 echo "<div class='tabber'>" >> "$html"
196 echo "<div class='tabbertab' title='Data frequency'>" >> "$html"
197 echo "<table><tr><td style='vertical-align:top;'>" >> "$html"
198 echo "<table border = 1 class='result_table summary_table' id='summary_table_${patient}_freq'>" >> "$html"
199 echo "<thead><th>Ig/TCR gene rearrangement type</th><th>Proximal gene segment</th><th>Distal gene segment</th><th>Cut off value</th><th>Number of sequences ${patient}_All</th><th>Number of sequences_$sample1</th><th>Number of sequences_$sample2</th><th>Number of sequences_$sample3</th><th>Number of sequences_${sample1}_${sample2}</th><th>Number of sequences_${sample1}_${sample3}</th><th>Number of sequences_${sample2}_${sample3}</th></thead>" >> "$html"
200 echo "<tbody>" >> "$html"
201 scatterplot_tab="<div class='tabbertab' title='Scatter Plots Frequency'><table border='0'><tr>"
202 while read locus j_segment v_segment cut_off_value all one two three one_two one_three two_three
203 do
204 if [ "$locus" != "$oldLocus" ] ; then
205 echo "<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr>" >> "$html"
206 echo "<tr><td><b>$locus</b></td>" >> "$html"
207 else
208 echo "<td></td>" >> "$html"
209 fi
210 echo "<td>$v_segment</td>" >> "$html"
211 echo "<td>$j_segment</td>" >> "$html"
212 echo "<td>>$cut_off_value</td>" >> "$html"
213 if [ "$all" != "0" ] ; then
214 echo "<td data-patient='${patient}' style='cursor:pointer' onclick='javascript:loadfile(\"${sample1}_${sample2}_${sample3}_${locus}_${cut_off_value}.txt\", \"$patient\", \"freq\")'>$all</td>" >> "$html"
215 else
216 echo "<td>$all</td>" >> "$html"
217 fi
218 if [ "$one" != "0" ] && [ "$cut_off_value" != "0" ] ; then
219 echo "<td data-patient='${patient}' style='cursor:pointer' onclick='javascript:loadfile(\"${sample1}_${locus}_${cut_off_value}.txt\", \"$patient\", \"freq\")'>$one</td>" >> "$html"
220 else
221 echo "<td>$one</td>" >> "$html"
222 fi
223 if [ "$two" != "0" ] && [ "$cut_off_value" != "0" ] ; then
224 echo "<td data-patient='${patient}' style='cursor:pointer' onclick='javascript:loadfile(\"${sample2}_${locus}_${cut_off_value}.txt\", \"$patient\", \"freq\")'>$two</td>" >> "$html"
225 else
226 echo "<td>$two</td>" >> "$html"
227 fi
228 if [ "$three" != "0" ] && [ "$cut_off_value" != "0" ] ; then
229 echo "<td data-patient='${patient}' style='cursor:pointer' onclick='javascript:loadfile(\"${sample3}_${locus}_${cut_off_value}.txt\", \"$patient\", \"freq\")'>$three</td>" >> "$html"
230 else
231 echo "<td>$three</td>" >> "$html"
232 fi
233
234 if [ "${one_two}" != "0" ] && [ "$cut_off_value" != "0" ] ; then
235 echo "<td data-patient='${patient}' style='cursor:pointer' onclick='javascript:loadfile(\"${sample1}_${sample2}_${locus}_${cut_off_value}freq.txt\", \"$patient\", \"freq\")'>${one_two}</td>" >> "$html"
236 else
237 echo "<td>${one_two}</td>" >> "$html"
238 fi
239 if [ "${one_three}" != "0" ] && [ "$cut_off_value" != "0" ] ; then
240 echo "<td data-patient='${patient}' style='cursor:pointer' onclick='javascript:loadfile(\"${sample1}_${sample3}_${locus}_${cut_off_value}freq.txt\", \"$patient\", \"freq\")'>${one_three}</td>" >> "$html"
241 else
242 echo "<td>${one_three}</td>" >> "$html"
243 fi
244 if [ "${two_three}" != "0" ] && [ "$cut_off_value" != "0" ] ; then
245 echo "<td data-patient='${patient}' style='cursor:pointer' onclick='javascript:loadfile(\"${sample2}_${sample3}_${locus}_${cut_off_value}freq.txt\", \"$patient\", \"freq\")'>${two_three}</td>" >> "$html"
246 else
247 echo "<td>${two_three}</td>" >> "$html"
248 fi
249
250 echo "</tr>" >> "$html"
251 oldLocus="$locus"
252 if [ "${cut_off_value}" == "0" ] ; then
253 scatterplot_tab="${scatterplot_tab}<td><img src='${sample1}_${sample2}_${sample3}_freq_${locus}_scatter.png' /></td>"
254 fi
255 done < tmp.txt
256 echo "</tbody></table>" >> "$html"
257 echo "</td><td style='vertical-align:top;'><div id='result_div_${patient}_freq'></div></td></tr></table>" >> "$html"
258 echo "</div>" >> "$html"
259 echo "<div class='tabbertab' title='Graphs frequency'>" >> "$html"
260 echo "<a href='${patient}_freq_total_all.png'><img src='${patient}_freq_total_all.png' width='1280' height='720' /></a><br />" >> "$html"
261 echo "<a href='${patient}_freq_indiv_all.png'><img src='${patient}_freq_indiv_all.png' width='1280' height='720' /></a><br /></div>" >> "$html"
262 echo "${scatterplot_tab}</tr></table></div>" >> "$html"
263
264 tail -n+2 ${patient}_reads.txt | sed "s/>//" > tmp.txt
265 echo "<div class='tabbertab' title='Data reads'>" >> "$html"
266 echo "<table><tr><td style='vertical-align:top;'>" >> "$html"
267 echo "<table border = 1 class='result_table summary_table' id='summary_table_${patient}_reads'>" >> "$html"
268 echo "<thead><th>Ig/TCR gene rearrangement type</th><th>Proximal gene segment</th><th>Distal gene segment</th><th>Cut off value</th><th>Number of sequences ${patient}_All</th><th>Number of sequences_$sample1</th><th>Number of sequences_$sample2</th><th>Number of sequences_$sample3</th><th>Number of sequences_${sample1}_${sample2}</th><th>Number of sequences_${sample1}_${sample3}</th><th>Number of sequences_${sample2}_${sample3}</th></thead>" >> "$html"
269 echo "<tbody>" >> "$html"
270 scatterplot_tab="<div class='tabbertab' title='Scatter Plots Reads'><table border='0'><tr>"
271 while read locus j_segment v_segment cut_off_value all one two three one_two one_three two_three
272 do
273 if [ "$locus" != "$oldLocus" ] ; then
274 echo "<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr>" >> "$html"
275 echo "<tr><td><b>$locus</b></td>" >> "$html"
276 else
277 echo "<td></td>" >> "$html"
278 fi
279 echo "<td>$v_segment</td>" >> "$html"
280 echo "<td>$j_segment</td>" >> "$html"
281 echo "<td>>$cut_off_value</td>" >> "$html"
282 if [ "$all" != "0" ] ; then
283 echo "<td data-patient='${patient}' style='cursor:pointer' onclick='javascript:loadfile(\"${sample1}_${sample2}_${sample3}_${locus}_${cut_off_value}.txt\", \"$patient\", \"reads\")'>$all</td>" >> "$html"
284 else
285 echo "<td>$all</td>" >> "$html"
286 fi
287 if [ "$one" != "0" ] && [ "$cut_off_value" != "0" ] ; then
288 echo "<td data-patient='${patient}' style='cursor:pointer' onclick='javascript:loadfile(\"${sample1}_${locus}_${cut_off_value}.txt\", \"$patient\", \"reads\")'>$one</td>" >> "$html"
289 else
290 echo "<td>$one</td>" >> "$html"
291 fi
292 if [ "$two" != "0" ] && [ "$cut_off_value" != "0" ] ; then
293 echo "<td data-patient='${patient}' style='cursor:pointer' onclick='javascript:loadfile(\"${sample2}_${locus}_${cut_off_value}.txt\", \"$patient\", \"reads\")'>$two</td>" >> "$html"
294 else
295 echo "<td>$two</td>" >> "$html"
296 fi
297 if [ "$three" != "0" ] && [ "$cut_off_value" != "0" ] ; then
298 echo "<td data-patient='${patient}' style='cursor:pointer' onclick='javascript:loadfile(\"${sample3}_${locus}_${cut_off_value}.txt\", \"$patient\", \"reads\")'>$three</td>" >> "$html"
299 else
300 echo "<td>$three</td>" >> "$html"
301 fi
302
303 if [ "${one_two}" != "0" ] && [ "$cut_off_value" != "0" ] ; then
304 echo "<td data-patient='${patient}' style='cursor:pointer' onclick='javascript:loadfile(\"${sample1}_${sample2}_${locus}_${cut_off_value}reads.txt\", \"$patient\", \"reads\")'>${one_two}</td>" >> "$html"
305 else
306 echo "<td>${one_two}</td>" >> "$html"
307 fi
308 if [ "${one_three}" != "0" ] && [ "$cut_off_value" != "0" ] ; then
309 echo "<td data-patient='${patient}' style='cursor:pointer' onclick='javascript:loadfile(\"${sample1}_${sample3}_${locus}_${cut_off_value}reads.txt\", \"$patient\", \"reads\")'>${one_three}</td>" >> "$html"
310 else
311 echo "<td>${one_three}</td>" >> "$html"
312 fi
313 if [ "${two_three}" != "0" ] && [ "$cut_off_value" != "0" ] ; then
314 echo "<td data-patient='${patient}' style='cursor:pointer' onclick='javascript:loadfile(\"${sample2}_${sample3}_${locus}_${cut_off_value}reads.txt\", \"$patient\", \"reads\")'>${two_three}</td>" >> "$html"
315 else
316 echo "<td>${two_three}</td>" >> "$html"
317 fi
318
319 echo "</tr>" >> "$html"
320 oldLocus="$locus"
321 if [ "${cut_off_value}" == "0" ] ; then
322 scatterplot_tab="${scatterplot_tab}<td><img src='${sample1}_${sample2}_${sample3}_reads_${locus}_scatter.png' /></td>"
323 fi
324 done < tmp.txt
325 echo "</tbody></table>" >> "$html"
326 echo "</td><td style='vertical-align:top;'><div id='result_div_${patient}_reads'></div></td></tr></table>" >> "$html"
327 echo "</div>" >> "$html"
328 echo "<div class='tabbertab' title='Graphs reads'>" >> "$html"
329 echo "<a href='${patient}_reads_total_all.png'><img src='${patient}_reads_total_all.png' width='1280' height='720' /></a><br />" >> "$html"
330 echo "<a href='${patient}_reads_indiv_all.png'><img src='${patient}_reads_indiv_all.png' width='1280' height='720' /></a><br /></div>" >> "$html"
331 echo "${scatterplot_tab}</tr></table></div>" >> "$html"
332 echo "</div>" >> "$html"
333 echo "</div>" >> "$html"
334 echo "</html>" >> "$html"
335 done < triplets.txt
336 rm tmp.txt
337
338
339 html="index.html"
340
341 echo "</table>" >> "$html"
342 echo "<a href='log.html'>log</a><br />" >> "$html"
343 echo "<a href='single_matches.html'>single_matches</a><br />" >> "$html"
344 echo "<a href='multiple_matches.html'>multiple_matches</a><br />" >> "$html"
345 echo "</html>" >> "$html"
346
347 cp "index.html" "$outputFile"
348