Debian Codegraph @

man/untangle_random_search.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/untangle.R
3 \name{untangle_random_search}
4 \alias{untangle_random_search}
5 \title{Untangle - random search}
6 \usage{
7 untangle_random_search(
8 dend1,
9 dend2,
10 R = 100L,
11 L = 1,
12 leaves_matching_method = c("labels", "order"),
13 ...
14 )
15 }
16 \arguments{
17 \item{dend1}{a tree object (of class dendrogram/hclust/phylo).}
18
19 \item{dend2}{a tree object (of class dendrogram/hclust/phylo).}
20
21 \item{R}{numeric (default is 100). The number of shuffles to perform.}
22
23 \item{L}{the distance norm to use for measuring the distance between the
24 two trees. It can be any positive number, often one will want to
25 use 0, 1, 1.5, 2 (see 'details' for more).
26 It is passed to \link{entanglement}.}
27
28 \item{leaves_matching_method}{a character scalar passed to \link{entanglement}.
29 It can be either "order" or "labels" (default). If using "labels",
30 then we use the labels for matching the leaves order value.
31 And if "order" then we use the old leaves order value for matching the
32 leaves order value.
33
34 Using "order" is faster, but "labels" is safer. "order" will assume that
35 the original two trees had their labels and order values MATCHED.
36
37 Hence, it is best to make sure that the trees used here have the same labels
38 and the SAME values matched to these values - and then use "order" (for
39 fastest results).
40
41 If "order" is used, the function first calls \link{match_order_by_labels}
42 in order to make sure that the two trees have their labels synced with
43 their leaves order values.}
44
45 \item{...}{not used}
46 }
47 \value{
48 A dendlist with two trees with the best entanglement that was found.
49 }
50 \description{
51 Searches for two untangled dendrogram by randomlly shuflling them and each
52 time checking if their entanglement was improved.
53 }
54 \details{
55 Untangaling two trees is a hard combinatorical problem without a closed
56 form solution. One way for doing it is to run through a random spectrom
57 of options and look for the "best" two trees. This is what this function
58 offers.
59 }
60 \examples{
61
62 \dontrun{
63 dend1 <- iris[, -5] \%>\%
64 dist() \%>\%
65 hclust("com") \%>\%
66 as.dendrogram()
67 dend2 <- iris[, -5] \%>\%
68 dist() \%>\%
69 hclust("sin") \%>\%
70 as.dendrogram()
71 tanglegram(dend1, dend2)
72
73 set.seed(65168)
74 dend12 <- untangle_random_search(dend1, dend2, R = 10)
75 tanglegram(dend12[[1]], dend12[[2]])
76 tanglegram(dend12)
77
78 entanglement(dend1, dend2, L = 2) # 0.8894
79 entanglement(dend12[[1]], dend12[[2]], L = 2) # 0.0998
80 }
81 }
82 \seealso{
83 \link{tanglegram}, \link{match_order_by_labels},
84 \link{entanglement}.
85 }