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