I am trying to display heatmaps next to each other in R, but it fails. What I am doing is:
library(gplots)
xPos11<-read.table("dataset1.txt")
xPos2<-read.table("dataset2.txt")
xPos3<-read.table("dataset3.txt")
xPos4<-read.table("dataset4.txt")
colorMin = 0
colorMax = 5
pdf("Region3.heatmap.pdf")
par(mfrow=c(4,4))
heatmap.2(as.matrix( xPos1 ), Rowv=FALSE, Colv=FALSE, dendrogram="none", key=TRUE, density.info="none", trace="none", breaks=seq(colorMin, colorMax, length.out=101))
heatmap.2(as.matrix( xPos2 ), Rowv=FALSE, Colv=FALSE, dendrogram="none", key=TRUE, density.info="none", trace="none", breaks=seq(colorMin, colorMax, length.out=101))
heatmap.2(as.matrix( xPos3), Rowv=FALSE, Colv=FALSE, dendrogram="none", key=TRUE, density.info="none", trace="none", breaks=seq(colorMin, colorMax, length.out=101))
heatmap.2(as.matrix( xPos4 ), Rowv=FALSE, Colv=FALSE, dendrogram="none", key=TRUE, density.info="none", trace="none", breaks=seq(colorMin, colorMax, length.out=101))
dev.off()
Now what is happening is instead of getting one pdf page with all 4 heatmaps next to echother I am getting 4 pages of the pdf with one heatmap on each of them.
Could someone help me in tweaking the code to get the desired structure panel of heatmaps in R.
Thank you