| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/attr_access.R |
| 3 |
\name{get_leaves_branches_col} |
| 4 |
\alias{get_leaves_branches_col} |
| 5 |
\title{Get the colors of the branches of a dendrogram's leaves} |
| 6 |
\usage{ |
| 7 |
get_leaves_branches_col(dend, ...) |
| 8 |
} |
| 9 |
\arguments{ |
| 10 |
\item{dend}{a dendrogram object} |
| 11 |
|
| 12 |
\item{...}{not used} |
| 13 |
} |
| 14 |
\value{ |
| 15 |
A vector with the dendrogram's leaves' branches' colors |
| 16 |
} |
| 17 |
\description{ |
| 18 |
It is useful to get the colors of branches of the leaves, |
| 19 |
after we use \link{color_branches}, so to then match the colors of the labels |
| 20 |
to that of the branches (since getting the colors of branches to match |
| 21 |
those of the labels can be tricky). |
| 22 |
This is based on \link{get_leaves_branches_attr} which is based on |
| 23 |
\link{get_leaves_edgePar}. |
| 24 |
|
| 25 |
TODO: The function get_leaves_branches_col may behave oddly when extracting |
| 26 |
colors with missing col attributes when the lwd attribute is available. |
| 27 |
This may resolt in a vector with the wrong length (with omitted NA values). |
| 28 |
This might need to be fixed in the future, and attention should be given to this case. |
| 29 |
} |
| 30 |
\examples{ |
| 31 |
# define dendrogram object to play with: |
| 32 |
hc <- hclust(dist(USArrests[1:5, ]), "ave") |
| 33 |
dend <- as.dendrogram(hc) |
| 34 |
|
| 35 |
par(mfrow = c(1, 2), mar = c(5, 2, 1, 0)) |
| 36 |
dend <- dend \%>\% |
| 37 |
color_branches(k = 3) \%>\% |
| 38 |
set("branches_lwd", c(2, 1, 2)) \%>\% |
| 39 |
set("branches_lty", c(1, 2, 1)) |
| 40 |
|
| 41 |
plot(dend) |
| 42 |
|
| 43 |
labels_colors(dend) <- get_leaves_branches_col(dend) |
| 44 |
plot(dend) |
| 45 |
} |
| 46 |
\seealso{ |
| 47 |
\link{get_nodes_attr}, \link{assign_values_to_leaves_nodePar}, \link{labels_colors} |
| 48 |
\link{get_leaves_nodePar}, \link{get_leaves_edgePar}, \link{get_leaves_branches_attr} |
| 49 |
} |