cassiopeia.tl.calculate_likelihood_continuous#

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

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

A wrapper function for get_lineage_tracing_parameters and log_likelihood_of_character under a continuous 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 instantaneous 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 to be used. We assume that the rates are instantaneous rates representing the frequency at which mutation and missing data events occur in a period of time. Under this continuous model, we assume that the waiting time until a mutation/missing data event is exponentially distributed. The probability that an event occurred in time t is thus given by the exponential CDF.

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 str | NoneOptional[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 tree priors are not populated, or if character – state annotations are missing at a node.