diff RScript.r @ 4:10cfa5e9186e draft

Uploaded
author davidvanzessen
date Mon, 14 Oct 2013 08:12:41 -0400
parents d27d745d0556
children 021d293121bb
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")