Description Usage Arguments Details Value Author(s) Examples
View source: R/fix_root_time.R
Fixes root.time after taxa have been pruned from a tree using ape::drop.tip
1 | fix_root_time(original_tree, pruned_tree)
|
original_tree |
A tree in phylo format. |
pruned_tree |
A tree in phylo format that represents a pruned version of |
(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
.
Returns a tree (phylo object) with a fixed $root.time
.
Graeme T. Lloyd graemetlloyd@gmail.com
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # 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
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.