lineage.BaumWelch

Re-calculates the tHMM parameters of pi, T, and emissions using Baum Welch.

Module Contents

lineage.BaumWelch.do_E_step(tHMMobj: tHMM) → Tuple[list, list, list, list]

Calculate MSD, EL, NF, gamma, beta, LL from tHMM model.

Parameters

tHMMobj – A tHMM object with properties of the lineages of cells, such as

Return MSD

Marginal state distribution

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)

lineage.BaumWelch.calculate_log_likelihood(NF: list) → float

Calculates log likelihood of NF for each lineage.

Parameters

NF – list of normalizing factors

return: the sum of log likelihoods for each lineage

lineage.BaumWelch.calculate_stationary(T: np.ndarray) → np.ndarray

Calculate the stationary distribution of states from T. Note that this does not take into account potential influences of the emissions.

Parameters

T – transition matrix, a square matrix with probabilities of transitioning from one state to the other

Returns

The stationary distribution of states which can be obtained by solving w = w * T

lineage.BaumWelch.do_M_step(tHMMobj: list[tHMM], MSD: list, betas: list, gammas: list)

Calculates the maximization step of the Baum Welch algorithm given output of the expectation step. The individual parameter estimations are performed in separate functions.

Parameters
  • tHMMobj (list) – A class object with properties of the lineages of cells

  • MSD – The marginal state distribution P(z_n = k)

  • betas – beta values. The conditional probability of states, given observations of the sub-tree rooted in cell_n

  • gammas – gamma values. The conditional probability of states, given the observation of the whole tree

lineage.BaumWelch.do_M_pi_step(tHMMobj: list[tHMM], gammas: list[np.ndarray]) → np.ndarray

Calculates the M-step of the Baum Welch algorithm given output of the E step. Does the parameter estimation for the pi initial probability vector.

Parameters
  • tHMMobj (object) – A class object with properties of the lineages of cells

  • gammas – gamma values. The conditional probability of states, given the observation of the whole tree

lineage.BaumWelch.do_M_T_step(tHMMobj: list[tHMM], MSD: list[list[np.ndarray]], betas: list[list[np.ndarray]], gammas: list[list[np.ndarray]]) → np.ndarray

Calculates the M-step of the Baum Welch algorithm given output of the E step. Does the parameter estimation for the T Markov stochastic transition matrix.

Parameters
  • tHMMobj (list of tHMMobj s) – A class object with properties of the lineages of cells

  • MSD – The marginal state distribution P(z_n = k)

  • betas – beta values. The conditional probability of states, given observations of the sub-tree rooted in cell_n

  • gammas – gamma values. The conditional probability of states, given the observation of the whole tree

lineage.BaumWelch.do_M_E_step(tHMMobj: tHMM, gammas: list[np.ndarray])

Calculates the M-step of the Baum Welch algorithm given output of the E step. Does the parameter estimation for the E Emissions matrix (state probabilistic distributions).

Parameters
  • tHMMobj (object) – A class object with properties of the lineages of cells

  • gammas – gamma values. The conditional probability of states, given the observation of the whole tree

lineage.BaumWelch.do_M_E_step_atonce(all_tHMMobj: list[tHMM], all_gammas: list[list[np.ndarray]])

Performs the maximization step for emission estimation when data for all the concentrations are given at once for all the states. After reshaping, we will have a list of lists for each state. This function is specifically written for the experimental data of G1 and S-G2 cell cycle fates and durations.