diff shm_csr.r @ 43:77a7ac76c7b9 draft

Uploaded
author davidvanzessen
date Tue, 11 Apr 2017 08:02:17 -0400
parents 1cf60ae234b4
children aa8d37bd1930
line wrap: on
line diff
--- a/shm_csr.r	Tue Mar 28 08:25:36 2017 -0400
+++ b/shm_csr.r	Tue Apr 11 08:02:17 2017 -0400
@@ -124,6 +124,8 @@
 	regions = c("CDR2", "FR3")
 }
 
+pdfplots = list() #save() this later to create the pdf plots in another script (maybe avoids the "address (nil), cause memory not mapped")
+
 sum_by_row = function(x, columns) { sum(as.numeric(x[columns]), na.rm=T) }
 
 print("aggregating data into new columns")
@@ -308,7 +310,7 @@
 			print(p)
 			dev.off()
 			
-			ggsave(paste("transitions_stacked_", name, ".pdf", sep=""))
+			pdfplots[[paste("transitions_stacked_", name, ".pdf", sep="")]] <<- p
 			
 			png(filename=paste("transitions_heatmap_", name, ".png", sep=""))
 			p = ggplot(transition2, aes(factor(reorder(variable, -order.y)), factor(reorder(id, -order.x)))) + geom_tile(aes(fill = value)) + scale_fill_gradient(low="white", high="steelblue") #heatmap
@@ -316,7 +318,7 @@
 			print(p)
 			dev.off()
 			
-			ggsave(paste("transitions_heatmap_", name, ".pdf", sep=""))
+			pdfplots[[paste("transitions_heatmap_", name, ".pdf", sep="")]] <<- p
 		} else {
 			#print("No data to plot")
 		}
@@ -400,7 +402,7 @@
 	print(pc)
 	dev.off()
 	
-	ggsave("IGA.pdf", pc)
+	pdfplots[["IGA.pdf"]] <- pc	
 }
 
 print("Plotting IGG piechart")
@@ -423,7 +425,7 @@
 	print(pc)
 	dev.off()
 	
-	ggsave("IGG.pdf", pc)
+	pdfplots[["IGG.pdf"]] <- pc	
 }
 
 print("Plotting scatterplot")
@@ -445,7 +447,7 @@
 print(p)
 dev.off()
 
-ggsave("scatter.pdf", p)
+pdfplots[["scatter.pdf"]] <- p
 
 write.table(dat[,c("Sequence.ID", "best_match", "VRegionMutations", "VRegionNucleotides", "percentage_mutations")], "scatter.txt", sep="\t",quote=F,row.names=F,col.names=T)
 
@@ -471,7 +473,9 @@
 print(p)
 dev.off()
 
-ggsave("frequency_ranges.pdf", p)
+pdfplots[["frequency_ranges.pdf"]] <- p
+
+save(pdfplots, file="pdfplots.RData")
 
 frequency_bins_data_by_class = frequency_bins_data