AddTip | R Documentation |
AddTip()
adds a tip to a phylogenetic tree at a specified location.
AddTip(
tree,
where = sample.int(tree[["Nnode"]] * 2 + 2L, size = 1) - 1L,
label = "New tip",
nodeLabel = "",
edgeLength = 0,
lengthBelow = NULL,
nTip = NTip(tree),
nNode = tree[["Nnode"]],
rootNode = RootNode(tree)
)
AddTipEverywhere(tree, label = "New tip", includeRoot = FALSE)
tree |
A tree of class |
where |
The node or tip that should form the sister taxon to the new
node. To add a new tip at the root, use |
label |
Character string providing the label to apply to the new tip. |
nodeLabel |
Character string providing a label to apply to the newly
created node, if |
edgeLength |
Numeric specifying length of new edge. If |
lengthBelow |
Numeric specifying length below neighbour at which to
graft new edge. Values greater than the length of the edge will result
in negative edge lengths. If |
nTip , nNode , rootNode |
Optional integer vectors specifying number of tips
and nodes in |
includeRoot |
Logical; if |
AddTip()
extends bind.tree
, which cannot handle
single-taxon trees.
AddTipEverywhere()
adds a tip to each edge in turn.
AddTip()
returns a tree of class phylo
with an additional tip
at the desired location.
AddTipEverywhere()
returns a list of class multiPhylo
containing
the trees produced by adding label
to each edge of tree
in turn.
Martin R. Smith (martin.smith@durham.ac.uk)
Add one tree to another: bind.tree()
Other tree manipulation:
CollapseNode()
,
ConsensusWithout()
,
DropTip()
,
EnforceOutgroup()
,
ImposeConstraint()
,
KeptPaths()
,
KeptVerts()
,
LeafLabelInterchange()
,
MakeTreeBinary()
,
Renumber()
,
RenumberTips()
,
RenumberTree()
,
RootTree()
,
SortTree()
,
Subtree()
,
TipTimedTree()
,
TrivialTree
tree <- BalancedTree(10)
# Add a leaf below an internal node
plot(tree)
ape::nodelabels()
node <- 15
ape::nodelabels(bg = ifelse(NodeNumbers(tree) == node, "green", "grey"))
plot(AddTip(tree, 15, "NEW_TIP"))
# Add edge lengths for an ultrametric tree
tree$edge.length <- rep(c(rep(1, 5), 2, 1, 2, 2), 2)
# Add a leaf to an external edge
leaf <- 5
plot(tree)
ape::tiplabels(bg = ifelse(seq_len(NTip(tree)) == leaf, "green", "grey"))
plot(AddTip(tree, 5, "NEW_TIP", edgeLength = NULL))
# Set up multi-panel plot
oldPar <- par(mfrow = c(2, 4), mar = rep(0.3, 4), cex = 0.9)
# Add leaf to each edge on a tree in turn
backbone <- BalancedTree(4)
# Treating the position of the root as instructive:
additions <- AddTipEverywhere(backbone, includeRoot = TRUE)
xx <- lapply(additions, plot)
par(mfrow = c(2, 3))
# Don't treat root edges as distinct:
additions <- AddTipEverywhere(backbone, includeRoot = FALSE)
xx <- lapply(additions, plot)
# Restore original plotting parameters
par(oldPar)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.