cellrank.tl.kernels.PrecomputedKernel

class cellrank.tl.kernels.PrecomputedKernel(object, adata=None, obsp_key=None, **kwargs)[source]

Kernel which contains a precomputed transition matrix.

Parameters
  • object (Union[str, bool, ndarray, spmatrix, AnnData, KernelExpression]) –

    Can be one of the following types:

    • anndata.AnnData - annotated data object.

    • scipy.sparse.spmatrix, numpy.ndarray - row-normalized transition matrix.

    • cellrank.tl.kernels.KernelExpression - kernel expression.

    • str - key in anndata.AnnData.obsp where the transition matrix is stored. adata must be provided in this case.

    • bool - directionality of the transition matrix that will be used to infer its storage location. If None, the directionality will be determined automatically. adata must be provided in this case.

  • adata (anndata.AnnData) – Annotated data object. Must be provided when object is str or bool.

  • obsp_key (Optional[str]) – Key in anndata.AnnData.obsp where the transition matrix is stored. If None, it will be determined automatically. Only used when object is anndata.AnnData.

  • copy – Whether or not to copy the stored transition matrix.

  • backward – Hint whether this is a forward, backward or a unidirectional kernel. Only used when object is anndata.AnnData.

Attributes

adata

Annotated data object.

backward

Direction of the process.

kernels

Underlying base kernels.

params

Parameters which are used to compute the transition matrix.

shape

(n_cells, n_cells).

transition_matrix

Row-normalized transition matrix.

Methods

compute_transition_matrix(*_, **__)

Do nothing and return self.

copy(*[, deep])

Return a copy of itself.

plot_projection([basis, key_added, ...])

Plot transition_matrix as a stream or a grid plot.

plot_random_walks([n_sims, max_iter, seed, ...])

Plot random walks in an embedding.

plot_single_flow(cluster, cluster_key, time_key)

Visualize outgoing flow from a cluster of cells [Mittnenzweig et al., 2021].

read(fname[, adata, copy])

Deserialize self from a file.

write(fname[, write_adata, ext])

Serialize self to a file.

write_to_adata([key, copy])

Write the transition matrix and parameters used for computation to the underlying adata object.