hclust_rect {MethylIT.utils} | R Documentation |
Draws rectangles with background colors around the branches of a dendrogram highlighting the corresponding clusters. First the dendrogram is cut at a certain level, then a rectangle is drawn around selected branches.
hclust_rect(tree, k = NULL, which = NULL, x = NULL, h = NULL, border = 2, cluster = NULL, cuts = NULL, color = NULL, ...)
tree |
The same as in |
k, h |
The same as in |
which, x |
The same as in |
border |
The same as in |
cluster |
The same as in |
cuts |
A numeric vector used to manually locate the rectangles around hierarchical clusters in the rigth position. This is tricky since each experimental dataset yield different measurement scale and must be manually adjusted. Settings are cuts = c(xleft, ybottom, xright, ytop). Default is NULL. Use it only if need it. |
color |
Background color to use inside the rectangles around hierarchical clusters. Default is NULL. |
This function is exactly function rect.hclust
with a nice feature added: "to draw the rectangles around hierarchical
clusters with background colors".
### Violent crime rates by US state hca <- hclust(dist(USArrests)) # Basic key RGB colors # rgb(red, green, blue, alpha, names = NULL, maxColorValue = 1) clusters.color = c(rgb(0, 0.7, 0, 0.1), rgb(0, 0, 1, 0.1), rgb(1, 0.2, 0, 0.1)) plot(hca) hclust_rect(hca, h = 150, border = clusters.color, col = clusters.color )