[R] One question on heatmap

Jim Lemon jim at bitwrit.com.au
Wed Nov 3 10:28:58 CET 2010


On 11/03/2010 02:50 AM, Hua wrote:
> ...
> When I try to make heatmap based on this gene expression value table, I found that, when I set 'scale' to 'column', the heatmap will be always be red. I think this is because, there's very large values in the matrix (gene Actb), while the most are just very small. Thus, the color will be very ugly. I just wonder, how to set the color to make the heatmap look better?  I have tried log-tranformation on the matrix and it's better now. But I do want to know if you have better ways to set the color span manually and make the heatmap look better without any log-transformation?
>
Hi Hua,

It is not all that easy, but can be done. I read in your data as 
"genexp". Notice how I split up the data into three ranges, adding the 
range extremes in color.scale (plotrix) and then removing the extremes.

expcol[genexp$sample2<100]<-
  color.scale(c(0,100,genexp$sample2[genexp$sample2<100]),
  c(1,0.5),c(0,0.5),0)[-(1:2)]
expcol[genexp$sample2>=100&genexp$sample2<1000]<-
 
color.scale(c(100,1000,genexp$sample2[genexp$sample2>=100&genexp$sample2<1000]),
  c(0.5,0.1),c(0.5,0.9),0)[-(1:2)]
expcol[genexp$sample2>1000]<-
  color.scale(c(1000,10000,genexp$sample2[genexp$sample2>=1000]),
  c(0.1,0),c(0.9,1),0)[-(1:2)]
barplot(rep(1,27),col=expcol)
color.legend(0,-0.1,15,-0.05,c(0,100,1000,10000),
  rect.col=c("red","#808000","#1ae600","green"))

Jim



More information about the R-help mailing list