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
tree = toytree.rtree.unittree(12, seed=42)
traits = tree.pcm.simulate_discrete_data(nstates=3, tips_only=True, nreplicates=1, seed=7)
ci = toytree.infer.consistency_and_retention_indices(tree, traits.t0, npermutations=500, rng=7)
print(ci)
trait = traits.t0.to_dict()
color_map = {0: '#4c78a8', 1: '#f58518', 2: '#54a24b'}
tip_colors = [color_map[trait[name]] for name in tree.get_tip_labels()]
c, a, m = tree.draw(layout='r', tip_labels=True, tip_labels_colors=tip_colors, scale_bar=True)
c
import toytree
tree = toytree.rtree.unittree(12, seed=42)
traits = tree.pcm.simulate_discrete_data(nstates=3, tips_only=True, nreplicates=1, seed=7)
ci = toytree.infer.consistency_and_retention_indices(tree, traits.t0, npermutations=500, rng=7)
print(ci)
trait = traits.t0.to_dict()
color_map = {0: '#4c78a8', 1: '#f58518', 2: '#54a24b'}
tip_colors = [color_map[trait[name]] for name in tree.get_tip_labels()]
c, a, m = tree.draw(layout='r', tip_labels=True, tip_labels_colors=tip_colors, scale_bar=True)
c