lineage.Analyze

Calls the tHMM functions and outputs the parameters needed to generate the Figures.

Module Contents

lineage.Analyze.Analyze(X: list, num_states: int, fpi=None, fT=None, fE=None, rng=None) → Tuple[tHMM, float]

Wrapper for one-condition case.

lineage.Analyze.fit_list(tHMMobj_list: list, tolerance: float = 1e-06, max_iter: int = 200, rng=None) → Tuple[list[np.ndarray], list[np.ndarray], float]

Runs the tHMM function through Baum Welch fitting for a list containing a set of data for different concentrations.

Parameters
  • tHMMobj_list – all lineage trees we want to fit at once

  • tolerance – the stopping criteria for fitting. when the likelihood does not change more than tolerance from one step to the other, the fitting converges.

  • max_iter – the maximum number of iterations for fitting

Return MSD_list

marginal state distributions for all populations we fit at once

Return NF

normalizing factor

Return betas

beta values (conditional probability of cell states given cell observations)

Return gammas

gamma values (used to calculate the downward reursion)

Return new_LL

the log-likelihood of the optimized solution

lineage.Analyze.Analyze_list(pop_list: list, num_states: int, fpi=None, fT=None, fE=None, rng=None) → Tuple[list[tHMM], float, list]

This function runs the analyze function for the case when we want to fit multiple conditions at the same time. :param pop_list: The list of cell populations to run the analyze function on. :param num_states: The number of states that we want to run the model for. :return tHMMobj_list: The tHMMobj after fitting corresponding to the given LineageTree population. :return pred_states_by_lineage_by_conc: The list of cells in each lineage with states assigned to each cell. :return LL: The log-likelihood of the fitted model.

lineage.Analyze.run_Analyze_over(list_of_populations: list[list], num_states: np.ndarray, parallel=False, atonce=False, list_of_fpi=None, list_of_fT=None, list_of_fE=None) → list

A function that can be parallelized to speed up figure creation.

This function is the outermost for-loop we will end up using when analyzing heterogenous populations or lineages.

Analyze is the bottleneck in the figure creation process. The rest of the code involved in figure creation deals with collecting and computing certain statistics, most of which can be done in an additional for loop over the results from Analyze. :param list_of_populations: The list of cell populations to run the analyze function on. :param num_states: The number of states that we want to run the model for. :return output: The list of results from fitting a lineage.

lineage.Analyze.Results(tHMMobj: tHMM, LL: float) → dict[str, Any]

This function calculates several results of fitting a synthetic lineage and stores it in a dictionary. The dictionary contains the total number of lineages, the log likelihood of state assignments, and the total number of cells. It also contains metrics such as the accuracy of state assignment predictions, the distance between two distributions, and the Wasserstein distance between two states. :param tHMMobj: An instantiation of the tHMM class. :param LL: The log-likelihood of the fitted model. :return results_dict: A dictionary containing metrics of accuracy and scoring for the results of fitting a lineage.

lineage.Analyze.permute_states(tHMMobj: tHMM, switch_map: np.ndarray) → Tuple[Any, list]

This function takes the tHMMobj and the predicted states, and finds out whether we need to switch the state identities or not based on the likelihood. :param tHMMobj: An instantiation of the tHMM class. :param switch_map: An array of the likelihood of predicted states. :return tHMMobj: An instantiation of the tHMM class. :return pred_states_switched: A list of lineages with switched states.

lineage.Analyze.cheat(tHMMobj: tHMM) → np.ndarray

Find out the map between the assigned and true states by finding the closest pairs of parameters.