This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to compute scale bar of the dendrogram for heatmap using heatmap2 ?

Hi,

I have created a heatmap for the genes expression across different samples. I need to compute the scale bar of the dendrogram for my heatmaps which shows how the hierarchically clustered samples are similar to each other.

Does anybody knows how can I do that using heatmap2 function in R?

r

1 answer

To my knowledge I don't think you can do this AND have the dendrogram scale bar show up in the same figure as the heatmap--at least using the heatmap.2 function. However, you can plot just the row and/or column dendrogram and it will show you the scale bar on that figure. See R code below:

M <- matrix(sample.int(20, size=100, replace=TRUE), nrow=10, byrow=TRUE)
figdata <- heatmap.2(M)
names(figdata)
plot(figdata$colDendrogram)
plot(figdata$rowDendrogram)

Or, you can see if the aheatmap() function from the NMF package (http://cran.r-project.org/web/packages/NMF/NMF.pdf) does what you need. I just found this function, so haven't had a chance to experiment with it yet.

Log in to answer this question.