Skip to contents

Project the velocity vector for each cell onto an existing low-dimensional embedding.

Usage

embedVelocity(x, vobj, ...)

# S4 method for class 'ANY'
embedVelocity(x, vobj, ...)

# S4 method for class 'SingleCellExperiment'
embedVelocity(x, vobj, ..., use.dimred = 1)

Arguments

x

A numeric matrix of low-dimensional coordinates, e.g., after t-SNE. Alternatively, a SingleCellExperiment containing such coordinates in its reducedDims.

vobj

A SingleCellExperiment containing the output of the velocity calculations, typically after running scvelo.

...

For the generic, further arguments to pass to specific methods.

For the ANY method, further arguments to pass to the velocity_embedding Python function from scVelo.

For the SingleCellExperiment method, further arguments to pass to the ANY method.

use.dimred

String or integer scalar specifying the reduced dimensions to retrieve from x.

Value

A numeric matrix of the same dimensions as x, containing the projected velocity vectors in that embedding.

Details

This is a simple wrapper around the scvelo.tools.velocity_embedding function. Briefly, we construct a cell-cell transition matrix where a cell is more likely to transition to one of its neighbors if its velocity vector is pointing in the same direction as that neighbor. The resulting matrix is then used to compute a weighted average of the positions in x, allowing us to compute a velocity in the low-dimensional embedding.

Author

Aaron Lun

Examples

example(scvelo, echo=FALSE) # recycling that example.
#> Loading required package: SingleCellExperiment

# Making up a new embedding.
tsne.results <- matrix(rnorm(2*ncol(out)), ncol=2)

# Projecting the future state of each cell:
projected <- embedVelocity(tsne.results, out)
#>  Using the 'X' assay as the X matrix