hsp_squared_change_parsimony {castor} | R Documentation |

Reconstruct ancestral states of a continuous (numeric) trait for nodes and predict unknown (hidden) states for tips on a tree using squared-change (or weighted squared-change) parsimony (Maddison 1991).

hsp_squared_change_parsimony(tree, tip_states, weighted=TRUE, 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 state of each tip in the tree. |

`weighted` |
Logical, specifying whether to weight transition costs by the inverted edge lengths during ancestral state reconstruction. This corresponds to the "weighted squared-change parsimony" reconstruction by Maddison (1991) for a Brownian motion model of trait evolution. |

`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 |

Any `NA`

entries in `tip_states`

are interpreted as unknown (hidden) states to be estimated. Prior to ancestral state reconstruction, the tree is temporarily prunned, keeping only tips with known state. The function then uses Maddison's squared-change parsimony algorithm to reconstruct the globally parsimonious state at each node (Maddison 1991). The states of tips with hidden state are set to those of the most recent ancestor with reconstructed state, as described by Zaneveld and Thurber (2014). This 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).

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`

).

This function is meant for reconstructing ancestral states in all nodes of a tree as well as predicting the states of tips with an a priory unknown state. If the state of all tips is known and only ancestral state reconstruction is needed, consider using the function `asr_squared_change_parsimony`

for improved efficiency.

A list with the following elements:

`states` |
A numeric vector of size Ntips+Nnodes, listing the reconstructed state of each tip and node. The entries in this vector will be in the order in which tips and nodes are indexed in |

`total_sum_of_squared_changes` |
The total sum of squared changes, minimized by the (optionally weighted) squared-change parsimony algorithm. This is equation 7 in (Maddison, 1991). |

Stilianos Louca

W. P. Maddison (1991). Squared-change parsimony reconstructions of ancestral states for continuous-valued characters on a phylogenetic tree. Systematic Zoology. 40:304-314.

J. R. Zaneveld and R. L. V. Thurber (2014). Hidden state prediction: A modification of classic ancestral state reconstruction algorithms helps unravel complex symbioses. Frontiers in Microbiology. 5:431.

`asr_squared_change_parsimony`

`hsp_max_parsimony`

,
`hsp_mk_model`

,
`map_to_state_space`

# 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, spread=1, decay_rate=0.001)$tip_states # print tip states print(tip_states) # set half of the tips to unknown state tip_states[sample.int(Ntips,size=as.integer(Ntips/2),replace=FALSE)] = NA # reconstruct all tip states via weighted SCP estimated_states = hsp_squared_change_parsimony(tree, tip_states, weighted=TRUE)$states # print estimated tip states print(estimated_states[1:Ntips])

[Package *castor* version 1.6.8 Index]