scvelo.tl.velocity_graph

scvelo.tl.velocity_graph(data, vkey='velocity', xkey='Ms', tkey=None, basis=None, n_neighbors=None, n_recurse_neighbors=None, random_neighbors_at_max=None, sqrt_transform=None, variance_stabilization=None, gene_subset=None, compute_uncertainties=None, approx=None, mode_neighbors='distances', copy=False, n_jobs=None, backend='loky')

Computes velocity graph based on cosine similarities.

The cosine similarities are computed between velocities and potential cell state transitions, i.e. it measures how well a corresponding change in gene expression \(\delta_{ij} = x_j - x_i\) matches the predicted change according to the velocity vector \(\nu_i\),

\[\pi_{ij} = \cos\angle(\delta_{ij}, \nu_i) = \frac{\delta_{ij}^T \nu_i}{\left\lVert\delta_{ij}\right\rVert \left\lVert \nu_i \right\rVert}.\]
data: AnnData

Annotated data matrix.

vkey: str (default: ‘velocity’)

Name of velocity estimates to be used.

xkey: str (default: ‘Ms’)

Layer key to extract count data from.

tkey: str (default: None)

Observation key to extract time data from.

basis: str (default: None)

Basis / Embedding to use.

n_neighbors: int or None (default: None)

Use fixed number of neighbors or do recursive neighbor search (if None).

n_recurse_neighbors: int (default: None)

Number of recursions for neighbors search. Defaults to 2 if mode_neighbors is ‘distances’, and 1 if mode_neighbors is ‘connectivities’.

random_neighbors_at_max: int or None (default: None)

If number of iterative neighbors for an individual cell is higher than this threshold, a random selection of such are chosen as reference neighbors.

sqrt_transform: bool (default: False)

Whether to variance-transform the cell states changes and velocities before computing cosine similarities.

gene_subset: list of str, subset of adata.var_names or None`(default: `None)

Subset of genes to compute velocity graph on exclusively.

compute_uncertainties: bool (default: None)

Whether to compute uncertainties along with cosine correlation.

approx: bool or None (default: None)

If True, first 30 pc’s are used instead of the full count matrix

mode_neighbors: ‘str’ (default: ‘distances’)

Determines the type of KNN graph used. Options are ‘distances’ or ‘connectivities’. The latter yields a symmetric graph.

copy: bool (default: False)

Return a copy instead of writing to adata.

n_jobs: int or None (default: None)

Number of parallel jobs.

backend: str (default: “loky”)

Backend used for multiprocessing. See joblib.Parallel for valid options.

Returns

velocity_graph (.uns) – sparse matrix with correlations of cell state transitions with velocities