Laurent Fernandez Soldevila
2011-Sep-12 11:59 UTC
[R] hclust and cutree: identifying branches as classes
Good afternoon, After cuting a hierarchical tree using cutree(), how to check correspondances between classes and branches? This is what we do: srndpchc <- hclust(dist(srndpc$x[1:1000,1:3]),method="ward") #creation of hierarchical tree plclust(srndpchc,hmin=20000) #visualisation srndpchc20000 = cutree(srndpchc,h=20000) #returns 4 classes table(srndpchc20000 ) srndclass20000 = cbind(srnd@data[1:1000,],srndpchc20000) #assigning classes to objects srndcents20000 <- aggregate(srndclass20000, by=list(srndpchc20000), FUN=median) matplot(1:36,t(srndcents20000[,-c(1,38)])) But how can we make sure that, for example, class 1 is the first branch in the tree plottedĀ by plclust() ? Regards Laurent [[alternative HTML version deleted]]
Peter Langfelder
2011-Sep-12 12:52 UTC
[R] hclust and cutree: identifying branches as classes
On Mon, Sep 12, 2011 at 4:59 AM, Laurent Fernandez Soldevila <l.fernandez4 at yahoo.fr> wrote:> Good afternoon, > > > After cuting a hierarchical tree using cutree(), how to check correspondances between classes and branches? > This is what we do: > > srndpchc <- hclust(dist(srndpc$x[1:1000,1:3]),method="ward") #creation of hierarchical tree > plclust(srndpchc,hmin=20000) #visualisation > > srndpchc20000 = cutree(srndpchc,h=20000) #returns 4 classes > table(srndpchc20000 ) > > srndclass20000 = cbind(srnd at data[1:1000,],srndpchc20000) #assigning classes to objects > srndcents20000 <- aggregate(srndclass20000, by=list(srndpchc20000), FUN=median) > matplot(1:36,t(srndcents20000[,-c(1,38)])) > > > But how can we make sure that, for example, class 1 is the first branch in the tree plotted? by plclust() ?Hi Laurent, in the WGCNA package we have a function called plotDendroAndColors that takes, as the minimum, the hierarchical clustering tree and the clustering, and plots the tree with colors underneath. you would use something along the lines of plotDendroAndColors(srndpchc, srndpchc20000, "Classes", # Some label for the classes, dendroLabels = FALSE # To not plot labels for each leaf ) An example of the plot, with several different tree cuts, can be seen, e.g., at http://www.genetics.ucla.edu/labs/horvath/CoexpressionNetwork/BranchCutting/Example-Dendrogram-10.png HTH, Peter
Possibly Parallel Threads
- Manually modifying an hclust dendrogram to remove singletons
- WGCNA: Combining block-wise dendrograms and modules into a single figure
- [PATCH v2 00/27] x86: PIE support and option to extend KASLR randomization
- [PATCH v2 00/27] x86: PIE support and option to extend KASLR randomization
- [PATCH v3 00/27] x86: PIE support and option to extend KASLR randomization