lineage.HMM.E_step
Functions
|
Marginal State Distribution (MSD) matrix by upward recursion. |
|
Normalizing factor (NF) matrix and base case at the leaves. |
|
Get the gammas using downward recursion from the root nodes. |
Module Contents
- lineage.HMM.E_step.get_MSD(tree, pi, T)
Marginal State Distribution (MSD) matrix by upward recursion. This is the probability that a hidden state variable \(z_n\) is of state k, that is, each value in the N by K MSD array for each lineage is the probability
\(P(z_n = k)\),
for all \(z_n\) in the hidden state tree and for all k in the total number of discrete states. Each MSD array is an N by K array (an entry for each cell and an entry for each state), and each lineage has its own MSD array.
Every element in MSD matrix is essentially sum over all transitions from any state to state j (from parent to daughter):
\(P(z_u = k) = \sum_j(Transition(j -> k) * P(parent_{cell_u}) = j)\)
- Parameters:
tree (scipy.sparse.csr_array) -- CSR array representing the lineage tree adjacency
pi (numpy.typing.NDArray[numpy.float64]) -- Initial probabilities vector
T (numpy.typing.NDArray[numpy.float64]) -- State transitions matrix
- Returns:
The marginal state distribution
- Return type:
numpy.typing.NDArray[numpy.float64]
- lineage.HMM.E_step.get_beta_and_NF(leaves_idx, tree, T, MSD, EL)
Normalizing factor (NF) matrix and base case at the leaves.
Each element in this N by 1 matrix is the normalizing factor for each beta value calculation for each node. This normalizing factor is essentially the marginal observation distribution for a node.
- Parameters:
leaves_idx (numpy.ndarray) -- array of indices corresponding to leaf cells
tree (scipy.sparse.csr_array) -- CSR array representing the lineage tree adjacency
T (numpy.ndarray) -- Transition probability matrix
MSD (numpy.ndarray) -- The marginal state distribution P(z_n = k)
EL (numpy.ndarray) -- The emissions likelihood
- Returns:
normalizing factor. The marginal observation distribution P(x_n = x)
- Returns:
beta values. The conditional probability of states, given observations of the sub-tree rooted in cell_n
- Return type:
tuple[numpy.ndarray, numpy.ndarray]
- lineage.HMM.E_step.get_gamma(tree, T, MSD, beta)
Get the gammas using downward recursion from the root nodes. The conditional probability of states, given observation of the whole tree P(z_n = k | X_bar = x_bar) x_bar is the observations for the whole tree.
- Parameters:
tree (scipy.sparse.csr_array) -- CSR array representing the lineage tree adjacency
T (numpy.typing.NDArray[numpy.float64]) -- State transitions matrix
MSD (numpy.typing.NDArray[numpy.float64]) -- The marginal state distribution P(z_n = k)
beta (numpy.typing.NDArray[numpy.float64]) -- beta values. The conditional probability of states, given observations of the sub-tree rooted in cell_n
- Return type:
numpy.typing.NDArray[numpy.float64]