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