This function is used to calculate the crown ages for a set of clades within a phylogenetic tree. This function requires the package 'ape'

clade_age(tree, taxonomy, species, clades, total = TRUE, sp_sep = " ")

Arguments

tree

A time-resolved newick formatted tree with tip labels equal to the species binomial names with an "_" such as the trees downloaded from timetree.org.

taxonomy

A data frame with each row holding the species' taxonomic hierarchy, such as what is returned from hierarchy(), or the clade names in which each species belongs.

species

A character equal to the name of the column that holds the species binomial names. This column can also to be a different taxonomic level if needed.

clades

A character or vector equal to the name(s) of the columns that holds the clade names

total

Logical. If TRUE, the crown age for the entire group of species is returned

sp_sep

A character equal to the separator of the binomial name in the species name column. For example: for 'Apis mellifera' sp_sep = ' ' or for 'Apis.mellifera' sp_sep = '.'

Value

A data frame with three columns. One for the clade name, one for the clade rank (i.e. column name in the input data frame), and one for the crown age of the clade.

Examples

if (FALSE) {

library(here)
library(ape)

tree <- read.tree(file.path(here(), 'data_raw', 'Tetrapoda_species.nwk'))
herp <- read.csv(file.path(here(), 'data_out', 'supp_info', 'IBT_Carib_Taxonomy.csv'), header=TRUE)

ages <- clade_age(tree = tree,
                  taxonomy = taxa,
                  species = 'sp_in_Data',
                  clades = c("Class", "Order", "Family", "Genus"),
                  total = TRUE,
                  sp_sep = " ")
}