optimTree {compdiagTools}R Documentation

Optimal reordering of hclust objects

Description

optimTree rearranges an hclust object such that the sum of pairwise distances between neighboring leafs is minimal.

Usage

optimTree(hclust.obj, dist.obj, all = FALSE)

Arguments

hclust.obj An object of class hclust.
dist.obj The distance object from which hclust.obj was generated.
all Logical value. If FALSE, only the first dendrogram with minimal sum of distances is returned. If TRUE, a list containing all possible dendrogram permutations is returned.

Details

The function completely enumerates all possible dendrogram rearrangements of the given hclust object. Note, that computation time increases with sample size. With n samples, the number of possible dendrograms is $2^(n-2)$.

Value

Returns an hclust object with additional slot sumDist containing the corresponding sum of distances. If all=TRUE, returns a list of hclust objects.

Author(s)

Stefanie Scheid <stefanie.scheid@molgen.mpg.de>

References

See Also

optimTree.plot,optimTree.dendrogram

Examples

a <- rbind(rep(0,4),
           c(1,rep(0,3)),
           c(5,2,0,0),
           c(3,9,7,0))

a <- as.dist(a)

hc.old <- hclust(a,method="average")
hc.new <- optimTree(hc.old,a)

plot(hc.old)
plot(hc.new)
print(hc.new$sumDist)

[Package compdiagTools version 1.5.3 Index]