drop_time_tip: Drop tips from a time-scaled tree

View source: R/drop_time_tip.R

drop_time_tipR Documentation

Drop tips from a time-scaled tree

Description

Drop tips from a time-scaled tree and update root.time accordingly

Usage

drop_time_tip(time_tree, tip_names, ...)

Arguments

time_tree

A time-scaled tree in phylo format where branch lengths are durations and where a $root.time value indicates the root age.

tip_names

A vector of tip names to be pruned from the tree.

...

Additional options to be passed to ape::drop.tip.

Details

(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.

Value

Returns a tree (phylo object) with pruned tips and corrected $root.time.

Author(s)

Graeme T. Lloyd graemetlloyd@gmail.com

See Also

fix_root_time

Examples


# 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


graemetlloyd/Claddis documentation built on May 9, 2024, 8:07 a.m.