Parsimony indices
Inference: Parsimony (CI / RI)¶
Compute parsimony indices for a discrete trait and visualize the trait values on the tips.
In [ ]:
Copied!
import toytree
import toytree
Simulate a trait with high phylogenetic signal¶
In [40]:
Copied!
tree = toytree.rtree.unittree(35, seed=42)
trait = tree.pcm.simulate_discrete_trait(nstates=3, tips_only=True, state_names="ABC", seed=7)
tree = toytree.rtree.unittree(35, seed=42)
trait = tree.pcm.simulate_discrete_trait(nstates=3, tips_only=True, state_names="ABC", seed=7)
In [41]:
Copied!
trait.head()
trait.head()
Out[41]:
0 B 1 B 2 B 3 C 4 C Name: t0, dtype: object
In [42]:
Copied!
ci = toytree.infer.consistency_and_retention_indices(tree, trait, npermutations=500, rng=7)
print(ci)
ci = toytree.infer.consistency_and_retention_indices(tree, trait, npermutations=500, rng=7)
print(ci)
CI 0.250000 CI_permuted_mean 0.169336 CI_p-value 0.003992 RI 0.812500 RI_permuted_mean 0.690750 RI_p-value 0.003992 RCI 0.203125 RCI_permuted_mean 0.117419 RCI_p-value 0.003992 fitch_parsimony_score 8.000000 fitch_parsimony_score_permuted_mean 11.896000 npermutations 500.000000 dtype: float64
simulate a trait with low (random) phylogenetic signal¶
In [ ]:
Copied!
In [ ]:
Copied!