0
|
1 #!/bin/bash
|
|
2
|
|
3 inputFile=$1
|
|
4 outputDir=$3
|
5
|
5 outputFile=$3/index.html #$2
|
0
|
6 clonalType=$4
|
10
|
7 species=$5
|
|
8 locus=$6
|
11
|
9 filterproductive=$7
|
22
|
10 dir="$(cd "$(dirname "$0")" && pwd)"
|
10
|
11 useD="false"
|
22
|
12 if grep -q "$species.*${locus}D" "$dir/genes.txt" ; then
|
23
|
13 echo "species D region in reference db"
|
10
|
14 useD="true"
|
|
15 fi
|
23
|
16 echo "$species"
|
|
17 if [[ "$species" == *"custom"* ]] ; then
|
|
18 loci=(${locus//;/ })
|
|
19 useD="true"
|
|
20 echo "${loci[@]}"
|
|
21 if [[ "${#loci[@]}" -eq "2" ]] ; then
|
|
22 useD="false"
|
|
23 fi
|
|
24 fi
|
0
|
25 mkdir $3
|
22
|
26 cp $dir/genes.txt $outputDir
|
|
27 Rscript --verbose $dir/RScript.r $inputFile $outputDir $outputDir $clonalType "$species" "$locus" $filterproductive 2>&1
|
5
|
28 cp $dir/tabber.js $outputDir
|
|
29 cp $dir/style.css $outputDir
|
|
30 cp $dir/script.js $outputDir
|
6
|
31 cp $dir/jquery-1.11.0.min.js $outputDir
|
10
|
32 samples=`cat $outputDir/samples.txt`
|
15
|
33 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
|
|
34 echo "<table border = 1>" >> $2
|
|
35 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
|
|
36 while IFS=, read sample all productive perc_prod productive_unique perc_prod_un unproductive perc_unprod unproductive_unique perc_unprod_un
|
|
37 do
|
|
38 echo "<tr><td>$sample</td>" >> $2
|
|
39 echo "<td>$all</td>" >> $2
|
16
|
40 echo "<td>$productive (${perc_prod}%)</td>" >> $2
|
|
41 echo "<td>$productive_unique (${perc_prod_un}%)</td>" >> $2
|
|
42 echo "<td>$unproductive (${perc_unprod}%)</td>" >> $2
|
|
43 echo "<td>$unproductive_unique (${perc_unprod_un}%)</td></tr>" >> $2
|
15
|
44 done < $outputDir/productive_counting.txt
|
|
45 echo "</table border></center></html>" >> $2
|
|
46
|
|
47 echo "productive_counting.txt"
|
10
|
48 echo "<html><head><title>Report on:" >> $outputFile
|
|
49 for sample in $samples; do
|
|
50 echo " $sample" >> $outputFile
|
|
51 done
|
|
52 echo "</title><script type='text/javascript' src='jquery-1.11.0.min.js'></script>" >> $outputFile
|
6
|
53 echo "<script type='text/javascript' src='tabber.js'></script>" >> $outputFile
|
|
54 echo "<script type='text/javascript' src='script.js'></script>" >> $outputFile
|
|
55 echo "<link rel='stylesheet' type='text/css' href='style.css'></head>" >> $outputFile
|
|
56 echo "<div class='tabber'><div class='tabbertab' title='Gene frequencies'>" >> $outputFile
|
|
57
|
9
|
58 echo "<img src='CDR3LengthPlot.png'/><br />" >> $outputFile
|
6
|
59 echo "<img src='VFPlot.png'/>" >> $outputFile
|
10
|
60 if [[ "$useD" == "true" ]] ; then
|
|
61 echo "<img src='DFPlot.png'/>" >> $outputFile
|
|
62 fi
|
6
|
63 echo "<img src='JFPlot.png'/>" >> $outputFile
|
5
|
64 echo "<img src='VPlot.png'/>" >> $outputFile
|
10
|
65 if [[ "$useD" == "true" ]] ; then
|
|
66 echo "<img src='DPlot.png'/>" >> $outputFile
|
|
67 fi
|
5
|
68 echo "<img src='JPlot.png'/></div>" >> $outputFile
|
1
|
69
|
0
|
70 count=1
|
5
|
71 echo "<div class='tabbertab' title='Heatmaps'><div class='tabber'>" >> $outputFile
|
0
|
72 for sample in $samples; do
|
5
|
73 echo "<div class='tabbertab' title='$sample'><table border='1'><tr>" >> $outputFile
|
10
|
74 if [[ "$useD" == "true" ]] ; then
|
|
75 echo "<td><img src='HeatmapVD_$sample.png'/></td>" >> $outputFile
|
|
76 fi
|
6
|
77 echo "<td><img src='HeatmapVJ_$sample.png'/></td>" >> $outputFile
|
10
|
78 if [[ "$useD" == "true" ]] ; then
|
|
79 echo "<td><img src='HeatmapDJ_$sample.png'/></td>" >> $outputFile
|
|
80 fi
|
|
81 echo "</tr></table></div>" >> $outputFile
|
5
|
82 count=$((count+1))
|
|
83 done
|
|
84 echo "</div></div>" >> $outputFile
|
|
85
|
10
|
86 #echo "<div class='tabbertab' title='Interactive'><svg class='chart'></svg><script src='http://d3js.org/d3.v3.min.js'></script></div>" >> $outputFile
|
5
|
87
|
|
88 hasReplicateColumn="$(if head -n 1 $inputFile | grep -q 'Replicate'; then echo 'Yes'; else echo 'No'; fi)"
|
|
89 echo "$hasReplicateColumn"
|
|
90 #if its a 'new' merged file with replicate info
|
|
91 if [[ "$hasReplicateColumn" == "Yes" ]] ; then
|
|
92 echo "<div class='tabbertab' title='Clonality'><div class='tabber'>" >> $outputFile
|
|
93 for sample in $samples; do
|
|
94 clonalityScore="$(cat $outputDir/ClonalityScore_$sample.csv)"
|
|
95 echo "<div class='tabbertab' title='$sample'><table border='1'>" >> $outputFile
|
|
96 echo "<tr><td colspan='4'>Clonality Score: $clonalityScore</td></tr>" >> $outputFile
|
|
97
|
0
|
98 #replicate,reads,squared
|
5
|
99 echo "<tr><td>Replicate ID</td><td>Number of Reads</td><td>Reads Squared</td><td></td></tr>" >> $outputFile
|
0
|
100 while IFS=, read replicate reads squared
|
|
101 do
|
|
102
|
5
|
103 echo "<tr><td>$replicate</td><td>$reads</td><td>$squared</td><td></td></tr>" >> $outputFile
|
0
|
104 done < $outputDir/ReplicateReads_$sample.csv
|
|
105
|
|
106 #sum of reads and reads squared
|
|
107 while IFS=, read readsSum squaredSum
|
|
108 do
|
|
109 echo "<tr><td>Sum</td><td>$readsSum</td><td>$squaredSum</td></tr>" >> $outputFile
|
|
110 done < $outputDir/ReplicateSumReads_$sample.csv
|
|
111
|
|
112 #overview
|
5
|
113 echo "<tr><td>Coincidence Type</td><td>Raw Coincidence Freq</td><td>Coincidence Weight</td><td>Coincidences, Weighted</td></tr>" >> $outputFile
|
0
|
114 while IFS=, read type count weight weightedCount
|
|
115 do
|
|
116 echo "<tr><td>$type</td><td>$count</td><td>$weight</td><td>$weightedCount</td></tr>" >> $outputFile
|
|
117 done < $outputDir/ClonalityOverView_$sample.csv
|
5
|
118 echo "</table></div>" >> $outputFile
|
|
119 done
|
|
120 echo "</div></div>" >> $outputFile
|
|
121 fi
|
|
122
|
7
|
123 hasJunctionData="$(if head -n 1 $inputFile | grep -q '3V-REGION trimmed-nt nb'; then echo 'Yes'; else echo 'No'; fi)"
|
|
124
|
|
125 if [[ "$hasJunctionData" == "Yes" ]] ; then
|
20
|
126 echo "<div class='tabbertab' title='Junction Analysis'>" >> $outputFile
|
|
127 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
|
5
|
128 while IFS=, read Sample unique VHDEL P1 N1 P2 DELDH DHDEL P3 N2 P4 DELJH TotalDel TotalN TotalP
|
|
129 do
|
|
130 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
|
20
|
131 done < $outputDir/junctionAnalysisProd.csv
|
|
132 echo "</tbody></table>" >> $outputFile
|
|
133
|
|
134 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
|
|
135 while IFS=, read Sample unique VHDEL P1 N1 P2 DELDH DHDEL P3 N2 P4 DELJH TotalDel TotalN TotalP
|
|
136 do
|
|
137 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
|
|
138 done < $outputDir/junctionAnalysisUnProd.csv
|
|
139 echo "</tbody></table>" >> $outputFile
|
|
140
|
|
141 echo "</div>" >> $outputFile
|
5
|
142 fi
|
|
143
|
|
144 echo "<div class='tabbertab' title='Comparison'><table border='1'><tr><th>ID</th><th>Include</th></tr>" >> $outputFile
|
|
145 for sample in $samples; do
|
|
146 echo "<tr><td>$sample</td><td><input type='checkbox' onchange=\"javascript:compareAdd('$sample')\" id='compare_checkbox_$sample'/></td></tr>" >> $outputFile
|
0
|
147 done
|
5
|
148 echo "</table><div name='comparisonarea'>" >> $outputFile
|
|
149 echo "<table><tr id='comparison_table_vd'></tr></table>" >> $outputFile
|
|
150 echo "<table><tr id='comparison_table_vj'></tr></table>" >> $outputFile
|
|
151 echo "<table><tr id='comparison_table_dj'></tr></table>" >> $outputFile
|
|
152 echo "</div></div>" >> $outputFile
|
0
|
153
|
5
|
154 echo "<div class='tabbertab' title='Downloads'>" >> $outputFile
|
|
155 echo "<table border='1'>" >> $outputFile
|
|
156 echo "<tr><th>Description</th><th>Link</th></tr>" >> $outputFile
|
6
|
157 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
|
|
158 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
|
|
159
|
9
|
160 echo "<tr><td>The dataset used to generate the CDR3 length frequency graph</td><td><a href='CDR3LengthPlot.csv'>Download</a></td></tr>" >> $outputFile
|
|
161
|
6
|
162 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
|
10
|
163 if [[ "$useD" == "true" ]] ; then
|
|
164 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
|
|
165 fi
|
6
|
166 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
|
|
167
|
|
168 echo "<tr><td>The dataset used to generate the V gene frequency graph</td><td><a href='VFrequency.csv'>Download</a></td></tr>" >> $outputFile
|
10
|
169 if [[ "$useD" == "true" ]] ; then
|
|
170 echo "<tr><td>The dataset used to generate the D gene frequency graph</td><td><a href='DFrequency.csv'>Download</a></td></tr>" >> $outputFile
|
|
171 fi
|
6
|
172 echo "<tr><td>The dataset used to generate the J gene frequency graph</td><td><a href='JFrequency.csv'>Download</a></td></tr>" >> $outputFile
|
|
173
|
|
174 for sample in $samples; do
|
10
|
175 if [[ "$useD" == "true" ]] ; then
|
|
176 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
|
|
177 fi
|
6
|
178 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
|
10
|
179 if [[ "$useD" == "true" ]] ; then
|
|
180 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
|
|
181 fi
|
6
|
182 done
|
|
183
|
5
|
184 echo "</table>" >> $outputFile
|
6
|
185 echo "</div></html>" >> $outputFile
|