get_tips_in_ape_plot_order: Get tips of a phylogenetic tree in their plotted order

Description Usage Arguments Details Value References Examples

Description

After re-rooting a tree, the order of tips when the tree is plotted no longer match the order of $tip.label. Use this function to get tips in the order they are plotted.

Usage

1

Arguments

tree

Phylognetic tree (list of class "phylo")

Details

Note that this is not compatible with ggtree! The same tree plotted with ggtree and ape may have slightly different tip order.

To get tip order of a ggtree plot, do something like this: data(bird.orders) p <- ggtree::ggtree(bird.orders) p[["data"]] # extract 'label' and 'y' columns

Value

Vector

References

https://stackoverflow.com/questions/34364660/how-to-get-correct-order-of-tip-labels-in-ape-after-calling-ladderize-function

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
library(ape)
data(bird.orders)
plot(bird.orders, no.margin = TRUE)
bird.orders$tip.label # matches plot
bird.orders_reroot <- root(bird.orders, 5)
plot(bird.orders_reroot)
# Tip order still the same even though the tree
# has been re-rooted!
all.equal(bird.orders_reroot$tip.label, bird.orders$tip.label)
get_tips_in_ape_plot_order(bird.orders_reroot) # matches order in plot

joelnitta/jntools documentation built on Jan. 17, 2022, 3:05 p.m.