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

2010-09-08 Thread BD

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.

__
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.


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

2010-09-08 Thread Barry Rowlingson
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.


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

2010-09-08 Thread BD

Thanks!  I will try it now.  I am using linux too!

Bhakti

On Wed, Sep 8, 2010 at 11:54 AM, Barry Rowlingson [via R] 
ml-node+2531559-939380251-160...@n4.nabble.comml-node%2b2531559-939380251-160...@n4.nabble.com
 wrote:

 On Wed, Sep 8, 2010 at 4:32 PM, BD [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=2531559i=0
 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

 __
 [hidden email] http://user/SendEmail.jtp?type=nodenode=2531559i=1mailing 
 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.


 --
  View message @
 http://r.789695.n4.nabble.com/saving-heatmaps-in-graphical-format-that-can-be-edited-in-graphic-editor-tool-tp2531512p2531559.html
 To unsubscribe from saving heatmaps in graphical format that can be edited
 in graphic editor tool, click 
 herehttp://r.789695.n4.nabble.com/template/TplServlet.jtp?tpl=unsubscribe_by_codenode=2531512code=Ymhha3RpLmR3aXZlZGlAZ21haWwuY29tfDI1MzE1MTJ8LTE3NjEyNTUyNg==.




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

[[alternative HTML version deleted]]

__
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.