Debian Codegraph @

man/all_couple_rotations_at_k.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/untangle.R
3 \name{all_couple_rotations_at_k}
4 \alias{all_couple_rotations_at_k}
5 \title{Rotate tree branches for k}
6 \usage{
7 all_couple_rotations_at_k(dend, k, dend_heights_per_k, ...)
8 }
9 \arguments{
10 \item{dend}{a dendrogram object}
11
12 \item{k}{integer scalar with the number of clusters the tree should be cut into.}
13
14 \item{dend_heights_per_k}{a named vector that resulted from running
15 \link{heights_per_k.dendrogram}. When running the function many times,
16 supplying this object will help improve the running time if using the
17 \link{cutree.dendrogram} method..}
18
19 \item{...}{not used}
20 }
21 \value{
22 A list with dendrogram objects with all the possible rotations
23 for k clusters (beyond the k-1 clusters!).
24 }
25 \description{
26 Given a tree and a k number of clusters, the tree is rotated so that the
27 extra clusters added from k-1 to k clusters are flipped.
28
29 This is useful for finding good trees for a \link{tanglegram}.
30 }
31 \examples{
32
33 \dontrun{
34 dend1 <- USArrests[1:5, ] \%>\%
35 dist() \%>\%
36 hclust() \%>\%
37 as.dendrogram()
38 dend2 <- all_couple_rotations_at_k(dend1, k = 2)[[2]]
39 tanglegram(dend1, dend2)
40 entanglement(dend1, dend2, L = 2) # 0.5
41
42 dend2 <- all_couple_rotations_at_k(dend1, k = 3)[[2]]
43 tanglegram(dend1, dend2)
44 entanglement(dend1, dend2, L = 2) # 0.4
45
46 dend2 <- all_couple_rotations_at_k(dend1, k = 4)[[2]]
47 tanglegram(dend1, dend2)
48 entanglement(dend1, dend2, L = 2) # 0.05
49 }
50 }
51 \seealso{
52 \link{tanglegram}, \link{match_order_by_labels},
53 \link{entanglement}, \link{flip_leaves}.
54 }