Bind a tip to a phylogeny (data frame version)
bind_tip_df.Rd
Graft a tip to a phylogeny at location specified.
Usage
bind_tip_df(
tree = NULL,
where,
tip_label,
frac = 0.5,
new_node_above = FALSE,
node_label = NULL,
return_tree = TRUE,
tree_tbl = NULL,
node_heights = NULL,
use_castor = FALSE
)
Arguments
- tree
A phylogeny, with class of "phylo".
- where
Location where to insert the tip. It can be either tip label or node label, but must be characters. If the location does not have a name, assign it first.
- tip_label
Name of the new tip inserted.
- frac
The fraction of branch length, must be between 0 and 1. This only applies when location is a tip or
new_node_above = TRUE
. The distance from the new inserted node to the location (a node or a tip) is the branch length of the location * (1 - frac).- new_node_above
Whether to insert the new node above when the location is a node? Default is
FALSE
, which will attach the new tip to the location node.- node_label
Name of the new node created. This only applies when location is a tip or
new_node_above = TRUE
.- return_tree
Whether to return a phylogeny with class "phylo?" Default is
TRUE
. Otherwise, it will return a data frame.- tree_tbl
A tibble version of the tree, optional.
- node_heights
A named numeric vector of node hieghts of the tree, generated by
ape::branching.times()
. It is also optional iftree
is specified; but required iftree_tbl
is specified.- use_castor
Whether to use package
castor
to get the phylogeny at a node; it is faster thantidytree::offspring
to figure out what are the tip offsprings at a node.
Examples
if (FALSE) {
library(rtrees)
bind_tip(tree_plant_otl, "N70407", tip_label = "test_sp")
tree_plant_otl_df = tidytree::as_tibble(tree_plant_otl)
node_heights = ape::branching.times(tree_plant_otl)
bind_tip(tree_tbl = tree_plant_otl_df, where = "N70407",
tip_label = "test_sp", node_heights = node_heights)
}