R: Get Branching Times From Parenthetic-Format Tree ('Newick')
getBtimes
R Documentation
Get Branching Times From Parenthetic-Format Tree ('Newick')
Description
Reads a file containing an ultrametric tree in parenthetic format and
returns a numeric vector of branching times, sorted from earliest to most
recent.
Usage
getBtimes(file = NULL, string=NULL)
Arguments
file
a file containing a single tree in 'newick' (parenthetic) format
string
the name of an object containing a 'newick' tree character string
Details
This function requires the package ape. If ape has not been
attached to the search path but exists in the R directory, it will automatically
be loaded. If ape does not exist, you must install it by typing
install.packages("ape") at the R prompt.
If tree is not ultrametric, an error message will be generated.
data(agamids)
write.table(agamids, file = 'example.tre', quote=FALSE,
row.names = FALSE, col.names = FALSE)
# the preceding lines generate a file 'example.tre' that can be
# read by 'getBtimes'
agbtimes <- getBtimes(file = 'example.tre')
#or alternatively:
agbtimes <- getBtimes(string = agamids)
#agbtimes is now a numeric vector of branching times
plotLtt(agbtimes) #plot log-lineages through time for agamid data
gamStat(agbtimes) #calculate gamma statistic for agamid data
unlink('example.tre') #clean-up.