DescendantEdges {TreeTools} | R Documentation |
Identify descendant edges
Description
DescendantEdges()
efficiently identifies edges that are "descended" from
edges in a tree.
DescendantTips()
efficiently identifies leaves (external nodes) that are
"descended" from edges in a tree.
Usage
DescendantEdges(
parent,
child,
edge = NULL,
node = NULL,
nEdge = length(parent),
includeSelf = TRUE
)
DescendantTips(parent, child, edge = NULL, node = NULL, nEdge = length(parent))
AllDescendantEdges(parent, child, nEdge = length(parent))
Arguments
parent |
Integer vector corresponding to the first column of the edge
matrix of a tree of class |
child |
Integer vector corresponding to the second column of the edge
matrix of a tree of class |
edge |
Integer specifying the number of the edge whose children are
required (see |
node |
Integer specifying the number(s) of nodes whose children are
required. Specify |
nEdge |
number of edges (calculated from |
includeSelf |
Logical specifying whether to mark |
Value
DescendantEdges()
returns a logical vector stating whether each
edge in turn is the specified edge (if includeSelf = TRUE
)
or one of its descendants.
DescendantTips()
returns a logical vector stating whether each
leaf in turn is a descendant of the specified edge.
AllDescendantEdges()
is deprecated; use DescendantEdges()
instead.
It returns a matrix of class logical, with row N specifying whether each
edge is a descendant of edge N (or the edge itself).
See Also
Other tree navigation:
AncestorEdge()
,
CladeSizes()
,
EdgeAncestry()
,
EdgeDistances()
,
ListAncestors()
,
MRCA()
,
MatchEdges()
,
NDescendants()
,
NodeDepth()
,
NodeNumbers()
,
NodeOrder()
,
RootNode()
Examples
tree <- as.phylo(0, 6)
plot(tree)
desc <- DescendantEdges(tree$edge[, 1], tree$edge[, 2], edge = 5)
which(desc)
ape::edgelabels(bg = 3 + desc)
tips <- DescendantTips(tree$edge[, 1], tree$edge[, 2], edge = 5)
which(tips)
tiplabels(bg = 3 + tips)