[BioC] colors on heatmap

Johannes Freudenberg mai98ftu at studserv.uni-leipzig.de
Fri Sep 12 20:16:26 MEST 2003


Sean,

I'm not quite sure what the standard green/black/red color map is but i'm 
assuming that green means low values, red means high values and black is in the 
middle?

You could define a function which returns colors following that scheme as 
follows:

> my.colors <- function(n = 50, low.col = 0.45, high.col=1, saturation = 1) {
  if (n < 2) stop("n must be greater than 2")
  n1 <- n%/%2
  n2 <- n - n1
  c(hsv(low.col, saturation, seq(1,0,length=n1)),
     hsv(high.col, saturation, seq(0,1,length=n2)))
}

You could then use this function within the heatmap function:

> x <- matrix(runif(1000), 50)
> hv <- heatmap(x, col = my.colors(), main = "Random U[0,1] heatmap")

I hope that helps,
Johannes


Quoting Sean Davis <Sean.Davis at dcb.cit.nih.gov>:

> I would like to use "heatmap" to display my data and wondered if anyone
> had any suggestions on making a color scheme that works to create the
> standard green/black/red color map.
> 
> Thanks
> 
> _______________________________________________
> Bioconductor mailing list
> Bioconductor at stat.math.ethz.ch
> https://www.stat.math.ethz.ch/mailman/listinfo/bioconductor
>



More information about the Bioconductor mailing list