[R] saving heatmaps in graphical format that can be edited in graphic editor tool

BD bhakti.dwivedi at gmail.com
Wed Sep 8 17:32:43 CEST 2010


I generated a heatmap in R using the following commands:

> mydata <- read.csv(file="Data.csv", header=TRUE, sep=",")
> mydata <- mydata[rowSums(mydata[,-1]^2) >0, ]
> rownames(mydata)=mydata$Name
> mydata <- mydata[,2:253]
> mydatamatrix <- data.matrix(mydata)
> mydatascale <- t(scale(t(mydatamatrix)))
> hr <- hclust(as.dist(1-cor(t(mydatascale), method="pearson")),
> method="complete")
> hc <- hclust(as.dist(1-cor(mydatascale, method="spearman")),
> method="complete")
> myclhr <- cutree(hr, h=max(hr$height)/2); mycolhr <- sample(rainbow(256));
> myclhc <- cutree(hc, h=max(hc$height)/2); mycolhc <- sample(rainbow(256));
> mycolhr <- mycolhr[as.vector(myclhr)];
> mycolhc <- mycolhc[as.vector(myclhc)];
> library("gplots")
> library("RSvgDevice")
> jpeg("Heatmap.jpg", height=6+2/3, width=6+2/3, units="in", res=1200)
> heatmap.2(mydatamatrix, Rowv=as.dendrogram(hr), Colv=as.dendrogram(hc),
> dendrogram="both", 
   scale="row", col=brewer.pal(3, "YlOrRd"), cexRow=0.01, cexCol=0.01,
trace="none", density.info="none", 
   key=TRUE, keysize=1.5, margin=c(5,8),RowSideColor=mycolhr,
ColSideColor=mycolhc)
> dev.off()


I would like to save the file in a graphical format that can be edited later
in any image editing program (like corel).  is there a way to do this in R? 
Its a lot of data I plotted on heatmap (~ 300*600). The x and y labels are
difficult to read.  I used cexRow = 0.01 and cexCol =0.01 with 1200
resolution to save as jpeg file.  That helped but I can still hardly figure
out the row labels.  I want to be able to read them to interpret the results
and also to edit them with different font/color in corel and may be add
other things that could be relevant to my work.  So, I guess my question
here- is there a way I can make the labels readable in R itself or can I
generate a list of the row and col labels (in the exact order as in figure) 
in a text file separately so I know the order and can try attaching it to
heatmap in corel draw?

any help will be appreciated!  Thanks!

BD
-- 
View this message in context: http://r.789695.n4.nabble.com/saving-heatmaps-in-graphical-format-that-can-be-edited-in-graphic-editor-tool-tp2531512p2531512.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list