View source: R/asr_subtree_averaging.R
asr_subtree_averaging | R Documentation |
Reconstruct ancestral states in a phylogenetic tree for a continuous (numeric) trait by averaging trait values over descending subtrees. That is, for each node the reconstructed state is set to the arithmetic average state of all tips descending from that node.
asr_subtree_averaging(tree, tip_states, check_input=TRUE)
tree |
A rooted tree of class "phylo". The root is assumed to be the unique node with no incoming edge. |
tip_states |
A numeric vector of size Ntips, specifying the known state of each tip in the tree. |
check_input |
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 |
The function returns the estimated ancestral states (=averages) as well as the corresponding standard deviations. Note that reconstructed states are local estimates, i.e. they only take into account the tips descending from the reconstructed node.
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). Edge lengths and distances between tips and nodes are not taken into account. All tip states are assumed to be known, and NA
or NaN
are not allowed in tip_states
.
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
).
A list with the following elements:
success |
Logical, indicating whether ASR was sucessful. If all input data are valid then this will always be |
ancestral_states |
A numeric vector of size Nnodes, listing the reconstructed state (=average over descending tips) for each node. The entries in this vector will be in the order in which nodes are indexed in the tree. |
ancestral_stds |
A numeric vector of size Nnodes, listing the standard deviations corresponding to |
ancestral_counts |
A numeric vector of size Nnodes, listing the number of (descending) tips used to reconstruct the state of each node. |
Stilianos Louca
asr_independent_contrasts
,
asr_squared_change_parsimony
# 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 by averaging simulated tip states
node_states = asr_subtree_averaging(tree, tip_states)$ancestral_states
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.