Question

I have the following code that perform hiearchical clustering and plot them in heatmap.

set.seed(538)
# generate data
y <- matrix(rnorm(50), 10, 5, dimnames=list(paste("g", 1:10, sep=""),
paste("t", 1:5, sep="")))
# the actual data is much larger that the above

# perform hiearchical clustering and plot heatmap
test <- heatmap.2(y)

What I want to do is to print the cluster member from each hierarchy of in the plot. I'm not sure what's the good way to do it.

I tried this:

cutree(as.hclust(test$rowDendrogram), 1:dim(y)[1])

But having problem in interpreting the result. What's the meaning of each value in the matrix? For example g9-9=8 . What does 8 mean here?

    1 2 3 4 5 6 7 8 9 10
g1  1 1 1 1 1 1 1 1 1  1
g2  1 2 2 2 2 2 2 2 2  2
g3  1 2 2 3 3 3 3 3 3  3
g4  1 2 2 2 2 2 2 2 2  4
g5  1 1 1 1 1 1 1 4 4  5
g6  1 2 3 4 4 4 4 5 5  6
g7  1 2 2 2 2 5 5 6 6  7
g8  1 2 3 4 5 6 6 7 7  8
g9  1 2 3 4 4 4 7 8 8  9
g10 1 2 3 4 5 6 6 7 9 10

Your expert advice will be greatly appreciated.

Was it helpful?

Solution

Column j tells you how your gs should be grouped if you wanted exactly j groups.

Columns 1 and 10 are not very useful, but maybe column 2 is a good example. It is telling you that if you wanted exactly two groups then they would be:

group1: {g1, g5}
group2: {g2, g3, g4, g6, g7, g8, g9, g10}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top