[R] consistent results with heatmap.2

mkcheste at purdue.edu mkcheste at purdue.edu
Sat Sep 12 09:41:33 CEST 2009


Hi,

I am trying to create a heatmap with some specific requirements.  Specifically, 
I need to be able to center the color-scale around 0, and I need to truncate the 
data so that a few extreme values do not cause the rest of the heatmap to appear 
black (on a red/green scale).

After reading through and experimenting with heatmap, heatmap.2, heatmap_plus, 
and heatmap_2, I believe heatmap.2 will provide the best solution - it appears 
to be the only option that will center around 0 without me manually adjusting 
the zlim.  In addition, the color key and distributional information is useful 
(at least for the non-truncated data).

Although I have not used truncated data at this point, I have so far been unable 
to produce consistent dendrograms when I'm not producing the dendrogram as part 
of the heatmap.  What am I missing?


###################################
R version 2.9.0 (2009-04-17)
Copyright (C) 2009 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

# The correct results
> hv <- heatmap.2(x,
	col=col.palette,
	Colv=FALSE,
	key=TRUE,
	Rowv=cc1$order,
	dendrogram="row",
	scale="none",
	tracecol="white",
	cexCol=.5)

> hv$rowInd
 [1] 26 23  5 19 15  4  2 16 21 13 22 12 10 20  7  3 25  1  8 11 24  9 18 14 17
[26]  6

# Attempt 1
> cc = as.dendrogram(hclust(dist(x)))
> hv1 <- heatmap.2(x,
	col=col.palette,
	Rowv=cc,
	Colv=FALSE,
	key=TRUE,
	dendrogram="row",
	scale="none",
	tracecol="white",
	cexCol=.5)
> hv1$rowInd
 [1]  5 23 26  1 25  8 11  9 24 18 14  6 17  2  4 16 21 13 22 12 10 20  3  7 15
[26] 19


# Attempt 2
> cutting <- cutree(hclust(dist(x)),k=8) 
# I counted about 8 divisions in correct clustering
> hv2 <- heatmap.2(x,
	col=col.palette,
	Rowv=cutting,
	Colv=FALSE,
	key=TRUE,
	dendrogram="row",
	scale="none",
	tracecol="white",
	cexCol=.5)
> hv2$rowInd
 [1]  5 23 26  1 25  8 11  9 24 18 14  6 17 15 19  2  4 16 21 13 22  3  7 12 10
[26] 20

# Attempt 3
> correct.order <- hv$rowInd
> hv3 <- heatmap.2(x,
	col=col.palette,
	Rowv=correct.order,
	Colv=FALSE,
	key=TRUE,
	dendrogram="row",
	scale="none",
	tracecol="white",
	cexCol=.5)
> hv3$rowInd
 [1]  5 26 23 15 19 22 13  7  3 12 20 10 16 21  4  2  8 11 25  1 24  9 18 14  6
[26] 17

My understanding is that my first attempt is the same call heatmap.2 makes - so 
there is no reason for the different results.

Note - if there is another way to create the heatmaps meeting my requirements 
using other packages, that works too - I just need something to produce 
consistent results.

Thanks!

Melissa Key
Graduate Student
Department of Statistics
Purdue University




More information about the R-help mailing list