annotate report_clonality/r_wrapper.sh.old @ 26:28fbbdfd7a87 draft

Uploaded
author davidvanzessen
date Mon, 13 Feb 2017 09:08:46 -0500
parents 9185c3dfc679
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
20
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
1 #!/bin/bash
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
2
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
3 inputFile=$1
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
4 outputDir=$3
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
5 outputFile=$3/index.html #$2
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
6 clonalType=$4
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
7 species=$5
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
8 locus=$6
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
9 filterproductive=$7
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
10 clonality_method=$8
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
11
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
12 dir="$(cd "$(dirname "$0")" && pwd)"
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
13 useD="false"
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
14 if grep -q "$species.*${locus}D" "$dir/genes.txt" ; then
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
15 echo "species D region in reference db"
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
16 useD="true"
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
17 fi
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
18 echo "$species"
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
19 if [[ "$species" == *"custom"* ]] ; then
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
20 loci=(${locus//;/ })
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
21 useD="true"
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
22 echo "${loci[@]}"
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
23 if [[ "${#loci[@]}" -eq "2" ]] ; then
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
24 useD="false"
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
25 fi
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
26 fi
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
27 mkdir $3
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
28 cp $dir/genes.txt $outputDir
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
29 Rscript --verbose $dir/RScript.r $inputFile $outputDir $outputDir $clonalType "$species" "$locus" $filterproductive ${clonality_method} 2>&1
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
30 cp $dir/tabber.js $outputDir
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
31 cp $dir/style.css $outputDir
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
32 cp $dir/script.js $outputDir
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
33 cp $dir/jquery-1.11.0.min.js $outputDir
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
34 cp $dir/pure-min.css $outputDir
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
35 samples=`cat $outputDir/samples.txt`
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
36
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
37 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
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
38 echo "<table border = 1>" >> $2
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
39 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
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
40 while IFS=, read sample all productive perc_prod productive_unique perc_prod_un unproductive perc_unprod unproductive_unique perc_unprod_un
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
41 do
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
42 echo "<tr><td>$sample</td>" >> $2
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
43 echo "<td>$all</td>" >> $2
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
44 echo "<td>$productive (${perc_prod}%)</td>" >> $2
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
45 echo "<td>$productive_unique (${perc_prod_un}%)</td>" >> $2
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
46 echo "<td>$unproductive (${perc_unprod}%)</td>" >> $2
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
47 echo "<td>$unproductive_unique (${perc_unprod_un}%)</td></tr>" >> $2
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
48 done < $outputDir/productive_counting.txt
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
49 echo "</table border></center></html>" >> $2
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
50
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
51 echo "<html><head><title>Report on:" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
52
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
53 mkdir $outputDir/circos
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
54 cp $dir/circos/* $outputDir/circos/
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
55 #CIRCOSTOOLS="/data/galaxy/galaxy-dist/toolsheddependencies/circos/0.64/saskia-hiltemann/cg_circos_plots/bbfdd52d64fd/circos-tools-0.21/tools"
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
56 #CIRCOSDIR="/data/galaxy/galaxy-dist/toolsheddependencies/circos/0.64/saskia-hiltemann/cg_circos_plots/bbfdd52d64fd/bin/"
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
57
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
58 #CIRCOSTOOLS="/home/galaxy/circos/circos-tools-0.22/tools"
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
59 #CIRCOSDIR="/home/galaxy/Anaconda3/bin"
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
60
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
61 USECIRCOS="no"
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
62 if [ -d "$CIRCOSDIR" ]; then
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
63 USECIRCOS="yes"
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
64 else
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
65 if [ -d "/data/galaxy/galaxy-dist/toolsheddependencies/circos/0.64/saskia-hiltemann/cg_circos_plots/bbfdd52d64fd/bin/" ]; then #hopefully temporary fix
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
66 USECIRCOS="yes"
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
67 CIRCOSTOOLS="/data/galaxy/galaxy-dist/toolsheddependencies/circos/0.64/saskia-hiltemann/cg_circos_plots/bbfdd52d64fd/circos-tools-0.21/tools"
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
68 CIRCOSDIR="/data/galaxy/galaxy-dist/toolsheddependencies/circos/0.64/saskia-hiltemann/cg_circos_plots/bbfdd52d64fd/bin/"
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
69 fi
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
70
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
71 if [ -d "/home/galaxy/Anaconda3/bin" ]; then #hopefully temporary fix
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
72 USECIRCOS="yes"
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
73 CIRCOSTOOLS="/home/galaxy/circos/circos-tools-0.22/tools"
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
74 CIRCOSDIR="/home/galaxy/Anaconda3/bin"
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
75 fi
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
76 fi
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
77
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
78 echo "Using Circos: $USECIRCOS"
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
79 sed -i "s%DATA_DIR%$outputDir/circos%" $outputDir/circos/circos.conf
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
80 for sample in $samples; do #output the samples to a file and create the circos plots with the R script output
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
81 echo " $sample" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
82
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
83 if [[ "$USECIRCOS" != "yes" ]]; then
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
84 continue
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
85 fi
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
86
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
87 circos_file="$outputDir/${sample}_VJ_circos.txt"
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
88 echo -e -n "labels$(cat ${circos_file})" > ${circos_file}
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
89 cat "${circos_file}" | $CIRCOSTOOLS/tableviewer/bin/parse-table -configfile $dir/circos/parse-table.conf 2>&1 | $CIRCOSTOOLS/tableviewer/bin/make-conf -dir $outputDir/circos/
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
90 $CIRCOSDIR/circos -conf $outputDir/circos/circos.conf 2>&1
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
91 mv $outputDir/circos/circos.png $outputDir/circosVJ_${sample}.png
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
92
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
93
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
94 if [[ "$useD" == "true" ]] ; then
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
95 circos_file="$outputDir/${sample}_VD_circos.txt"
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
96 echo -e -n "labels$(cat ${circos_file})" > ${circos_file}
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
97 cat "${circos_file}" | $CIRCOSTOOLS/tableviewer/bin/parse-table -configfile $dir/circos/parse-table.conf 2>&1 | $CIRCOSTOOLS/tableviewer/bin/make-conf -dir $outputDir/circos/
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
98 $CIRCOSDIR/circos -conf $outputDir/circos/circos.conf 2>&1
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
99 mv $outputDir/circos/circos.png $outputDir/circosVD_${sample}.png
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
100
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
101 circos_file="$outputDir/${sample}_DJ_circos.txt"
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
102 echo -e -n "labels$(cat ${circos_file})" > ${circos_file}
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
103 cat "${circos_file}" | $CIRCOSTOOLS/tableviewer/bin/parse-table -configfile $dir/circos/parse-table.conf 2>&1 | $CIRCOSTOOLS/tableviewer/bin/make-conf -dir $outputDir/circos/
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
104 $CIRCOSDIR/circos -conf $outputDir/circos/circos.conf 2>&1
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
105 mv $outputDir/circos/circos.png $outputDir/circosDJ_${sample}.png
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
106
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
107 fi
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
108 done
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
109 echo "</title><script type='text/javascript' src='jquery-1.11.0.min.js'></script>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
110 echo "<link rel='stylesheet' type='text/css' href='pure-min.css'>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
111 echo "<script type='text/javascript' src='tabber.js'></script>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
112 echo "<script type='text/javascript' src='script.js'></script>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
113 echo "<link rel='stylesheet' type='text/css' href='style.css'></head>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
114 echo "<div class='tabber'><div class='tabbertab' title='Gene frequencies'>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
115
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
116
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
117 echo "<img src='VFPlot.png'/>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
118 if [[ "$useD" == "true" ]] ; then
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
119 echo "<img src='DFPlot.png'/>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
120 fi
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
121 echo "<img src='VPlot.png'/>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
122 if [[ "$useD" == "true" ]] ; then
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
123 echo "<img src='DPlot.png'/>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
124 fi
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
125 echo "<img src='JPlot.png'/>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
126 echo "</div>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
127
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
128 echo "<div class='tabbertab' title='CDR3 Characteristics'>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
129 echo "<img src='CDR3LengthPlot.png'/><br />" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
130 echo "<img src='AAComposition.png'/>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
131 echo "<img src='DReadingFrame.png'/>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
132
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
133 echo "<table class='pure-table pure-table-striped'>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
134 echo "<thead><tr><th>Sample</th><th>Median CDR3 Length</th></tr></thead>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
135 while IFS=, read Sample median
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
136 do
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
137 echo "<tr><td>$Sample</td><td>$median</td></tr>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
138 done < $outputDir/AAMedianBySample.csv
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
139 echo "</table>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
140
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
141 echo "</div>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
142
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
143 #Heatmaps
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
144
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
145 count=1
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
146 echo "<div class='tabbertab' title='Heatmaps'><div class='tabber'>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
147 for sample in $samples; do
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
148 echo "<div class='tabbertab' title='$sample'><table border='1'><tr>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
149 if [[ "$useD" == "true" ]] ; then
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
150 echo "<td><img src='HeatmapVD_$sample.png'/></td>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
151 fi
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
152 echo "<td><img src='HeatmapVJ_$sample.png'/></td>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
153 if [[ "$useD" == "true" ]] ; then
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
154 echo "<td><img src='HeatmapDJ_$sample.png'/></td>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
155 fi
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
156 echo "</tr></table></div>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
157 count=$((count+1))
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
158 done
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
159 echo "</div></div>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
160
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
161 #circos
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
162
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
163 if [[ "$USECIRCOS" == "yes" ]]; then
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
164
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
165 echo "<div class='tabbertab' title='Circos'><div class='tabber'>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
166 for sample in $samples; do
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
167 echo "<div class='tabbertab' title='$sample'><table border='1'><center>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
168 if [[ "$useD" == "true" ]] ; then
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
169 echo "<tr><td>V-D</td><td><img src='circosVD_${sample}.png' width='700' height='700'/></td></tr>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
170 fi
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
171 echo "<tr><td>V-J</td><td><img src='circosVJ_${sample}.png' width='700' height='700'/></td></tr>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
172 if [[ "$useD" == "true" ]] ; then
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
173 echo "<tr><td>D-J</td><td><img src='circosDJ_${sample}.png' width='700' height='700'/></td></tr>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
174 fi
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
175 echo "<center></table></div>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
176 count=$((count+1))
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
177 done
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
178 echo "</div></div>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
179 fi
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
180 #echo "<div class='tabbertab' title='Interactive'><svg class='chart'></svg><script src='http://d3js.org/d3.v3.min.js'></script></div>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
181
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
182 hasReplicateColumn="$(if head -n 1 $inputFile | grep -q 'Replicate'; then echo 'Yes'; else echo 'No'; fi)"
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
183 echo "$hasReplicateColumn"
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
184 #if its a 'new' merged file with replicate info
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
185 if [[ "$hasReplicateColumn" == "Yes" ]] ; then
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
186 echo "<div class='tabbertab' title='Clonality'><div class='tabber'>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
187 for sample in $samples; do
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
188 echo "${clonality_method}"
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
189 if [[ "${clonality_method}" == "old" ]] ; then
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
190 echo "in old"
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
191 clonalityScore="$(cat $outputDir/ClonalityScore_$sample.csv)"
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
192 echo "<div class='tabbertab' title='$sample'><table class='pure-table pure-table-striped'>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
193 echo "<thead><tr><th colspan='4'>Clonality Score: $clonalityScore</th></tr></thead>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
194
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
195 #replicate,reads,squared
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
196 echo "<tr><td>Replicate ID</td><td>Number of Reads</td></tr>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
197 while IFS=, read replicate reads squared
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
198 do
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
199 echo "<tr><td>$replicate</td><td>$reads</td></tr>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
200 done < $outputDir/ReplicateReads_$sample.csv
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
201
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
202 #sum of reads and reads squared
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
203 while IFS=, read readsSum squaredSum
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
204 do
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
205 echo "<tr><td>Sum</td><td>$readsSum</td></tr>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
206 done < $outputDir/ReplicateSumReads_$sample.csv
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
207
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
208 #overview
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
209 echo "<tr><td>Coincidence Type</td><td>Raw Coincidence Freq</td></tr>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
210 while IFS=, read type count weight weightedCount
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
211 do
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
212 if [[ "$type" -eq "1" ]]; then
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
213 echo "<tr><td>$type</td><td>$count</td></tr>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
214 else
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
215 echo "<tr><td><a href='coincidences_${sample}_${type}.txt'>$type</a></td><td>$count</td></tr>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
216 fi
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
217
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
218 done < $outputDir/ClonalityOverView_$sample.csv
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
219 echo "</table></div>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
220 else
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
221 echo "in new"
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
222 clonalityScore="$(cat $outputDir/lymphclon_clonality_${sample}.csv)"
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
223 echo "<div class='tabbertab' title='$sample'>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
224 echo "Lymphclon clonality score: <br />$clonalityScore<br /><br />" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
225 echo "<table border = 1>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
226 while IFS=, read type count
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
227 do
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
228 echo "<tr><td>$type</td><td>$count</td></tr>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
229 done < $outputDir/lymphclon_coincidences_$sample.csv
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
230 echo "</table></div>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
231 fi
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
232 done
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
233 echo "</div></div>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
234 fi
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
235
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
236 #hasJunctionData="$(if head -n 1 $inputFile | grep -qE '3V.REGION.trimmed.nt.nb'; then echo 'Yes'; else echo 'No'; fi)"
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
237
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
238 #if [[ "$hasJunctionData" == "Yes" ]] ; then
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
239 if [ -a "$outputDir/junctionAnalysisProd_mean.csv" ] ; then
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
240 echo "<div class='tabbertab' title='Junction Analysis'>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
241 echo "<table class='pure-table pure-table-striped' id='junction_table'> <caption>Productive mean</caption><thead><tr><th>Sample</th><th>count</th><th>V.DEL</th><th>P1</th><th>N1</th><th>P2</th><th>DEL.D</th><th>D.DEL</th><th>P3</th><th>N2</th><th>P4</th><th>DEL.J</th><th>Total.Del</th><th>Total.N</th><th>Total.P</th><th>Median.CDR3</th><thead></tr><tbody>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
242 while IFS=, read Sample unique VDEL P1 N1 P2 DELD DDEL P3 N2 P4 DELJ TotalDel TotalN TotalP median
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
243 do
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
244 echo "<tr><td>$Sample</td><td>$unique</td><td>$VDEL</td><td>$P1</td><td>$N1</td><td>$P2</td><td>$DELD</td><td>$DDEL</td><td>$P3</td><td>$N2</td><td>$P4</td><td>$DELJ</td><td>$TotalDel</td><td>$TotalN</td><td>$TotalP</td><td>$median</td></tr>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
245 done < $outputDir/junctionAnalysisProd_mean.csv
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
246 echo "</tbody></table>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
247
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
248 echo "<table class='pure-table pure-table-striped' id='junction_table'> <caption>Unproductive mean</caption><thead><tr><th>Sample</th><th>count</th><th>V.DEL</th><th>P1</th><th>N1</th><th>P2</th><th>DEL.D</th><th>D.DEL</th><th>P3</th><th>N2</th><th>P4</th><th>DEL.J</th><th>Total.Del</th><th>Total.N</th><th>Total.P</th><th>Median.CDR3</th><thead></tr><tbody>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
249 while IFS=, read Sample unique VDEL P1 N1 P2 DELD DDEL P3 N2 P4 DELJ TotalDel TotalN TotalP median
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
250 do
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
251 echo "<tr><td>$Sample</td><td>$unique</td><td>$VDEL</td><td>$P1</td><td>$N1</td><td>$P2</td><td>$DELD</td><td>$DDEL</td><td>$P3</td><td>$N2</td><td>$P4</td><td>$DELJ</td><td>$TotalDel</td><td>$TotalN</td><td>$TotalP</td><td>$median</td></tr>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
252 done < $outputDir/junctionAnalysisUnProd_mean.csv
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
253 echo "</tbody></table>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
254
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
255 echo "<table class='pure-table pure-table-striped' id='junction_table'> <caption>Productive median</caption><thead><tr><th>Sample</th><th>count</th><th>V.DEL</th><th>P1</th><th>N1</th><th>P2</th><th>DEL.D</th><th>D.DEL</th><th>P3</th><th>N2</th><th>P4</th><th>DEL.J</th><th>Total.Del</th><th>Total.N</th><th>Total.P</th><th>Median.CDR3</th><thead></tr><tbody>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
256 while IFS=, read Sample unique VDEL P1 N1 P2 DELD DDEL P3 N2 P4 DELJ TotalDel TotalN TotalP median
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
257 do
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
258 echo "<tr><td>$Sample</td><td>$unique</td><td>$VDEL</td><td>$P1</td><td>$N1</td><td>$P2</td><td>$DELD</td><td>$DDEL</td><td>$P3</td><td>$N2</td><td>$P4</td><td>$DELJ</td><td>$TotalDel</td><td>$TotalN</td><td>$TotalP</td><td>$median</td></tr>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
259 done < $outputDir/junctionAnalysisProd_median.csv
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
260 echo "</tbody></table>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
261
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
262 echo "<table class='pure-table pure-table-striped' id='junction_table'> <caption>Unproductive median</caption><thead><tr><th>Sample</th><th>count</th><th>V.DEL</th><th>P1</th><th>N1</th><th>P2</th><th>DEL.D</th><th>D.DEL</th><th>P3</th><th>N2</th><th>P4</th><th>DEL.J</th><th>Total.Del</th><th>Total.N</th><th>Total.P</th><th>Median.CDR3</th><thead></tr><tbody>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
263 while IFS=, read Sample unique VDEL P1 N1 P2 DELD DDEL P3 N2 P4 DELJ TotalDel TotalN TotalP median
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
264 do
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
265 echo "<tr><td>$Sample</td><td>$unique</td><td>$VDEL</td><td>$P1</td><td>$N1</td><td>$P2</td><td>$DELD</td><td>$DDEL</td><td>$P3</td><td>$N2</td><td>$P4</td><td>$DELJ</td><td>$TotalDel</td><td>$TotalN</td><td>$TotalP</td><td>$median</td></tr>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
266 done < $outputDir/junctionAnalysisUnProd_median.csv
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
267 echo "</tbody></table>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
268
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
269 echo "</div>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
270 fi
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
271
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
272 echo "<div class='tabbertab' title='Comparison'><table class='pure-table pure-table-striped'><thead><tr><th>ID</th><th>Include</th></tr></thead>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
273 for sample in $samples; do
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
274 echo "<tr><td>$sample</td><td><input type='checkbox' onchange=\"javascript:compareAdd('$sample')\" id='compare_checkbox_$sample'/></td></tr>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
275 done
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
276 echo "</table><div name='comparisonarea'>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
277 echo "<table><tr id='comparison_table_vd'></tr></table>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
278 echo "<table><tr id='comparison_table_vj'></tr></table>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
279 echo "<table><tr id='comparison_table_dj'></tr></table>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
280 echo "</div></div>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
281
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
282 echo "<div class='tabbertab' title='Downloads'>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
283 echo "<table class='pure-table pure-table-striped'>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
284 echo "<thead><tr><th>Description</th><th>Link</th></tr></thead>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
285 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
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
286 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
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
287
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
288 echo "<tr><td>The dataset used to generate the CDR3 length frequency graph</td><td><a href='CDR3LengthPlot.csv'>Download</a></td></tr>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
289
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
290 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
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
291 if [[ "$useD" == "true" ]] ; then
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
292 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
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
293 fi
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
294
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
295 echo "<tr><td>The dataset used to generate the V gene frequency graph</td><td><a href='VFrequency.csv'>Download</a></td></tr>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
296 if [[ "$useD" == "true" ]] ; then
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
297 echo "<tr><td>The dataset used to generate the D gene frequency graph</td><td><a href='DFrequency.csv'>Download</a></td></tr>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
298 fi
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
299 echo "<tr><td>The dataset used to generate the J gene frequency graph</td><td><a href='JFrequency.csv'>Download</a></td></tr>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
300 echo "<tr><td>The dataset used to generate the AA composition graph</td><td><a href='AAComposition.csv'>Download</a></td></tr>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
301
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
302 for sample in $samples; do
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
303 if [[ "$useD" == "true" ]] ; then
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
304 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
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
305 fi
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
306 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
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
307 if [[ "$useD" == "true" ]] ; then
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
308 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
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
309 fi
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
310 done
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
311
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
312 echo "<tr><td>A frequency count of V Gene + J Gene + CDR3</td><td><a href='VJCDR3_count.txt'>Download</a></td></tr>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
313
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
314 echo "</table>" >> $outputFile
9185c3dfc679 Uploaded
davidvanzessen
parents:
diff changeset
315 echo "</div></html>" >> $outputFile