Adjust the order of one dendrogram based on another (using order)
Takes one dendrogram and adjusts its order leaves valeus based on the order of another dendrogram. The values are matached based on the order of the two dendrograms.
This allows for faster entanglement running time, since we can be sure that the leaves order is just as using their labels.
This is a function is FASTER than match_order_by_labels, but it assumes that the order and the labels of the two trees are matching!!
This will allow for a faster calculation of entanglement.
match_order_dendrogram_by_old_order( dend_change, dend_template, dend_change_old_order, check_that_labels_match = FALSE, check_that_leaves_order_match = FALSE )
dend_change |
tree object (dendrogram) |
dend_template |
tree object (dendrogram) |
dend_change_old_order |
a numeric vector with the order of leaves in dend_change (at least before it was changes for some reason). This is the vector based on which we adjust the new values of dend_change. |
check_that_labels_match |
logical (FALSE). If to check that the labels in the two dendrogram match. (if they do not, the function aborts) |
check_that_leaves_order_match |
logical (FALSE). If to check that the order in the two dendrogram match. (if they do not, the function aborts) |
Returns dend_change after adjusting its order values to be like dend_template.
## Not run: dend <- USArrests[1:4, ] %>% dist() %>% hclust() %>% as.dendrogram() order.dendrogram(dend) # c(4L, 3L, 1L, 2L) # Watch this! dend_changed <- dend dend_changed <- rev(dend_changed) expect_false(identical(order.dendrogram(dend_changed), order.dendrogram(dend))) # we keep the order of dend_change, so that the leaves order are synced # with their labels JUST LIKE dend: old_dend_changed_order <- order.dendrogram(dend_changed) # now we change dend_changed leaves order values: order.dendrogram(dend_changed) <- 1:4 # and we can fix them again, based on their old kept leaves order: dend_changed <- match_order_dendrogram_by_old_order( dend_changed, dend, old_dend_changed_order ) expect_identical(order.dendrogram(dend_changed), order.dendrogram(dend)) ## End(Not run)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.