mira.time.get_tree_structure#

mira.time.get_tree_structure(adata, cellrank=False, pseudotime_key='mira_pseudotime', branch_probs_key='branch_probs', lineage_names_key='lineage_names', start_cell=None, threshold=0.1)#

Parse tree structure from terminal state probabilities.

Parameters
adataanndata.AnnData

Adata with a transition matrix in .obsp[“transport_map”] and branch probabilities in .obsm[“branch_probs”].

thresholdfloat > 0, default = 0.1

Treshold to exceed to indicate divergence of lineages. Higher thresholds allow more tolerance before a branch point is assigned, while lower thresholds are more sensitive to divergence events. Try multiple values for threshold to find best value to parse lineage tree. Typically, 0.1 is a very sensitive value, while 1.0-2.0 are very tolerant.

cellrankboolean, default=False

If using cellrank to assign terminal states and lineage probabilities, set this option to True.

start_cellint or barcode, default=None

Cell representing start state of differentiation. Only needed if cellrank is True.

Returns
adataanndata.AnnData
`.obs[“tree_states”]np.ndarray[str] of shape (n_cells,)

“tree_states” columns indicate which lineages are downstream for each cell. For instance, given a bifurcating differentitation into terminal lineages A and B, all cells before the branch point would be labeled “A, B”, while cells after the branch point would be labeled “B” if they followed the path to the “B” terminal state.

`.uns[“connectivities_tree”]np.ndarray[boolean] of shape

(2*num_lineages - 1, 2*num_lineages - 1). Digraph of relationships between tree_states. For instance, an edge would be drawn from “A, B” to “A” and to “B”.

        "A"
    /   
"A, B"
    \__"B"
`.uns[“tree_state_names”]np.ndarray[str] of shape (2*num_lineages - 1,)

Tree state labels for columns and rows of connectivities_tree

Examples

>>> mira.time.get_tree_structure(data, threshold = 1)
>>> sc.pl.umap(data, color = 'tree_states', palette = 'Set2', 
...   **umap_kwargs, title = '', legend_loc='on data')
../_images/mira.time.get_tree_structure.png

Note

This function is part of the mira.time API and works with several others to help users understand lineage structures and dynamic processes in their data. Please refer to the pseudotime trajectory inference tutorial.