| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/prune.R |
| 3 |
\name{prune} |
| 4 |
\alias{prune} |
| 5 |
\alias{prune.default} |
| 6 |
\alias{prune.dendrogram} |
| 7 |
\alias{prune.hclust} |
| 8 |
\alias{prune.phylo} |
| 9 |
\alias{prune.rpart} |
| 10 |
\title{Prunes a tree (using leaves' labels)} |
| 11 |
\usage{ |
| 12 |
prune(dend, ...) |
| 13 |
|
| 14 |
\method{prune}{default}(dend, ...) |
| 15 |
|
| 16 |
\method{prune}{dendrogram}(dend, leaves, reindex_dend = TRUE, ...) |
| 17 |
|
| 18 |
\method{prune}{hclust}(dend, leaves, ...) |
| 19 |
|
| 20 |
\method{prune}{phylo}(dend, ...) |
| 21 |
|
| 22 |
\method{prune}{rpart}(dend, ...) |
| 23 |
} |
| 24 |
\arguments{ |
| 25 |
\item{dend}{tree object (dendrogram/hclust/phylo)} |
| 26 |
|
| 27 |
\item{...}{passed on} |
| 28 |
|
| 29 |
\item{leaves}{a character vector of the label(S) of the tip(s) (leaves) we wish to prune off the tree.} |
| 30 |
|
| 31 |
\item{reindex_dend}{logical (default is TRUE). If TRUE, the leaves of the new dendrograms |
| 32 |
include the rank of the old order.dendrogram. |
| 33 |
This insures that their values are just like the number of leaves. |
| 34 |
When FALSE, the values in the leaves is that of the original dendrogram. Thie is useful |
| 35 |
if prunning a dendrogram but then wanting to use \link{order.dendrogram} with the original values. |
| 36 |
When using prune.hclust, then reindex_dend is used by default since otherwise the \link{as.hclust} function |
| 37 |
would return an error.} |
| 38 |
} |
| 39 |
\value{ |
| 40 |
A pruned tree |
| 41 |
} |
| 42 |
\description{ |
| 43 |
Trimms a tree (dendrogram, hclust) from a set of leaves based on their labels. |
| 44 |
} |
| 45 |
\details{ |
| 46 |
I was not sure if to call this function drop.tip (from ape), snip/prune (from rpart) or just remove.leaves. I ended up deciding on prune. |
| 47 |
} |
| 48 |
\examples{ |
| 49 |
hc <- hclust(dist(USArrests[1:5, ]), "ave") |
| 50 |
dend <- as.dendrogram(hc) |
| 51 |
|
| 52 |
par(mfrow = c(1, 2)) |
| 53 |
plot(dend, main = "original tree") |
| 54 |
plot(prune(dend, c("Alaska", "California")), main = "tree without Alaska and California") |
| 55 |
|
| 56 |
|
| 57 |
# this works because prune uses reindex_dend = TRUE by default |
| 58 |
as.hclust(prune(dend, c("Alaska", "California"))) |
| 59 |
prune(hc, c("Alaska", "California")) |
| 60 |
} |
| 61 |
\seealso{ |
| 62 |
\link{prune_leaf}, \link[ape]{drop.tip} |
| 63 |
} |