[R] question about function heatmap

Chris Campbell clc559 at gmail.com
Thu Nov 19 00:05:48 CET 2009


On Tue, Nov 17, 2009 at 17:03, Waverley @ Palo Alto
<waverley.paloalto at gmail.com> wrote:
> Hi,
>
> I am using the function heatmap(stats) to draw a microarray heatmap,
> columns are samples and rows are gene features.
>
> I did a 2D clustering during the heatmap drawing.  The features and
> samples indeed cluster into several blocks both vertically and
> horizontally.
>
> I can get the index of re-ordered rows and columns after the heatmap
> drawing by typing the the return variable of the heatmap function.
> However, I cannot  separate these index by the the dendro tree. All
> the indexes labeled at the bottom and right of the plot all jammed
> together.  I cannot by looking at the plot to find where the borders
> are.
>
> Can someone help?  Essentially I want the dendro tree of the genes
> which are grouped after the clustering so that, e.g., I want to check
> whether genes clustered together are in the same pathway etc.
>
> Thanks in advance.
>
> --
> Waverley @ Palo Alto
>
> ______________________________________________
> R-help at 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.
>

The heatmap function does not return the full clustering information.
If you look in the help, you'll see that the rows and columns are
reordered by:
dd <- as.dendrogram(hclustfun(distfun(X)))
so you need to run your own clustering separately:

x <- matrix(rnorm(100),ncol=10,dimnames=list(paste("gene",1:10),paste("sample",1:10)))
x.hclust <- hclust(dist(x))
plot(as.dendrogram(x.hclust))
x.ident <- rect.hclust(x.hclust,k=2)
x.ident

To get the sample clusters, transpose the matrix for the distance calculation.




More information about the R-help mailing list