-2

I want to extract the structure values of a heatmap plot but I don't need to plot the heatmap. Is there a way to do that? The function I used is heatmap.

dm<-matrix(1:100,nrow=10)
ht<-heatmap(dm)
v1<-ht$rowInd
v2<-ht$colInd
v3<-ht$rowV
v4<-ht$colV

as you can see from the above, the heatmap was plotted. I am wondering if there is way to extract v1 to v4 without plot ht. Thanks.

Xiaokuan Wei
  • 135
  • 6
  • What "structure" values are you talking about? Please provide a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – MrFlick Jul 01 '14 at 17:16

1 Answers1

1

So you basically just want the dendrogram information. You can just calculate that yourself the same way heatmap() does.

dm<-matrix(1:100,nrow=10)

Rowv <- as.dendrogram(hclust(dist(dm)))
rowInd <- order.dendrogram(Rowv)

Colv <- as.dendrogram(hclust(dist(t(dm))))
colInd <- order.dendrogram(Colv)

Then if you want to plot the heatmape without recalculating the dendrograms, you can run

heatmap(dm, Rowv=Rowv, Colv=Colv)
MrFlick
  • 195,160
  • 17
  • 277
  • 295
  • If you want any sort of dendrogram on the heatmap, that will impose a certain order on the values (the lines of a dendrogram will not cross). If you turn off the dendrograms with `heatmap(dm, Rowv=NA, Colv=NA)`, then they will plot in the original order. – MrFlick Jul 01 '14 at 19:16