reorder.hclust: Reorder a Hierarchical Clustering Tree

Description Usage Arguments Details Value Note Author(s) See Also Examples

Description

Function takes a hierarchical clustering tree from hclust and a vector of values and reorders the clustering tree in the order of the supplied vector, maintaining the constraints on the tree. This is a method of generic function reorder and an alternative to reordering a "dendrogram" object with reorder.dendrogram

Usage

1
2
3
4
5
6
7
## S3 method for class 'hclust'
reorder(x, wts, 
   agglo.FUN = c("mean", "min", "max", "sum", "uwmean"), ...)
## S3 method for class 'hclust'
rev(x)
## S3 method for class 'hclust'
scores(x, display = "internal", ...)

Arguments

x

hierarchical clustering from hclust.

wts

numeric vector for reordering.

agglo.FUN

a function for weights agglomeration, see below.

display

return "internal" nodes or "terminal" nodes (also called "leaves").

...

additional arguments (ignored).

Details

Dendrograms can be ordered in many ways. The reorder function reorders an hclust tree and provides an alternative to reorder.dendrogram which can reorder a dendrogram. The current function will also work differently when the agglo.FUN is "mean": the reorder.dendrogram will always take the direct mean of member groups ignoring their sizes, but this function will used weighted.mean weighted by group sizes, so that the group mean is always the mean of member leaves (terminal nodes). If you want to ignore group sizes, you can use unweighted mean with "uwmean".

The function accepts only a limited list of agglo.FUN functions for assessing the value of wts for groups. The ordering is always ascending, but the order of leaves can be reversed with rev.

Function scores finds the coordinates of nodes as a two-column matrix. For terminal nodes (leaves) this the value at which the item is merged to the tree, and the labels can still hang below this level (see plot.hclust).

Value

Reordered hclust result object with added item value that gives the value of the statistic at each merge level.

Note

These functions should really be in base R.

Author(s)

Jari Oksanen

See Also

hclust for getting clustering trees, as.hclust.spantree to change a vegan minimum spanning tree to an hclust object, and dendrogram and reorder.dendrogram for an alternative implementation.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## reorder by water content of soil
data(mite, mite.env)
hc <- hclust(vegdist(wisconsin(sqrt(mite))))
ohc <- with(mite.env, reorder(hc, WatrCont))
plot(hc)
plot(ohc)

## label leaves by the observed value, and each branching point
## (internal node) by the cluster mean
with(mite.env, plot(ohc, labels=round(WatrCont), cex=0.7))
ordilabel(scores(ohc), label=round(ohc$value), cex=0.7)

## Slightly different from reordered 'dendrogram' which ignores group
## sizes in assessing means.
den <- as.dendrogram(hc)
den <- with(mite.env, reorder(den, WatrCont, agglo.FUN = mean))
plot(den)

Example output

Loading required package: permute
Loading required package: lattice
This is vegan 2.4-3

vegan documentation built on May 2, 2019, 5:51 p.m.