lineage.Viterbi
¶
This file contains the methods for the Viterbi algorithm implemented in an a upward recursion.
Module Contents¶
-
lineage.Viterbi.
get_deltas
(X: list, E: list, T: np.ndarray) → Tuple[list[np.ndarray], list]¶ Delta matrix and base case at the leaves. Each element in this N by K matrix is the probability for the leaves \(P(x_n = x | z_n = k)\).
Then calculates delta values for non-leaf cells by filling out the delta matrix.
- Parameters
tHMMobj – the tHMM object
- Returns
a list of N by K matrices for each lineage, initialized from the leaf cells by EL(n,k).
-
lineage.Viterbi.
get_delta_parent_child_prod
(linObj, delta_array: np.ndarray, T: np.ndarray, node_parent_m_idx: int) → Tuple[np.ndarray, list]¶ Calculates the delta coefficient for every parent-child relationship of a given parent cell in a given state. In these set of functions state pointer is an array of size K, that holds the state number with the highest probability in each row of the max_holder. max_holder is a matrix of size K x K that initially starts from T, and gets updated. delta_m_n_holder is a vector of size K that has the highest of those probabilities.
- Parameters
lineage – A list containing cells (which are objects with their own properties).
delta_array – A N by K matrix containing the delta values that will be used in Viterbi.
T – The K by K transition matrix.
node_parent_m_index – The index of the parent to the currently-intended-cell.
- Return delta_m_n_holder
A list to hold the factors in the product.
- Return max_state_ptr
A list of tuples of daughter cell indexes and their state pointers.
-
lineage.Viterbi.
Viterbi
(tHMMobj) → list[np.ndarray]¶ Runs the viterbi algorithm and returns a list of arrays containing the optimal state of each cell. This function returns the most likely sequence of states for each lineage.
- Parameters
tHMMobj – a class object with properties of the lineages of cells
deltas – a list of N by K matrices containing the delta values for each lineage
state_ptrs – a list of tuples of daughter cell indexes and their state pointers
- Returns
assigned states to each cell in all lineages