lineage.LineageTree

This file contains the LineageTree class.

Classes

LineageTree

A class for lineage trees. This class also handles algorithms for walking

Functions

get_Emission_Likelihoods(X, E)

Emission Likelihood (EL) matrix.

lineage_to_tree(lineage)

Build a directed adjacency CSR array (parent -> daughter) from a lineage.

Module Contents

class lineage.LineageTree.LineageTree(list_of_cells, E, obs=None, states=None)

A class for lineage trees. This class also handles algorithms for walking the tree to calculate various properties.

Parameters:
pi: numpy.typing.NDArray[numpy.float64]
T: numpy.typing.NDArray[numpy.float64]
leaves_idx: numpy.ndarray
_output_lineage: list[lineage.CellVar.CellVar] | None
obs: numpy.ndarray
tree: scipy.sparse.csr_array
states: numpy.ndarray
E: collections.abc.Sequence[lineage.states.StateDistributionGamma.StateDistribution | lineage.states.StateDistributionGaPhs.StateDistribution | lineage.states.StateDistributionCR.StateDistributionPhase]
property output_lineage: list[lineage.CellVar.CellVar]

Backwards compatibility property constructing CellVar list from arrays.

Return type:

list[lineage.CellVar.CellVar]

_build_cellvar_list()
Return type:

list[lineage.CellVar.CellVar]

property non_leaves_idx: numpy.ndarray

Return array of non-leaf cell indices.

Return type:

numpy.ndarray

property edges: tuple[numpy.ndarray, numpy.ndarray]

Return (parents, daughters) edge arrays.

Return type:

tuple[numpy.ndarray, numpy.ndarray]

property cell_to_daughters: numpy.ndarray

Compatibility helper returning (N, 2) array of daughter indices.

Return type:

numpy.ndarray

classmethod rand_init(pi, T, E, desired_num_cells, censor_condition=0, desired_experiment_time=2000000000000.0, rng=None)

Constructor method generating pure array representation.

:param \(\pi\): The initial probability matrix. :param T: The transition probability matrix. :param E: A list containing state distribution objects. :param desired_num_cells: The desired number of cells. :param censor_condition: An integer in {0, 1, 2, 3} deciding censoring type.

Parameters:
__len__()

Defines the length of a lineage by returning the number of cells it contains.

lineage.LineageTree.get_Emission_Likelihoods(X, E)

Emission Likelihood (EL) matrix.

Each element in this N by K matrix represents the probability

\(P(x_n = x | z_n = k)\),

for all \(x_n\) and \(z_n\) in our observed and hidden state tree and for all possible discrete states k. :param X: list of lineage trees :param E: The emissions likelihood :return: The marginal state distribution

Parameters:
Return type:

list[numpy.ndarray]

lineage.LineageTree.lineage_to_tree(lineage)

Build a directed adjacency CSR array (parent -> daughter) from a lineage.

Parameters:

lineage (list[lineage.CellVar.CellVar])

Return type:

scipy.sparse.csr_array