On Wed, Sep 8, 2010 at 4:32 PM, BD <bhakti.dwiv...@gmail.com> wrote: > > 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!
I've been doing exactly this today. Use the svg() device driver to create an svg file. Then edit it with "Inkscape", and open-source graphics layout and design program. For a demo, try: svg("foo.svg") plot(1:10) dev.off() Then open Inkscape and load foo.svg. You should be able to move all the bits of the plot around. It has saved me a ton of time today, since I wanted to move a legend on a ggplot graph to make room for another graphic. In Inkscape I can just select the elements of the legend and drag them around. Inkscape is cross-platform, so works on Windows/Mac/Linux I think (am using the Linux version). Barry ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.