cellrank.tl.kernels.PalantirKernel

class cellrank.tl.kernels.PalantirKernel(adata, backward=False, time_key='dpt_pseudotime', compute_cond_num=False, check_connectivity=False)[source]

Kernel which computes transition probabilities in a similar way to Palantir, see [Setty19].

Palantir computes a KNN graph in gene expression space and a pseudotime, which it then uses to direct the edges of the KNN graph, such that they are more likely to point into the direction of increasing pseudotime. To avoid disconnecting the graph, it does not remove all edges that point into the direction of decreasing pseudotime but keeps the ones that point to nodes inside a close radius. This radius is chosen according to the local density.

The implementation presented here won’t exactly reproduce the original Palantir algorithm (see below) but the results are qualitatively very similar.

Optionally, we apply a density correction as described in [Coifman05], where we use the implementation of [Haghverdi16].

Parameters
  • adata (anndata.AnnData) – Annotated data object.

  • backward (bool) – Direction of the process.

  • time_key (str) – Key in adata .obs where the pseudotime is stored.

  • compute_cond_num (bool) – Whether to compute condition number of the transition matrix. Note that this might be costly, since it does not use sparse implementation.

Attributes

adata

Annotated data object.

backward

Direction of the process.

condition_number

Condition number of the transition matrix.

kernels

Get the kernels of the kernel expression, except for constants.

params

Parameters which are used to compute the transition matrix.

pseudotime

Pseudotemporal ordering of cells.

transition_matrix

Return row-normalized transition matrix.

Methods

compute_transition_matrix([k, density_normalize])

Compute transition matrix based on KNN graph and pseudotemporal ordering.

copy()

Return a copy of self.

read(fname)

Deserialize self from a file.

write(fname[, ext])

Serialize self to a file.

write_to_adata([key])

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