ivy.chars.recon module¶
-
ivy.chars.recon.
anc_recon_cat
(tree, chars, Q, p=None, pi=u'Equal', ars=None, nregime=1)[source]¶ Given tree, character states at tips, and transition matrix perform ancestor reconstruction for a discrete character.
Perform downpass using mk function, then perform uppass.
Return reconstructed states - including tips
Parameters: - tree (Node) – Root node of a tree. All branch lengths must be greater than 0 (except root)
- chars (dict) –
Dict mapping character states to tip labels. Character states should be coded 0,1,2...
Can also be a list with tip states in preorder sequence
- Q (np.array) – Instantaneous rate matrix
- p (np.array) – 3-D array of dimensions branch_number * nchar * nchar. Optional. Pre-allocated space for efficient calculations
- pi (str or np.array) –
Option to weight the root node by given values. Either a string containing the method or an array of weights. Weights should be given in order. Accepted methods of weighting root:
Equal: Flat prior Equilibrium: Prior equal to stationary distributionof Q matrix- Fitzjohn: Root states weighted by how well they
- explain the data at the tips.
- ars (dict) – Dict of pre-allocated arrays to improve speed by avoiding creating and destroying new arrays. Can be created with create_ancrecon_ars function. Optional.
- nregime (int) – If hidden-rates model is used, the number of regimes to consider in the reconstruction. Optional, defaults to 1 (no hidden rates)
Returns: - Array of nodes in preorder sequence containing marginal
likelihoods.
Return type: np.array
-
ivy.chars.recon.
create_ancrecon_ars
(tree, chars, nregime=1)[source]¶ Create nodelists. For use in recon function
Returns edgelist of nodes in postorder sequence, edgelist of nodes in preorder sequence, partial likelihood vector for each node’s children, childlist, and branch lengths.