[R] color palette for heatmap?

2011-01-15 Thread BD

Hi,

Does anyone know how I can specify the colors based on the data values in
heatmap?
I have values ranging from -4 to 25 and I want to specify colors as:

-4 = white
0 = white/snow
10 =darkblue
20 = red
25 = dark red

the command line that I am currently using is (which is close to what I want
but not exactly)
col=colorRampPalette(c(-5 = white,5 = white, 10 = darkblue, 20
= red))(4)
can I get a smooth transition in heatmap colors from white to blue to red in
R?

Thanks!


-- 
View this message in context: 
http://r.789695.n4.nabble.com/color-palette-for-heatmap-tp3219238p3219238.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.


[R] How to Ignore NaN values in Rows when using hclust function in making Heatmap??

2010-09-22 Thread BD

I am making heatmaps for a dataset (~ 300*600 matrix) with the following R
script (I am not familiar with R and this is the first time I am using it).


library(gplots)
library(Cairo)
mydata - read.csv(file=data.csv, header=TRUE, sep=,)
rownames(mydata)=mydata$Name
mydata - mydata[,2:297]
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)];
jpeg(scaleRow.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=rev(heat.colors(10)), cexRow=0.08,
cexCol=0.08, trace=none, density.info=none, symkey= FALSE, key=TRUE,
keysize=1.5, margin=c(5,8),RowSideColor=mycolhr, ColSideColor=mycolhc)
dev.off()


My question is, in the dataset I have good number of rows (~ 17) that has
zero value for all the columns defined.  So when I run these two command
lines, 

hr - hclust(as.dist(1-cor(t(mydatascale), method=pearson)),
method=complete)
hc - hclust(as.dist(1-cor(mydatascale, method=spearman)),
method=complete)

I get the error msg:  
error in hclust (as.dist(1-cor(t(mydatascale), method=pearson)), :
NA/NaN/Inf in foreign function call (arg 11).  

It seems to be a problem when NaN exist in all columns for a given row. 
Because, when I delete those rows the script runs fine.   I don't know how
to work my way around this error msg.  I have to include these rows and also
cluster them in the heatmap.  Is there a way to do this?  Please help me!   

In addition to above, in my dataset I have duplicate row names.  I want to
keep it that way but every time I run a script I get a warning message for
not having unique row names.  Is there a way I can ignore this message and
still keep my original row names instead of re-naming them?

Thanks!!
-- 
View this message in context: 
http://r.789695.n4.nabble.com/How-to-Ignore-NaN-values-in-Rows-when-using-hclust-function-in-making-Heatmap-tp2551032p2551032.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.


[R] How to include rows with zeros in all columns when clustering data for heatmap?

2010-09-17 Thread BD

I am making a heatmap.  In the dataset, I have couple of rows with zero value
in all the columns.   When I cluster data using hierarchical clustering, R
gives an error message.  When I get rid of those particular rows, the script
runs smoothly with no problem.  I have to include those rows somehow and
also need to cluster the data.  Is there a way around to do this?

BD
-- 
View this message in context: 
http://r.789695.n4.nabble.com/How-to-include-rows-with-zeros-in-all-columns-when-clustering-data-for-heatmap-tp2544115p2544115.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.


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