optimTree {compdiagTools} | R Documentation |
optimTree
rearranges an hclust
object such that the sum of pairwise distances between neighboring leafs is minimal.
optimTree(hclust.obj, dist.obj, all = FALSE)
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. |
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)$.
Returns an hclust
object with additional slot sumDist
containing the corresponding sum of distances. If all=TRUE
, returns a list of hclust
objects.
Stefanie Scheid <stefanie.scheid@molgen.mpg.de>
optimTree.plot
,optimTree.dendrogram
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)