scvelo.tl.velocity

scvelo.tl.velocity(data, vkey='velocity', mode='stochastic', fit_offset=False, fit_offset2=False, filter_genes=False, groups=None, groupby=None, groups_for_fit=None, constrain_ratio=None, use_raw=False, use_latent_time=None, perc=[5, 95], min_r2=0.01, min_likelihood=0.001, r2_adjusted=None, copy=False, **kwargs)

Estimates velocities in a gene-specific manner

Parameters:
data : AnnData

Annotated data matrix.

vkey : str (default: ‘velocity’)

Name under which to refer to the computed velocities for velocity_graph and velocity_embedding.

mode : ‘steady_state’, ‘deterministic’, ‘stochastic’ or ‘dynamical’ (default: ‘stochastic’)

Whether to run the estimation using the deterministic or stochastic model of transcriptional dynamics. The ‘steady_state’ model is default and refers to the deterministic model. The dynamical model requires to run tl.recover_dynamics first; it is yet under development.

fit_offset : bool (default: False)

Whether to fit with offset for first order moment dynamics.

fit_offset2 : bool, (default: False)

Whether to fit with offset for second order moment dynamics.

filter_genes : bool (default: True)

Whether to remove genes that are not used for further velocity analysis.

groups : str, list (default: None)

Subset of groups, e.g. [‘g1’, ‘g2’, ‘g3’], to which velocity analysis shall be restricted.

groupby : str, list or np.ndarray (default: None)

Key of observations grouping to consider.

groups_for_fit : str, list or np.ndarray (default: None)

Subset of groups, e.g. [‘g1’, ‘g2’, ‘g3’], to which steady-state fitting shall be restricted.

constrain_ratio : float or tuple of type float or None: (default: None)

Bounds for the steady-state ratio gamma’.

use_raw : bool (default: False)

Whether to use raw data for estimation.

use_latent_time : bool`or `None (default: `None)

Whether to use latent time as a regularization for velocity when using dynamical mode.

perc : float (default: None)

Percentile, e.g. 98, upon for extreme quantile fit (to better capture steady states for velocity estimation).

min_r2 : float (default: 0.01)

Minimum threshold for coefficient of determination

min_likelihood : float (default: None)

Minimal likelihood for velocity genes to fit the model on.

r2_adjusted : bool (default: None)

Whether to compute coefficient of determination on full data fit (adjusted) or extreme quantile fit (None)

copy : bool (default: False)

Return a copy instead of writing to adata.

Returns:

  • Returns or updates adata with the attributes
  • velocity (.layers) – velocity vectors for each individual cell
  • variance_velocity (.layers) – velocity vectors for the cell variances
  • velocity_offset, velocity_beta, velocity_gamma, velocity_r2 (.var) – parameters