hclust_rect {MethylIT.utils}R Documentation

Draw Rectangles with Background Colors Around Hierarchical Clusters

Description

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.

Usage

hclust_rect(tree, k = NULL, which = NULL, x = NULL, h = NULL,
  border = 2, cluster = NULL, cuts = NULL, color = NULL, ...)

Arguments

tree

The same as in rect.hclust

k, h

The same as in rect.hclust

which, x

The same as in rect.hclust

border

The same as in rect.hclust

cluster

The same as in rect.hclust

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.

Details

This function is exactly function rect.hclust with a nice feature added: "to draw the rectangles around hierarchical clusters with background colors".

Examples

### 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 )

[Package MethylIT.utils version 0.3.1 ]