scvelo.pp.moments

scvelo.pp.moments(data, n_neighbors=30, n_pcs=None, mode='connectivities', method='umap', use_rep=None, copy=False)

Computes moments for velocity estimation.

First-/second-order moments are computed for each cell across its nearest neighbors, where the neighbor graph is obtained from euclidean distances in PCA space.

Parameters:
data : AnnData

Annotated data matrix.

n_neighbors : int (default: 30)

Number of neighbors to use.

n_pcs : int (default: None)

Number of principal components to use. If not specified, the full space is used of a pre-computed PCA, or 30 components are used when PCA is computed internally.

mode : ‘connectivities’ or ‘distances’ (default: ‘connectivities’)

Distance metric to use for moment computation.

method : {{‘umap’, ‘hnsw’, ‘sklearn’, None}} (default: ‘umap’)

Method to compute neighbors, only differs in runtime. Connectivities are computed with adaptive kernel width as proposed in Haghverdi et al. 2016 (https://doi.org/10.1038/nmeth.3971).

use_rep : None, ‘X’ or any key for .obsm (default: None)

Use the indicated representation. If None, the representation is chosen automatically: for .n_vars < 50, .X is used, otherwise ‘X_pca’ is used.

copy : bool (default: False)

Return a copy instead of writing to adata.

Returns:

  • Returns or updates adata with the attributes
  • Ms (.layers) – dense matrix with first order moments of spliced counts.
  • Mu (.layers) – dense matrix with first order moments of unspliced counts.