lineage.BaumWelch
Re-calculates the tHMM parameters of pi, T, and emissions using Baum Welch.
Functions
|
Calculate MSD, EL, NF, gamma, beta, LL from tHMM model. |
Calculates log likelihood of NF for each lineage. |
|
Calculate the stationary distribution of states from T. |
|
|
Calculates the maximization step of the Baum Welch algorithm |
|
Calculates the M-step of the Baum Welch algorithm |
|
Calculates the M-step of the Baum Welch algorithm |
|
Calculates the M-step of the Baum Welch algorithm |
|
Performs the maximization step for emission estimation when data for all the concentrations are given at once for all the states. |
Module Contents
- lineage.BaumWelch.do_E_step(tHMMobj)
Calculate MSD, EL, NF, gamma, beta, LL from tHMM model.
- Parameters:
tHMMobj (lineage.tHMM.tHMM) -- A tHMM object with properties of the lineages of cells.
- 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)
- Return type:
tuple[list, list, list, list]
- lineage.BaumWelch.calculate_log_likelihood(NF)
Calculates log likelihood of NF for each lineage.
- Parameters:
NF (list[numpy.ndarray] | list[list[numpy.ndarray]] | list[Any]) -- list of normalizing factors
- Returns:
the sum of log likelihoods for each lineage
- Return type:
float
- lineage.BaumWelch.calculate_stationary(T)
Calculate the stationary distribution of states from T. Note that this does not take into account potential influences of the emissions.
- Parameters:
T (numpy.ndarray) -- 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
- Return type:
numpy.ndarray
- lineage.BaumWelch.do_M_step(tHMMobj, MSD, betas, gammas)
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 (list) -- The marginal state distribution P(z_n = k)
betas (list) -- beta values. The conditional probability of states, given observations of the sub-tree rooted in cell_n
gammas (list) -- gamma values. The conditional probability of states, given the observation of the whole tree
- lineage.BaumWelch.do_M_pi_step(tHMMobj, gammas)
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 (list[numpy.ndarray]) -- gamma values. The conditional probability of states, given the observation of the whole tree
- Return type:
numpy.ndarray
- lineage.BaumWelch.do_M_T_step(tHMMobj, MSD, betas, gammas)
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 (list[list[numpy.ndarray]]) -- The marginal state distribution P(z_n = k)
betas (list[list[numpy.ndarray]]) -- beta values. The conditional probability of states, given observations of the sub-tree rooted in cell_n
gammas (list[list[numpy.ndarray]]) -- gamma values. The conditional probability of states, given the observation of the whole tree
- Return type:
numpy.ndarray
- lineage.BaumWelch.do_M_E_step(tHMMobj, gammas)
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 (list[numpy.ndarray]) -- gamma values. The conditional probability of states, given the observation of the whole tree
- lineage.BaumWelch.do_M_E_step_atonce(all_tHMMobj, all_gammas)
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.
- Parameters:
all_tHMMobj (list[lineage.tHMM.tHMM])
all_gammas (list[list[numpy.ndarray]])