[R] extracting groups from hclust() for a very large matrix

Christopher R. Dolanc crdolanc at ucdavis.edu
Fri Oct 12 00:50:56 CEST 2012


I'm having trouble figuring out how to see resulting groups (clusters) 
from my hclust() output. I have a very large matrix of 4371 plots and 29 
species, so simply looking at the graph is impossible. There must be a 
way to 'print' the results to a table that shows which plots were in 
what group, correct?

I've attached the matrix I'm working with (the whole thing since the 
point is its large size). I've been able to run the following code to 
get the groups I need:

 > VTM.Dist<- vegdist(VTM.Matrix)
 > VTM.HClust<- hclust(VTM.Dist, method="ward")
 > plot(VTM.HClust, hang=-1)

It takes a while, but it does run. Then, I can extract 8 groups, which 
I'd like to experiment with, but is about how many I'd like:

rect.hclust(VTM.HClust, 8)
 > VTM.8groups<- cutree(VTM.HClust, 8)

But, instead of listing the plots by name, it only tells me *how many* 
plots are in the eight groups:

 > table(VTM.8groups)
    1    2    3    4    5    6    7    8
  137  173  239  356  709  585  908 1264

The vegemite() function also doesn't work for this reason - I have way 
too many plots so they number in the thousands, which vegemite doesn't like.

 > vegemite(VTM.Matrix, VTM.HClust)
Error in vegemite(VTM.Matrix, VTM.HClust) :
   Cowardly refusing to use longer than 1 char symbols:
Use scale

Does anybody know how I can get a simple list of plots in each category? 
I would think this would be something like a summary command. Perhaps a 
different clustering method?

Chris Dolanc

Christopher R. Dolanc
Post-doctoral Researcher
University of Montana and UC-Davis

More information about the R-help mailing list