pygot.tools.analysis.CellFate#

class pygot.tools.analysis.CellFate[source]#

Bases: object

Cell fate prediction based on the markov chain.

\[\begin{split}r = \frac{1}{|C_k|}\sum_{i \in C_k}{R_{\dot, i}} \\ P = (I - Q)^{-1} r \\\end{split}\]

where \(R\) represents non-target cells to target cells transition matrix, \(C_k\) is the set of target cell type k. Besides, \(Q\) is the transition matrix from the non-target cells to the non-target cells, and \(I\) is the identity matrix. The final solution is \(P\), which represents the absorbing probabilities for the target cell type.

Example:#

cf = pygot.tl.analysis.CellFate()
cf.fit(adata, embedding_key='X_pca', velocity_key='velocity_pca', cell_type_key='clusters', target_cell_types=['Beta', 'Alpha', 'Delta', 'Epsilon'])
adata.obs[adata.obsm['descendant'].columns] = adata.obsm['descendant']
sc.pl.umap(adata, color=adata.obsm['descendant'].columns, ncols=2)
__init__()[source]#

Methods

__init__()

fit(adata, embedding_key, velocity_key, ...)

fit the cell fate prediction model and export the result into adata.obsm['descendant'] and adata.obsm['ancestor']

get_cluster_transition_map([pvalue, max_cutoff])

Get the cluster transition map based on the cell fate prediction model.

fit(adata, embedding_key, velocity_key, cell_type_key, target_cell_types=None, target_cell_idx=None, n_neighbors=30, mutual=True, sde=True, D=1.0)[source]#

fit the cell fate prediction model and export the result into adata.obsm[‘descendant’] and adata.obsm[‘ancestor’]

Arguments:#

adata: anndata.AnnData

AnnData object

embedding_key: str

The key of the embedding in adata.obsm

velocity_key: str

The key of the velocity in adata.obsm

cell_type_key: str

The key of the cell type in adata.obs

target_cell_types: list (default: None)

The list of target cell types

target_cell_idx: list (default: None)

The list of target cell indices

n_neighbors: int (default: 30)

The number of neighbors for the nearest neighbors graph

mutual: bool (default: True)

Whether to use mutual nearest neighbors graph. Might isolate some cells if set to True

sde: bool (default: True)

Whether to use inner product kernel or cosine kernel

D: float (default: 1.)

The diffusion factor. Larger D means larger diffusion.

get_cluster_transition_map(pvalue=0.001, max_cutoff=0.45)[source]#

Get the cluster transition map based on the cell fate prediction model.

Arguments:#

pvalue: float (default: 1e-3)

The pvalue cutoff for the cluster transition map

max_cutoff: float (default: 0.45)

The maximum cutoff for the cluster transition map