changeset 48:d08dfc8d5225 draft

Uploaded
author davidvanzessen
date Wed, 27 Jan 2016 10:36:35 -0500
parents d97e1421aa86
children 188712b1735f
files report_clonality/RScript.r report_clonality/r_wrapper.sh
diffstat 2 files changed, 27 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/report_clonality/RScript.r	Wed Jan 27 10:25:43 2016 -0500
+++ b/report_clonality/RScript.r	Wed Jan 27 10:36:35 2016 -0500
@@ -62,7 +62,9 @@
 #filter uniques
 inputdata.removed = inputdata[NULL,]
 
-if(filter_uniques == "yes" && c("CDR1.Seq", "CDR2.Seq", "CDR3.Seq", "FR1.IMGT", "FR2.IMGT", "FR3.IMGT") %in% names(inputdata)){
+filter_uniques = filter_uniques == "yes" && c("CDR1.Seq", "CDR2.Seq", "CDR3.Seq", "FR1.IMGT", "FR2.IMGT", "FR3.IMGT") %in% names(inputdata)
+
+if(filter_uniques){
 	
 	clmns = names(inputdata)
 	
@@ -177,12 +179,17 @@
 sample_productive_count$perc_unprod = round(sample_productive_count$Unproductive / sample_productive_count$All * 100)
 sample_productive_count$perc_unprod_un = round(sample_productive_count$Unproductive_unique / sample_productive_count$All * 100)
 
-inputdata.removed.s = data.table(inputdata.removed)[, list(UniqueRemoved=.N), by=c("Sample")]
+
+if(filter_uniques){
+	inputdata.removed.s = data.table(inputdata.removed)[, list(UniqueRemoved=.N), by=c("Sample")]
+
+	sample_productive_count = merge(sample_productive_count, inputdata.removed.s, by="Sample")
 
-sample_productive_count = merge(sample_productive_count, inputdata.removed.s, by="Sample")
-
-sample_productive_count$perc_rem = round(sample_productive_count$UniqueRemoved / sample_productive_count$All * 100)
-
+	sample_productive_count$perc_rem = round(sample_productive_count$UniqueRemoved / sample_productive_count$All * 100)
+} else {
+	sample_productive_count$UniqueRemoved = 0
+	sample_productive_count$perc_rem = 0
+}
 
 sample_replicate_productive_count = inputdata.dt[, list(All=.N, 
                                                         Productive = nrow(.SD[.SD$Functionality == "productive" | .SD$Functionality == "productive (see comment)",]), 
@@ -201,12 +208,17 @@
 sample_replicate_productive_count$perc_unprod = round(sample_replicate_productive_count$Unproductive / sample_replicate_productive_count$All * 100)
 sample_replicate_productive_count$perc_unprod_un = round(sample_replicate_productive_count$Unproductive_unique / sample_replicate_productive_count$All * 100)
 
-inputdata.removed.sr = data.table(inputdata.removed)[, list(UniqueRemoved=.N), by=c("samples_replicates")]
+
+if(filter_uniques){
+	inputdata.removed.sr = data.table(inputdata.removed)[, list(UniqueRemoved=.N), by=c("samples_replicates")]
+
+	sample_replicate_productive_count = merge(sample_replicate_productive_count, inputdata.removed.sr, by="samples_replicates")
 
-sample_replicate_productive_count = merge(sample_replicate_productive_count, inputdata.removed.sr, by="samples_replicates")
-
-sample_replicate_productive_count$perc_rem = round(sample_replicate_productive_count$UniqueRemoved / sample_productive_count$All * 100)
-
+	sample_replicate_productive_count$perc_rem = round(sample_replicate_productive_count$UniqueRemoved / sample_productive_count$All * 100)
+} else {
+	sample_replicate_productive_count$UniqueRemoved = 0
+	sample_replicate_productive_count$perc_rem = 0
+}
 
 setnames(sample_replicate_productive_count, colnames(sample_productive_count))
 
--- a/report_clonality/r_wrapper.sh	Wed Jan 27 10:25:43 2016 -0500
+++ b/report_clonality/r_wrapper.sh	Wed Jan 27 10:36:35 2016 -0500
@@ -35,12 +35,14 @@
 
 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
 echo "<table border = 1>" >> $2
-echo "<thead><tr><th>Sample/Replicate</th><th>All</th><th>Removed</th><th>Productive</th><th>Unique Productive</th><th>Unproductive</th><th>Unique Unproductive</th></tr></thead>" >> $2
+echo "<thead><tr><th>Sample/Replicate</th><th>Input</th><th>Removed</th><th>All</th><th>Productive</th><th>Unique Productive</th><th>Unproductive</th><th>Unique Unproductive</th></tr></thead>" >> $2
 while IFS=, read sample all productive perc_prod productive_unique perc_prod_un unproductive perc_unprod unproductive_unique perc_unprod_un removed perc_rem
 	do
 		echo "<tr><td>$sample</td>" >> $2
+		
+		echo "<td>$((all+removed))</td>" >> $2
+		echo "<td>${removed} (${perc_rem}%)</td>" >> $2
 		echo "<td>$all</td>" >> $2
-		echo "<td>${removed} (${perc_rem}%)</td>" >> $2
 		echo "<td>$productive (${perc_prod}%)</td>" >> $2
 		echo "<td>$productive_unique (${perc_prod_un}%)</td>" >> $2
 		echo "<td>$unproductive (${perc_unprod}%)</td>" >> $2