changeset 4:10cfa5e9186e draft

Uploaded
author davidvanzessen
date Mon, 14 Oct 2013 08:12:41 -0400
parents d27d745d0556
children 021d293121bb
files RScript.r r_wrapper.sh
diffstat 2 files changed, 20 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/RScript.r	Mon Oct 14 07:20:38 2013 -0400
+++ b/RScript.r	Mon Oct 14 08:12:41 2013 -0400
@@ -108,13 +108,17 @@
 
 
 plotVD <- function(dat){
-	ggplot() + 
+	img = ggplot() + 
 	geom_tile(data=dat, aes(x=factor(Top.D.Gene), y=factor(Top.V.Gene), fill=log)) + 
 	theme(axis.text.x = element_text(angle = 90, hjust = 1)) + 
 	scale_fill_gradient(low="gold", high="blue", na.value="white") + 
 	ggtitle(unique(dat$Sample)) + 
 	xlab("D genes") + 
 	ylab("V Genes")
+	
+	png(paste("HeatmapVD_", unique(dat[3])[1,1] , ".png", sep=""), width=150+(15*length(Dchain$v.name)), height=100+(15*length(Vchain$v.name)))
+	print(img)
+	dev.off()
 }
 
 
@@ -126,19 +130,23 @@
 completeVD$log = log(completeVD$Length)
 #completeVD$log[is.na(completeVD$log)] = 0
 l = split(completeVD, f=completeVD[,"Sample"])
-png("HeatmapVD%d.png", width=150+(15*length(Dchain$v.name)), height=100+(15*length(Vchain$v.name)))
+
 lapply(l, FUN=plotVD)
-dev.off()
+
 
 
 plotVJ <- function(dat){
-	ggplot() + 
+	img = ggplot() + 
 	geom_tile(data=dat, aes(x=factor(Top.J.Gene), y=factor(Top.V.Gene), fill=log)) + 
 	theme(axis.text.x = element_text(angle = 90, hjust = 1)) + 
 	scale_fill_gradient(low="gold", high="blue", na.value="white") + 
 	ggtitle(unique(dat$Sample)) + 
 	xlab("J genes") + 
 	ylab("V Genes")
+	
+	png(paste("HeatmapVJ_", unique(dat[3])[1,1] , ".png", sep=""), width=150+(15*length(Jchain$v.name)), height=100+(15*length(Vchain$v.name)))
+	print(img)
+	dev.off()
 }
 
 VandJCount = ddply(PRODF, c("Top.V.Gene", "Top.J.Gene", "Sample"), function(x) summary(x$VDJCDR3))
@@ -149,18 +157,20 @@
 completeVJ$log = log(completeVJ$Length)
 #completeVJ$log[is.na(completeVJ$log)] = 0
 l = split(completeVJ, f=completeVJ[,"Sample"])
-png("HeatmapVJ%d.png", width=150+(15*length(Jchain$v.name)), height=100+(15*length(Vchain$v.name)))
 lapply(l, FUN=plotVJ)
-dev.off()
 
 plotDJ <- function(dat){
-	ggplot() + 
+	img = ggplot() + 
 	geom_tile(data=dat, aes(x=factor(Top.J.Gene), y=factor(Top.D.Gene), fill=log)) + 
 	theme(axis.text.x = element_text(angle = 90, hjust = 1)) + 
 	scale_fill_gradient(low="gold", high="blue", na.value="white") + 
 	ggtitle(unique(dat$Sample)) + 
 	xlab("J genes") + 
 	ylab("D Genes")
+	
+	png(paste("HeatmapDJ_", unique(dat[3])[1,1] , ".png", sep=""), width=150+(15*length(Jchain$v.name)), height=100+(15*length(Dchain$v.name)))
+	print(img)
+	dev.off()
 }
 
 DandJCount = ddply(PRODF, c("Top.D.Gene", "Top.J.Gene", "Sample"), function(x) summary(x$VDJCDR3))
@@ -171,9 +181,7 @@
 completeDJ$log = log(completeDJ$Length)
 #completeDJ$log[is.na(completeDJ$log)] = 0
 l = split(completeDJ, f=completeDJ[,"Sample"])
-png("HeatmapDJ%d.png", width=150+(15*length(Jchain$v.name)), height=100+(15*length(Dchain$v.name)))
 lapply(l, FUN=plotDJ)
-dev.off()
 
 
 sampleFile <- file("samples.txt")
--- a/r_wrapper.sh	Mon Oct 14 07:20:38 2013 -0400
+++ b/r_wrapper.sh	Mon Oct 14 08:12:41 2013 -0400
@@ -21,11 +21,11 @@
 	echo "<tr><td colspan='3' height='100'></td>" >> $outputFile
 	echo "<tr><td colspan='3'><h1>$sample</h1></td></tr>" >> $outputFile
 	echo "<tr><td><h2>V-D Heatmap:</h2></td><td><h2>V-J Heatmap:</h2></td><td><h2>D-J Heatmap:</h2></td></tr><tr>" >> $outputFile
-	mv "$outputDir/HeatmapVD$count.png" "$outputDir/VD_$sample.png"
+	mv "$outputDir/HeatmapVD_$sample.png" "$outputDir/VD_$sample.png"
 	echo "<td><img src='VD_$sample.png'/></td>" >> $outputFile
-	mv "$outputDir/HeatmapVJ$count.png" "$outputDir/VJ_$sample.png"
+	mv "$outputDir/HeatmapVJ_$sample.png" "$outputDir/VJ_$sample.png"
 	echo "<td><img src='VJ_$sample.png'/></td>" >> $outputFile
-	mv "$outputDir/HeatmapDJ$count.png" "$outputDir/DJ_$sample.png"
+	mv "$outputDir/HeatmapDJ_$sample.png" "$outputDir/DJ_$sample.png"
 	echo "<td><img src='DJ_$sample.png'/></td></tr>" >> $outputFile
 	count=$((count+1))
 done