cellrank.tl.kernels.VelocityKernel.compute_transition_matrix
- VelocityKernel.compute_transition_matrix(mode=VelocityMode.DETERMINISTIC, backward_mode=BackwardMode.TRANSPOSE, scheme=Scheme.CORRELATION, softmax_scale=None, n_samples=1000, seed=None, check_irreducibility=False, **kwargs)[source]
Compute transition matrix based on velocity directions on the local manifold.
For each cell, infer transition probabilities based on the cell’s velocity-extrapolated cell state and the cell states of its K nearest neighbors.
- Parameters
mode (
Literal
[‘deterministic’, ‘stochastic’, ‘sampling’, ‘monte_carlo’]) –How to compute transition probabilities. Valid options are:
’deterministic’ - deterministic computation that doesn’t propagate uncertainty.
’monte_carlo’ - Monte Carlo average of randomly sampled velocity vectors.
’stochastic’ - second order approximation, only available when
jax
is installed.’sampling’ - sample 1 transition matrix from the velocity distribution.
backward_mode (
Literal
[‘transpose’, ‘negate’]) –Only matters if initialized as
backward
= True
. Valid options are:’transpose’ - compute transitions from neighboring cells \(j\) to cell \(i\).
’negate’ - negate the velocity vector.
softmax_scale (
Optional
[float
]) – Scaling parameter for the softmax. If None, it will be estimated using1 / median(correlations)
. The idea behind this is to scale the softmax to counter everything tending to orthogonality in high dimensions.scheme (
Union
[Literal
[‘dot_product’, ‘cosine’, ‘correlation’],Callable
]) –Similarity scheme between cells as described in [Li et al., 2021]. Can be one of the following:
’dot_product’ -
cellrank.tl.kernels.DotProductScheme
.’cosine’ -
cellrank.tl.kernels.CosineScheme
.’correlation’ -
cellrank.tl.kernels.CorrelationScheme
.
Alternatively, any function can be passed as long as it follows the signature of
cellrank.tl.kernels.SimilaritySchemeABC.__call__()
.n_samples (
int
) – Number of bootstrap samples whenmode = 'monte_carlo'
.seed (
Optional
[int
]) – Set the seed for random state when the method requiresn_samples
.check_irreducibility (
bool
) – Optional check for irreducibility of the final transition matrix.show_progress_bar – Whether to show a progress bar. Disabling it may slightly improve performance.
n_jobs – Number of parallel jobs. If -1, use all available cores. If None or 1, the execution is sequential.
backend – Which backend to use for parallelization. See
joblib.Parallel
for valid options.
- Return type
- Returns
Self and updates the following fields: