Learn R Programming

Claddis (version 0.7.0)

fix_root_time: Fixes root.time after taxa have been pruned from a tree

Description

Fixes root.time after taxa have been pruned from a tree using ape::drop.tip

Usage

fix_root_time(original_tree, pruned_tree)

Value

Returns a tree (phylo object) with a fixed $root.time.

Arguments

original_tree

A tree in phylo format.

pruned_tree

A tree in phylo format that represents a pruned version of original_tree.

Author

Graeme T. Lloyd graemetlloyd@gmail.com

Details

(NB: This function is designed to only cope with trees containing at least three tips.)

When removing taxa from a time-scaled tree using drop.tip in ape $root.time is left unchanged. This can cause downstream problems if not fixed and that is what this function does.

Note that fix_root_time in the paleotree package performs the same function, but is not called here to reduce the number of libraries on which Claddis is dependent. Interested users should also refer to the dropPaleoTip function in paleotree.

See Also

drop_time_tip

Examples

Run this code

# 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 <- fix_root_time(original_tree = tree, pruned_tree = pruned_tree)

# Show that the root time is now fixed (19 Ma):
pruned_tree$root.time

Run the code above in your browser using DataLab