View source: R/drop_time_tip.R
drop_time_tip | R Documentation |
Drop tips from a time-scaled tree and update root.time accordingly
drop_time_tip(time_tree, tip_names, ...)
time_tree |
A time-scaled tree in phylo format where branch lengths are durations and where a |
tip_names |
A vector of tip names to be pruned from the tree. |
... |
Additional options to be passed to |
(NB: This function is designed to only cope with trees containing at least three tips.)
Usually ape formatted trees are pruned with the drop.tip function in ape. However, trees time-scaled using either the paleotree
or strap
packages have an additional important component, the root age ($root.time
) that may need updating when tips are removed. (See fix_root_time.) Thus this function is a modified version of drop.tip that also performs the fix_root_time step.
Note that dropPaleoTip
in the paleotree
package performs the exact same function, but is not called here to reduce the number of dependencies for Claddis
.
Returns a tree (phylo object) with pruned tips and corrected $root.time
.
Graeme T. Lloyd graemetlloyd@gmail.com
fix_root_time
# Create a simple four-taxon tree with branch lengths:
tree <- ape::read.tree(text = "(A:1,(B:1,(C:1,D:1):1):1);")
# Set root age as 20 Ma:
tree$root.time <- 20
# Now prune taxon A:
pruned_tree <- ape::drop.tip(phy = tree, tip = "A")
# Show that drop.tip has not updated the tree's root time:
pruned_tree$root.time
# Use the function to fix the root time:
pruned_tree <- drop_time_tip(time_tree = tree, tip_names = "A")
# Show that the root time is now fixed (19 Ma):
pruned_tree$root.time
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.