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