sp.tips | R Documentation |
The function sp.tips
finds the shortest path between tips of a tree,
identified as tip1
and tip2
. This function applies to trees
with the class phylo
, phylo4 or
phylo4d. Several tips can be provided at a time.
sp.tips(x, tip1, tip2, useTipNames = FALSE, quiet = FALSE, include.mrca = TRUE)
x |
A tree of class |
tip1 |
A vector of integers identifying tips by their numbers, or a vector of characters identifying tips by their names. Recycled if needed. |
tip2 |
A vector of integers identifying tips by their numbers, or a vector of characters identifying tips by their names. Recycled if needed. |
useTipNames |
a logical stating whether the output must be named using
tip names in all cases (TRUE), or not (FALSE). If not, names of |
quiet |
a logical stating whether a warning must be issued when tip1==tip2, or not (see details). |
include.mrca |
a logical stating whether the most recent common ancestor shall be included in the returned path (TRUE, default) or not (FALSE). |
The function checks if there are cases where tip1 and tip2 are the same.
These cases are deleted when detected, issuing a warning (unless
quiet
is set to TRUE).
A list whose components are vectors of named nodes forming the shortest path between a couple of tips.
Thibaut Jombart tjombart@imperial.ac.uk
shortestPath
which does the same thing as
sp.tips
, for any node (internal or tip), but much more slowly.
if(require(ape) & require(phylobase)){
## make a tree
x <- as(rtree(20),"phylo4")
plot(x,show.node=TRUE)
## get shortest path between tip 1 and all other tips.
sp.tips(x, "t1", "t2")
sp.tips(x, 1, 2:20, TRUE)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.