Learn R Programming

spacodiR (version 0.13.0115)

phy.nodetimes: finding splitting times for nodes

Description

phy.nodetimes is a function to collect all nodes (and times) that are within a particular time fraction of the total temporal extent of a phylogeny

Usage

phy.nodetimes(phy, time.range = c(0, 0), proportion = TRUE)

Arguments

phy
a phylogenetic tree of class phylo; see read.tree
time.range
the temporal slice of the tree defining the bounds for extracted nodes
proportion
Boolean; whether time.range is regarded as proportions of tree height

Value

A named vector of times (whose names are node labels; see nodelabels for the function used to label nodes).

Details

Given a temporal fraction of a phylogeny, this function will return all contained nodes (and branching times if desired). If used with spacodi.by.nodes, one could conduct significance testing of Bst through particular time slices of the phylogeny. Note: when using proportion=TRUE, '0' is regarded as the present, '1' as the root of the tree (e.g., start.time=1.0 and stop.time=0.8 gathers nodes for the basalmost or most rootward 20 percent of the temporal extent of the tree).

Examples

Run this code
## an example of comparing observed and expected Bst at nodes ##
data(sp.example)
attach(sp.example)
s=spl
p=phy

# get nodes for a time-slice
n.t=phy.nodetimes(phy=p,time.range=c(0.25,0.75))

# get Bsts for nodes
o=spacodi.by.nodes(sp.plot=s, phy=p, obs.only=TRUE)[[1]]
obs=o[!is.na(match(o[,"node.ID"], names(n.t))),1]

# compile expected Bst-values from data reshuffling
spacodi.by.nodes(sp.plot=s, phy=p, n.rep=5, method="1s")[[2]]->exps
e=exps[!is.na(match(row.names(exps), names(n.t))),]
exp=unname(unlist(e))

# randomization test of observed and expected Bst
resamp.test(obs=obs, exp=exp, iter=100, two.tailed=TRUE)

Run the code above in your browser using DataLab