ColorDendrogram {sparcl} | R Documentation |
Pass in the output of "hclust" and a class label for each observation. A colored dendrogram will result, with the leaf colors indicating the classes.
ColorDendrogram(hc, y, main = "", branchlength = 0.7, labels = NULL, xlab = NULL, sub="NULL",ylab = "", cex.main = NULL)
hc |
The output of running "hclust" on a nxn dissimilarity matrix |
y |
A vector of n class labels for the observations that were clustered using "hclust". If labels are numeric from 1 to K, then colors will be determine automatically. Otherwise the labels can take the form of colors (e.g. c("red", "red", "orange", "orange")). |
main |
The main title for the dendrogram. |
branchlength |
How long to make the colored part of the branches. Adjustment will be needed for each dissimilarity matrix |
labels |
The labels for the n observations. |
xlab |
X-axis label. |
sub |
Sub-x-axis label. |
ylab |
Y-axis label. |
cex.main |
The amount by which to enlarge the main title for the figure. |
Daniela M. Witten and Robert Tibshirani
Witten and Tibshirani (2009) A framework for feature selection in clustering.
HierarchicalSparseCluster, HierarchicalSparseCluster.permute
# Generate 2-class data set.seed(1) x <- matrix(rnorm(100*20),ncol=20) y <- c(rep(1,50),rep(2,50)) x[y==1,] <- x[y==1,]+2 # Perform hierarchical clustering hc <- hclust(dist(x),method="complete") # Plot ColorDendrogram(hc,y=y,main="My Simulated Data",branchlength=3)