cassiopeia.tl.calculate_likelihood_discrete#

cassiopeia.tl.calculate_likelihood_discrete(tree, use_internal_character_states=False, layer=None)[source]#

Calculates the log likelihood of a tree under a discrete process.

A wrapper function for get_lineage_tracing_parameters and log_likelihood_of_character under a discrete model of lineage tracing.

This function acquires the mutation rate, the heritable missing rate, and the stochastic missing probability from the tree using get_lineage_tracing_parameters. The rates are assumed to be per-generation rates. Then, it calculates the log likelihood for each character using log_likelihood_of_character, and then by assumption that characters mutate independently, sums their likelihoods to get the likelihood for the tree.

Here, branch lengths are not to be used. We assume that rates are per-generation, that is, these rates represent the probability a mutation occurs on a branch regardless of the branch length t.

Parameters:
tree CassiopeiaTree

The tree on which to calculate likelihood over

use_internal_character_states bool (default: False)

Indicates if internal node character states should be assumed to be specified exactly

layer Optional[str] (default: None)

Layer to use for the character matrix in estimating parameters. If this is None, then the current character_matrix variable will be used.

Return type:

float

Returns:

The log likelihood of the tree given the observed character states.

Raises:

CassiopeiaError if the parameters consumed from the tree are invalid, – if the tree priors are not populated, or if character states annotations are missing at a node.