
Reconstruct ancestral states for a continuous (numeric) trait using squared-change maximum parsimony (Maddison, 1991). Transition costs can optionally be weighted by the inverse edge lengths ("weighted squared-change parsimony" by Maddison).
asr_squared_change_parsimony(tree, tip_states, weighted=TRUE, check_input=TRUE)
A list with the following elements:
A numeric vector of size Nnodes, listing the reconstructed state of each node. The entries in this vector will be in the order in which nodes are indexed in the tree.
The total sum of squared changes, minimized by the (optionally weighted) squared-change parsimony algorithm. This is equation 7 in (Maddison, 1991).
A rooted tree of class "phylo". The root is assumed to be the unique node with no incoming edge.
A numeric vector of size Ntips, specifying the known state of each tip in the tree.
Logical, specifying whether to weight transition costs by the inverted edge lengths. This corresponds to the "weighted squared-change parsimony" reconstruction by Maddison (1991) for a Brownian motion model of trait evolution.
Logical, specifying whether to perform some basic checks on the validity of the input data. If you are certain that your input data are valid, you can set this to FALSE
to reduce computation.
Stilianos Louca
The function traverses the tree in postorder (tips-->root) to calculate the quadratic parameters described by Maddison (1991) and obtain the globally parsimonious squared-change parsimony state for the root. The function then reroots at each node, updates all affected quadratic parameters in the tree and calculates the node's globally parsimonious squared-change parsimony state. The function has asymptotic time complexity O(Nedges).
If tree$edge.length
is missing, each edge in the tree is assumed to have length 1. This is the same as setting weighted=FALSE
. The tree may include multi-furcations (i.e. nodes with more than 2 children) as well as mono-furcations (i.e. nodes with only one child). Edges with length 0 will be adjusted internally to some tiny length if needed (if weighted==TRUE
).
Tips must be represented in tip_states
in the same order as in tree$tip.label
. The vector tip_states
need not include item names; if it does, however, they are checked for consistency (if check_input==TRUE
).
If weighted==FALSE
, then this function yields the same ancestral state reconstructions as
ape::ace(tip_states, tree, type="continuous", method="ML", model="BM", CI=FALSE)
in the ape
package (v. 0.5-64), assuming the tree as unit edge lengths. If weighted==TRUE
, then this function yields the same ancestral state reconstructions as the maximum likelihood estimates under a Brownian motion model, as implemented by the Rphylopars
package (v. 0.2.10):
Rphylopars::anc.recon(tip_states, tree, vars=FALSE, CI=FALSE).
W. P. Maddison (1991). Squared-change parsimony reconstructions of ancestral states for continuous-valued characters on a phylogenetic tree. Systematic Zoology. 40:304-314.
asr_independent_contrasts
asr_max_parsimony
,
asr_mk_model
# generate random tree
Ntips = 100
tree = generate_random_tree(list(birth_rate_intercept=1),max_tips=Ntips)$tree
# simulate a continuous trait
tip_states = simulate_ou_model(tree,
stationary_mean=0,
stationary_std=1,
decay_rate=0.001)$tip_states
# reconstruct node states based on simulated tip states
node_states = asr_squared_change_parsimony(tree, tip_states, weighted=TRUE)$ancestral_states
Run the code above in your browser using DataLab