cassiopeia.tl.fitch_count#

cassiopeia.tl.fitch_count(cassiopeia_tree, meta_item, root=None, infer_ancestral_states=True, state_key='S1', unique_states=None)[source]#

Runs the FitchCount algorithm.

Performs the FitchCount algorithm for inferring the number of times that two states transition to one another across all equally-parsimonious solutions returned by the Fitch-Hartigan algorithm. The original algorithm was described in Quinn, Jones, et al, Science (2021). The output is an MxM count matrix, where the values indicate the number of times that m1 transitioned to m2 along an edge in a Fitch-Hartigan solution. To obtain probabilities P(m1 -> m2), divide each row by its row-sum.

This procedure will only work on categorical data and will otherwise raise an error.

Parameters:
cassiopeia_tree CassiopeiaTree

CassiopeiaTree object with a tree and cell meta data.

meta_item str

A column in the CassiopeiaTree cell meta corresponding to a categorical variable.

root Optional[str] (default: None)

Node to treat as the root. Only the subtree below this node will be considered for the procedure.

infer_ancestral_states bool (default: True)

Whether or not to initialize the ancestral state sets with Fitch-Hartigan.

state_key str (default: 'S1')

If ancestral state sets have already been created, then this argument specifies what the attribute name is in the CassiopeiaTree

unique_states Optional[List[str]] (default: None)

State space that can be optionally provided by the user. If this is not provided, we take the unique values in cell_meta[meta_item] to be the state space.

Returns:

An MxM count matrix indicating the number of edges that contained a

transition between two states across all equally parsimonious solutions returned by Fitch-Hartigan.