dendextend (version 1.13.2)

untangle_random_search: Untangle - random search

Description

Searches for two untangled dendrogram by randomlly shuflling them and each time checking if their entanglement was improved.

Usage

untangle_random_search(
  dend1,
  dend2,
  R = 100L,
  L = 1,
  leaves_matching_method = c("labels", "order"),
  ...
)

Arguments

dend1

a tree object (of class dendrogram/hclust/phylo).

dend2

a tree object (of class dendrogram/hclust/phylo).

R

numeric (default is 100). The number of shuffles to perform.

L

the distance norm to use for measuring the distance between the two trees. It can be any positive number, often one will want to use 0, 1, 1.5, 2 (see 'details' for more). It is passed to entanglement.

leaves_matching_method

a character scalar passed to entanglement. It can be either "order" or "labels" (default). If using "labels", then we use the labels for matching the leaves order value. And if "order" then we use the old leaves order value for matching the leaves order value.

Using "order" is faster, but "labels" is safer. "order" will assume that the original two trees had their labels and order values MATCHED.

Hence, it is best to make sure that the trees used here have the same labels and the SAME values matched to these values - and then use "order" (for fastest results).

If "order" is used, the function first calls match_order_by_labels in order to make sure that the two trees have their labels synced with their leaves order values.

...

not used

Value

A dendlist with two trees with the best entanglement that was found.

Details

Untangaling two trees is a hard combinatorical problem without a closed form solution. One way for doing it is to run through a random spectrom of options and look for the "best" two trees. This is what this function offers.

See Also

tanglegram, match_order_by_labels, entanglement.

Examples

Run this code
# NOT RUN {
# }
# NOT RUN {
dend1 <- iris[, -5] %>%
  dist() %>%
  hclust("com") %>%
  as.dendrogram()
dend2 <- iris[, -5] %>%
  dist() %>%
  hclust("sin") %>%
  as.dendrogram()
tanglegram(dend1, dend2)

set.seed(65168)
dend12 <- untangle_random_search(dend1, dend2, R = 10)
tanglegram(dend12[[1]], dend12[[2]])
tanglegram(dend12)

entanglement(dend1, dend2, L = 2) # 0.8894
entanglement(dend12[[1]], dend12[[2]], L = 2) # 0.0998
# }

Run the code above in your browser using DataCamp Workspace