reorder                package:stats                R Documentation

Reorder a dendrogram

Description:

     There are many different orderings of a dendrogram that are
     consistent with the structure imposed.  This function takes a
     dendrogram and a vector of values and reorders the dendrogram in
     the order of the supplied vector, maintaining the constraints on
     the dendrogram.

Usage:

     reorder(x, ...)

     ## S3 method for class 'dendrogram':
     reorder(x, wts, ...)

Arguments:

       x: the object to be reordered

     wts: numeric weights (arbitrary values) for reordering.

     ...: additional arguments

Details:

     Using the weights 'wts', the leaves of the dendrogram are
     reordered so as to be in an order as consistent as possible with
     the weights.  Afterward, at each node, the branches are ordered in
     increasing weights (where the weight of a branch is defined as the
     sum of the weights of its sub branches).

Value:

     From 'reorder.dendrogram' a dendrogram, where each node has a
     further attribute 'value' with its corresponding weight.

Author(s):

     R. Gentleman

See Also:

     'heatmap', 'cophenetic'

Examples:

       set.seed(123)
       x <- rnorm(10)
       hc <- hclust(dist(x))
       dd <- as.dendrogram(hc)
       dd.reorder <- reorder(dd, 10:1)

       op <- par(mfcol = 1:2)
       plot(dd, main = "random dendrogram `dd'")
       plot(dd.reorder, main = "reorder(dd, 10:1)")
       par(op)

