0
|
1 #!/bin/bash
|
|
2
|
|
3 inputFile=$1
|
|
4 outputDir=$3
|
|
5 outputFile=$3/index.html #$2
|
|
6 clonalType=$4
|
|
7 species=$5
|
|
8 locus=$6
|
|
9 filterproductive=$7
|
|
10 clonality_method=$8
|
|
11 dir="$(cd "$(dirname "$0")" && pwd)"
|
|
12 useD="false"
|
|
13 if grep -q "$species.*${locus}D" "$dir/genes.txt" ; then
|
|
14 echo "species D region in reference db"
|
|
15 useD="true"
|
|
16 fi
|
|
17 echo "$species"
|
|
18 if [[ "$species" == *"custom"* ]] ; then
|
|
19 loci=(${locus//;/ })
|
|
20 useD="true"
|
|
21 echo "${loci[@]}"
|
|
22 if [[ "${#loci[@]}" -eq "2" ]] ; then
|
|
23 useD="false"
|
|
24 fi
|
|
25 fi
|
|
26 mkdir $3
|
|
27 cp $dir/genes.txt $outputDir
|
|
28 Rscript --verbose $dir/RScript.r $inputFile $outputDir $outputDir $clonalType "$species" "$locus" $filterproductive ${clonality_method} 2>&1
|
|
29 cp $dir/tabber.js $outputDir
|
|
30 cp $dir/style.css $outputDir
|
|
31 cp $dir/script.js $outputDir
|
|
32 cp $dir/jquery-1.11.0.min.js $outputDir
|
|
33 samples=`cat $outputDir/samples.txt`
|
34
|
34 CIRCOSTOOLS="/home/galaxy/Downloads/circos-master/tools"
|
0
|
35 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)<br />" > $2
|
|
36 echo "<table border = 1>" >> $2
|
|
37 echo "<thead><tr><th>Sample/Replicate</th><th>All</th><th>Productive</th><th>Unique Productive</th><th>Unproductive</th><th>Unique Unproductive</th></tr></thead>" >> $2
|
|
38 while IFS=, read sample all productive perc_prod productive_unique perc_prod_un unproductive perc_unprod unproductive_unique perc_unprod_un
|
|
39 do
|
|
40 echo "<tr><td>$sample</td>" >> $2
|
|
41 echo "<td>$all</td>" >> $2
|
|
42 echo "<td>$productive (${perc_prod}%)</td>" >> $2
|
|
43 echo "<td>$productive_unique (${perc_prod_un}%)</td>" >> $2
|
|
44 echo "<td>$unproductive (${perc_unprod}%)</td>" >> $2
|
|
45 echo "<td>$unproductive_unique (${perc_unprod_un}%)</td></tr>" >> $2
|
|
46 done < $outputDir/productive_counting.txt
|
|
47 echo "</table border></center></html>" >> $2
|
|
48
|
|
49 echo "productive_counting.txt"
|
|
50 echo "<html><head><title>Report on:" >> $outputFile
|
34
|
51
|
|
52 mkdir $outputDir/circos
|
|
53 cp $dir/circos/* $outputDir/circos/
|
35
|
54 sed -i "s%DATA_DIR%$outputDir/circos%" $outputDir/circos/circos.conf
|
|
55 for sample in $samples; do #output the samples to a file and create the circos plots with the R script output
|
0
|
56 echo " $sample" >> $outputFile
|
34
|
57
|
35
|
58 circos_file="$outputDir/${sample}_VJ_circos.txt"
|
|
59 echo -e -n "labels$(cat ${circos_file})" > ${circos_file}
|
|
60 cat "${circos_file}" | $CIRCOSTOOLS/tableviewer/bin/parse-table -configfile $dir/circos/parse-table.conf 2>&1 | $CIRCOSTOOLS/tableviewer/bin/make-conf -dir $outputDir/circos/
|
40
|
61 #/home/galaxy/Downloads/circos-master/bin/circos -conf $outputDir/circos/circos.conf 2>&1
|
|
62 circos -conf $outputDir/circos/circos.conf 2>&1
|
35
|
63 mv $outputDir/circos/circos.png $outputDir/circosVJ_${sample}.png
|
|
64
|
|
65
|
|
66 if [[ "$useD" == "true" ]] ; then
|
34
|
67 circos_file="$outputDir/${sample}_VD_circos.txt"
|
|
68 echo -e -n "labels$(cat ${circos_file})" > ${circos_file}
|
35
|
69 cat "${circos_file}" | $CIRCOSTOOLS/tableviewer/bin/parse-table -configfile $dir/circos/parse-table.conf 2>&1 | $CIRCOSTOOLS/tableviewer/bin/make-conf -dir $outputDir/circos/
|
|
70 /home/galaxy/Downloads/circos-master/bin/circos -conf $outputDir/circos/circos.conf 2>&1
|
|
71 mv $outputDir/circos/circos.png $outputDir/circosVD_${sample}.png
|
|
72
|
|
73 circos_file="$outputDir/${sample}_DJ_circos.txt"
|
|
74 echo -e -n "labels$(cat ${circos_file})" > ${circos_file}
|
|
75 cat "${circos_file}" | $CIRCOSTOOLS/tableviewer/bin/parse-table -configfile $dir/circos/parse-table.conf 2>&1 | $CIRCOSTOOLS/tableviewer/bin/make-conf -dir $outputDir/circos/
|
|
76 /home/galaxy/Downloads/circos-master/bin/circos -conf $outputDir/circos/circos.conf 2>&1
|
|
77 mv $outputDir/circos/circos.png $outputDir/circosDJ_${sample}.png
|
|
78
|
|
79 fi
|
0
|
80 done
|
|
81 echo "</title><script type='text/javascript' src='jquery-1.11.0.min.js'></script>" >> $outputFile
|
|
82 echo "<script type='text/javascript' src='tabber.js'></script>" >> $outputFile
|
|
83 echo "<script type='text/javascript' src='script.js'></script>" >> $outputFile
|
|
84 echo "<link rel='stylesheet' type='text/css' href='style.css'></head>" >> $outputFile
|
|
85 echo "<div class='tabber'><div class='tabbertab' title='Gene frequencies'>" >> $outputFile
|
|
86
|
|
87 echo "<img src='CDR3LengthPlot.png'/><br />" >> $outputFile
|
|
88 echo "<img src='VFPlot.png'/>" >> $outputFile
|
|
89 if [[ "$useD" == "true" ]] ; then
|
|
90 echo "<img src='DFPlot.png'/>" >> $outputFile
|
|
91 fi
|
|
92 echo "<img src='JFPlot.png'/>" >> $outputFile
|
|
93 echo "<img src='VPlot.png'/>" >> $outputFile
|
|
94 if [[ "$useD" == "true" ]] ; then
|
|
95 echo "<img src='DPlot.png'/>" >> $outputFile
|
|
96 fi
|
|
97 echo "<img src='JPlot.png'/>" >> $outputFile
|
|
98 echo "<img src='AAComposition.png'/></div>" >> $outputFile
|
|
99
|
35
|
100 #Heatmaps
|
|
101
|
0
|
102 count=1
|
|
103 echo "<div class='tabbertab' title='Heatmaps'><div class='tabber'>" >> $outputFile
|
|
104 for sample in $samples; do
|
|
105 echo "<div class='tabbertab' title='$sample'><table border='1'><tr>" >> $outputFile
|
|
106 if [[ "$useD" == "true" ]] ; then
|
|
107 echo "<td><img src='HeatmapVD_$sample.png'/></td>" >> $outputFile
|
|
108 fi
|
|
109 echo "<td><img src='HeatmapVJ_$sample.png'/></td>" >> $outputFile
|
|
110 if [[ "$useD" == "true" ]] ; then
|
|
111 echo "<td><img src='HeatmapDJ_$sample.png'/></td>" >> $outputFile
|
|
112 fi
|
|
113 echo "</tr></table></div>" >> $outputFile
|
|
114 count=$((count+1))
|
|
115 done
|
|
116 echo "</div></div>" >> $outputFile
|
|
117
|
35
|
118 #circos
|
|
119
|
|
120 echo "<div class='tabbertab' title='Circos'><div class='tabber'>" >> $outputFile
|
|
121 for sample in $samples; do
|
|
122 echo "<div class='tabbertab' title='$sample'><table border='1'><center>" >> $outputFile
|
|
123 if [[ "$useD" == "true" ]] ; then
|
|
124 echo "<tr><td>V-D</td><td><img src='circosVD_${sample}.png' width='700' height='700'/></td></tr>" >> $outputFile
|
|
125 fi
|
|
126 echo "<tr><td>V-J</td><td><img src='circosVJ_${sample}.png' width='700' height='700'/></td></tr>" >> $outputFile
|
|
127 if [[ "$useD" == "true" ]] ; then
|
|
128 echo "<tr><td>D-J</td><td><img src='circosDJ_${sample}.png' width='700' height='700'/></td></tr>" >> $outputFile
|
|
129 fi
|
|
130 echo "<center></table></div>" >> $outputFile
|
|
131 count=$((count+1))
|
|
132 done
|
|
133 echo "</div></div>" >> $outputFile
|
|
134
|
0
|
135 #echo "<div class='tabbertab' title='Interactive'><svg class='chart'></svg><script src='http://d3js.org/d3.v3.min.js'></script></div>" >> $outputFile
|
|
136
|
|
137 hasReplicateColumn="$(if head -n 1 $inputFile | grep -q 'Replicate'; then echo 'Yes'; else echo 'No'; fi)"
|
|
138 echo "$hasReplicateColumn"
|
|
139 #if its a 'new' merged file with replicate info
|
34
|
140 if [[ "$hasReplicateColumn" == "Yes" ]] ; then
|
0
|
141 echo "<div class='tabbertab' title='Clonality'><div class='tabber'>" >> $outputFile
|
|
142 for sample in $samples; do
|
|
143 echo "${clonality_method}"
|
|
144 if [[ "${clonality_method}" == "old" ]] ; then
|
|
145 echo "in old"
|
|
146 clonalityScore="$(cat $outputDir/ClonalityScore_$sample.csv)"
|
|
147 echo "<div class='tabbertab' title='$sample'><table border='1'>" >> $outputFile
|
|
148 echo "<tr><td colspan='4'>Clonality Score: $clonalityScore</td></tr>" >> $outputFile
|
|
149
|
|
150 #replicate,reads,squared
|
|
151 echo "<tr><td>Replicate ID</td><td>Number of Reads</td><td>Reads Squared</td><td></td></tr>" >> $outputFile
|
|
152 while IFS=, read replicate reads squared
|
|
153 do
|
|
154
|
|
155 echo "<tr><td>$replicate</td><td>$reads</td><td>$squared</td><td></td></tr>" >> $outputFile
|
|
156 done < $outputDir/ReplicateReads_$sample.csv
|
|
157
|
|
158 #sum of reads and reads squared
|
|
159 while IFS=, read readsSum squaredSum
|
|
160 do
|
|
161 echo "<tr><td>Sum</td><td>$readsSum</td><td>$squaredSum</td></tr>" >> $outputFile
|
|
162 done < $outputDir/ReplicateSumReads_$sample.csv
|
|
163
|
|
164 #overview
|
|
165 echo "<tr><td>Coincidence Type</td><td>Raw Coincidence Freq</td><td>Coincidence Weight</td><td>Coincidences, Weighted</td></tr>" >> $outputFile
|
|
166 while IFS=, read type count weight weightedCount
|
|
167 do
|
|
168 echo "<tr><td>$type</td><td>$count</td><td>$weight</td><td>$weightedCount</td></tr>" >> $outputFile
|
|
169 done < $outputDir/ClonalityOverView_$sample.csv
|
|
170 echo "</table></div>" >> $outputFile
|
|
171 else
|
|
172 echo "in new"
|
|
173 clonalityScore="$(cat $outputDir/lymphclon_clonality_${sample}.csv)"
|
|
174 echo "<div class='tabbertab' title='$sample'>" >> $outputFile
|
|
175 echo "Lymphclon clonality score: <br />$clonalityScore<br /><br />" >> $outputFile
|
|
176 echo "<table border = 1>" >> $outputFile
|
|
177 while IFS=, read type count
|
|
178 do
|
|
179 echo "<tr><td>$type</td><td>$count</td></tr>" >> $outputFile
|
|
180 done < $outputDir/lymphclon_coincidences_$sample.csv
|
|
181 echo "</table></div>" >> $outputFile
|
|
182 fi
|
|
183 done
|
|
184 echo "</div></div>" >> $outputFile
|
|
185 fi
|
|
186
|
34
|
187 #hasJunctionData="$(if head -n 1 $inputFile | grep -qE '3V.REGION.trimmed.nt.nb'; then echo 'Yes'; else echo 'No'; fi)"
|
0
|
188
|
34
|
189 #if [[ "$hasJunctionData" == "Yes" ]] ; then
|
|
190 if [ -a "$outputDir/junctionAnalysisProd.csv" ] ; then
|
0
|
191 echo "<div class='tabbertab' title='Junction Analysis'>" >> $outputFile
|
|
192 echo "<table border='1' id='junction_table'> <caption>Productive</caption><thead><tr><th>Sample</th><th>count</th><th>VH.DEL</th><th>P1</th><th>N1</th><th>P2</th><th>DEL.DH</th><th>DH.DEL</th><th>P3</th><th>N2</th><th>P4</th><th>DEL.JH</th><th>Total.Del</th><th>Total.N</th><th>Total.P</th><thead></tr><tbody>" >> $outputFile
|
|
193 while IFS=, read Sample unique VHDEL P1 N1 P2 DELDH DHDEL P3 N2 P4 DELJH TotalDel TotalN TotalP
|
|
194 do
|
|
195 echo "<tr><td>$Sample</td><td>$unique</td><td>$VHDEL</td><td>$P1</td><td>$N1</td><td>$P2</td><td>$DELDH</td><td>$DHDEL</td><td>$P3</td><td>$N2</td><td>$P4</td><td>$DELJH</td><td>$TotalDel</td><td>$TotalN</td><td>$TotalP</td></tr>" >> $outputFile
|
|
196 done < $outputDir/junctionAnalysisProd.csv
|
|
197 echo "</tbody></table>" >> $outputFile
|
|
198
|
|
199 echo "<table border='1' id='junction_table'> <caption>Unproductive</caption><thead><tr><th>Sample</th><th>count</th><th>VH.DEL</th><th>P1</th><th>N1</th><th>P2</th><th>DEL.DH</th><th>DH.DEL</th><th>P3</th><th>N2</th><th>P4</th><th>DEL.JH</th><th>Total.Del</th><th>Total.N</th><th>Total.P</th><thead></tr><tbody>" >> $outputFile
|
|
200 while IFS=, read Sample unique VHDEL P1 N1 P2 DELDH DHDEL P3 N2 P4 DELJH TotalDel TotalN TotalP
|
|
201 do
|
|
202 echo "<tr><td>$Sample</td><td>$unique</td><td>$VHDEL</td><td>$P1</td><td>$N1</td><td>$P2</td><td>$DELDH</td><td>$DHDEL</td><td>$P3</td><td>$N2</td><td>$P4</td><td>$DELJH</td><td>$TotalDel</td><td>$TotalN</td><td>$TotalP</td></tr>" >> $outputFile
|
|
203 done < $outputDir/junctionAnalysisUnProd.csv
|
|
204 echo "</tbody></table>" >> $outputFile
|
|
205
|
|
206 echo "</div>" >> $outputFile
|
|
207 fi
|
|
208
|
|
209 echo "<div class='tabbertab' title='Comparison'><table border='1'><tr><th>ID</th><th>Include</th></tr>" >> $outputFile
|
|
210 for sample in $samples; do
|
|
211 echo "<tr><td>$sample</td><td><input type='checkbox' onchange=\"javascript:compareAdd('$sample')\" id='compare_checkbox_$sample'/></td></tr>" >> $outputFile
|
|
212 done
|
|
213 echo "</table><div name='comparisonarea'>" >> $outputFile
|
|
214 echo "<table><tr id='comparison_table_vd'></tr></table>" >> $outputFile
|
|
215 echo "<table><tr id='comparison_table_vj'></tr></table>" >> $outputFile
|
|
216 echo "<table><tr id='comparison_table_dj'></tr></table>" >> $outputFile
|
|
217 echo "</div></div>" >> $outputFile
|
|
218
|
|
219 echo "<div class='tabbertab' title='Downloads'>" >> $outputFile
|
|
220 echo "<table border='1'>" >> $outputFile
|
|
221 echo "<tr><th>Description</th><th>Link</th></tr>" >> $outputFile
|
|
222 echo "<tr><td>The dataset used to generate the frequency graphs and the heatmaps (Unique based on clonaltype, $clonalType)</td><td><a href='allUnique.csv'>Download</a></td></tr>" >> $outputFile
|
|
223 echo "<tr><td>The dataset used to calculate clonality score (Unique based on clonaltype, $clonalType)</td><td><a href='clonalityComplete.csv'>Download</a></td></tr>" >> $outputFile
|
|
224
|
|
225 echo "<tr><td>The dataset used to generate the CDR3 length frequency graph</td><td><a href='CDR3LengthPlot.csv'>Download</a></td></tr>" >> $outputFile
|
|
226
|
|
227 echo "<tr><td>The dataset used to generate the V gene family frequency graph</td><td><a href='VFFrequency.csv'>Download</a></td></tr>" >> $outputFile
|
|
228 if [[ "$useD" == "true" ]] ; then
|
|
229 echo "<tr><td>The dataset used to generate the D gene family frequency graph</td><td><a href='DFFrequency.csv'>Download</a></td></tr>" >> $outputFile
|
|
230 fi
|
|
231 echo "<tr><td>The dataset used to generate the J gene family frequency graph</td><td><a href='JFFrequency.csv'>Download</a></td></tr>" >> $outputFile
|
|
232
|
|
233 echo "<tr><td>The dataset used to generate the V gene frequency graph</td><td><a href='VFrequency.csv'>Download</a></td></tr>" >> $outputFile
|
|
234 if [[ "$useD" == "true" ]] ; then
|
|
235 echo "<tr><td>The dataset used to generate the D gene frequency graph</td><td><a href='DFrequency.csv'>Download</a></td></tr>" >> $outputFile
|
|
236 fi
|
|
237 echo "<tr><td>The dataset used to generate the J gene frequency graph</td><td><a href='JFrequency.csv'>Download</a></td></tr>" >> $outputFile
|
|
238 echo "<tr><td>The dataset used to generate the AA composition graph</td><td><a href='AAComposition.csv'>Download</a></td></tr>" >> $outputFile
|
|
239
|
|
240 for sample in $samples; do
|
|
241 if [[ "$useD" == "true" ]] ; then
|
|
242 echo "<tr><td>The data used to generate the VD heatmap for $sample.</td><td><a href='HeatmapVD_$sample.csv'>Download</a></td></tr>" >> $outputFile
|
|
243 fi
|
|
244 echo "<tr><td>The data used to generate the VJ heatmap for $sample.</td><td><a href='HeatmapVJ_$sample.csv'>Download</a></td></tr>" >> $outputFile
|
|
245 if [[ "$useD" == "true" ]] ; then
|
|
246 echo "<tr><td>The data used to generate the DJ heatmap for $sample.</td><td><a href='HeatmapDJ_$sample.csv'>Download</a></td></tr>" >> $outputFile
|
|
247 fi
|
|
248 done
|
|
249
|
|
250 echo "</table>" >> $outputFile
|
|
251 echo "</div></html>" >> $outputFile
|