pair.age.in.tree {phylopairs} | R Documentation |
pair.age.in.tree
Description
Takes a lineage-pair dataset and a phylogenetic tree and returns the 'age' of the node representing the MRCA for each pair. 'Age' is measured from the present and is in whatever units are represented by branch lengths of the tree (which is time in a dated phylogeny).
Takes a lineage-pair dataset and a phylogenetic tree and returns the 'age' of the node representing the MRCA for each pair. 'Age' is measured from the present and is in whatever units are represented by branch lengths of the tree (which is time in a dated phylogeny).
Usage
pair.age.in.tree(dataset, tree, taxacolumns)
pair.age.in.tree(dataset, tree, taxacolumns)
Arguments
dataset |
A data.frame in which each row corresponds to a pair in the dataset. Must contain two columns of taxa names (one for each taxon in every pair), and the taxa names must be in same format as that used in the tree. |
tree |
An ultrametric phylogenetic tree ('phylo' object) containing the species that appear in at least one pair in the dataset. Names must be in the same format as those used in 'dataset'. |
taxacolumns |
Character vector containing the column names for the two columns containing species names (e.g. c("sp1", "sp2")) |
Details
Function is a wrapper for ape::node.depth.edgelength
. That function returns the depths of all the nodes in a tree as measured from the root. phylopairs::node.age
converts these values to depth as measured from the present and returns the values corresponding to each pair in a user-supplied lineage-pair dataset.
Function is a wrapper for ape::node.depth.edgelength()
. That function returns the depths of all the nodes in a tree as measured from the root. phylopairs::node.age()
converts these values to depth as measured from the present and returns the values corresponding to each pair in a user-supplied lineage-pair dataset.
Value
A numeric vector of node ages ordered to match the rows in 'dataset'.
A numeric vector of node ages ordered to match the rows in 'dataset'.
Examples
# Load a dataset and a tree
data(data1)
data(sim.tree1)
# Find the node.ages and add as a column to the dataset
data1$age = pair.age.in.tree(dataset=data1, tree=sim.tree1, taxacolumns=c("sp1","sp2"))
head(data1)
# Plot tree with axis in units of branch lengths and perform visual check that dates are correct
library(ape)
plot(sim.tree1)
axisPhylo()
# Load a dataset and a tree
data(data1)
data(sim.tree1)
# Find the node.ages and add as a column to the dataset
data1$age = pair.age.in.tree(dataset=data1, tree=sim.tree1, taxacolumns=c("sp1","sp2"))
head(data1)
# Plot tree with axis in units of branch lengths and perform visual check that dates are correct
library(ape)
plot(sim.tree1)
axisPhylo()