lineage.tHMM

This file holds the parameters of our tHMM in the tHMM class.

Module Contents

class lineage.tHMM.estimate(X: list[LineageTree], nState: int, fpi=None, fT=None, fE=None, rng=None)

Estimation class.

class lineage.tHMM.tHMM(X: list[LineageTree], num_states: int, fpi=None, fT=None, fE=None, rng=None)

Main tHMM class.

predict(self)

Given a fit model, the model predicts an optimal state assignment using the Viterbi algorithm.

Returns

assigned states to each cell in each lineage. It is organized in the form of list of arrays, each array shows the state of cells in one lineage.

get_BIC(self, LL: float, num_cells: int, atonce=False, mcf10a=False)

Gets the BIC values. Akaike Information Criterion, used for model selection and deals with the trade off between over-fitting and under-fitting. \(BIC = - 2 * log(LL) + log(number_of_cells) * DoF\) in which k is the number of free parameters and LL is the maximum of likelihood function. Minimum of BIC detremines the relatively better model.

log_score(self, X_state_tree_sequence: list, pi=None, T=None, E=None)

This function returns the log-likelihood of a possible state assignment given the estimated model parameters. The user can also provide their own pi, T, or E matrices instead to score a possible state assignment. \(P(x_1,...,x_N,z_1,...,z_N) = P(z_1) * prod_{n=2:N}(P(z_n | z_pn)) * prod_{n=1:N}(P(x_n|z_n))\) \(log{P(x_1,...,x_N,z_1,...,z_N)} = log{P(z_1)} + sum_{n=2:N}(log{P(z_n | z_pn)}) + sum_{n=1:N}(log{P(x_n|z_n)})\) :param X_state_tree_sequence: the assigned states to cells at each lineage object :return: the log-likelihood of states assigned to single cells, based on the pi, T, and E, separate for each lineage tree

lineage.tHMM.log_T_score(T: np.ndarray, state_tree_sequence: list, lineageObj: LineageTree) → float

To calculate the joint probability of state and observations. This function calculates the second term. \(P(x_1,...,x_N,z_1,...,z_N) = P(z_1) * prod_{n=2:N}(P(z_n | z_pn)) * prod_{n=1:N}(P(x_n|z_n))\) \(log{P(x_1,...,x_N,z_1,...,z_N)} = log{P(z_1)} + sum_{n=2:N}(log{P(z_n | z_pn)}) + sum_{n=1:N}(log{P(x_n|z_n)})\) :param T: transition probability matrix :type T: ndarray :param state_tree_sequence: the assigned states to cells at each lineage object :param lineageObj: the lineage trees :type lineageObj: object :return: the log-likelihood of the transition probability matrix