| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/entanglement.R |
| 3 |
\name{match_order_dendrogram_by_old_order} |
| 4 |
\alias{match_order_dendrogram_by_old_order} |
| 5 |
\title{Adjust the order of one dendrogram based on another (using order)} |
| 6 |
\usage{ |
| 7 |
match_order_dendrogram_by_old_order( |
| 8 |
dend_change, |
| 9 |
dend_template, |
| 10 |
dend_change_old_order, |
| 11 |
check_that_labels_match = FALSE, |
| 12 |
check_that_leaves_order_match = FALSE |
| 13 |
) |
| 14 |
} |
| 15 |
\arguments{ |
| 16 |
\item{dend_change}{tree object (dendrogram)} |
| 17 |
|
| 18 |
\item{dend_template}{tree object (dendrogram)} |
| 19 |
|
| 20 |
\item{dend_change_old_order}{a numeric vector with the order of leaves in |
| 21 |
dend_change (at least before it was changes for some reason). |
| 22 |
This is the vector based on which we adjust the new values of dend_change.} |
| 23 |
|
| 24 |
\item{check_that_labels_match}{logical (FALSE). If to check that the labels |
| 25 |
in the two dendrogram match. (if they do not, the function aborts)} |
| 26 |
|
| 27 |
\item{check_that_leaves_order_match}{logical (FALSE). If to check that |
| 28 |
the order in the two dendrogram match. (if they do not, the function aborts)} |
| 29 |
} |
| 30 |
\value{ |
| 31 |
Returns dend_change after adjusting its order values to |
| 32 |
be like dend_template. |
| 33 |
} |
| 34 |
\description{ |
| 35 |
Takes one dendrogram and adjusts its order leaves valeus based on the order |
| 36 |
of another dendrogram. The values are matached based on the order of the |
| 37 |
two dendrograms. |
| 38 |
|
| 39 |
This allows for faster \link{entanglement} running time, since we can be |
| 40 |
sure that the leaves order is just as using their labels. |
| 41 |
|
| 42 |
This is a function is FASTER than \link{match_order_by_labels}, but it |
| 43 |
assumes that the order and the labels of the two trees are matching!! |
| 44 |
|
| 45 |
This will allow for a faster calculation of \link{entanglement}. |
| 46 |
} |
| 47 |
\examples{ |
| 48 |
\dontrun{ |
| 49 |
|
| 50 |
dend <- USArrests[1:4, ] \%>\% |
| 51 |
dist() \%>\% |
| 52 |
hclust() \%>\% |
| 53 |
as.dendrogram() |
| 54 |
order.dendrogram(dend) # c(4L, 3L, 1L, 2L) |
| 55 |
|
| 56 |
|
| 57 |
# Watch this! |
| 58 |
dend_changed <- dend |
| 59 |
dend_changed <- rev(dend_changed) |
| 60 |
expect_false(identical(order.dendrogram(dend_changed), order.dendrogram(dend))) |
| 61 |
# we keep the order of dend_change, so that the leaves order are synced |
| 62 |
# with their labels JUST LIKE dend: |
| 63 |
old_dend_changed_order <- order.dendrogram(dend_changed) |
| 64 |
# now we change dend_changed leaves order values: |
| 65 |
order.dendrogram(dend_changed) <- 1:4 |
| 66 |
# and we can fix them again, based on their old kept leaves order: |
| 67 |
dend_changed <- match_order_dendrogram_by_old_order( |
| 68 |
dend_changed, dend, |
| 69 |
old_dend_changed_order |
| 70 |
) |
| 71 |
expect_identical(order.dendrogram(dend_changed), order.dendrogram(dend)) |
| 72 |
} |
| 73 |
} |
| 74 |
\seealso{ |
| 75 |
\link{entanglement} , \link{tanglegram}, |
| 76 |
\link{match_order_by_labels} |
| 77 |
} |