gene.relative.velocity.estimates: Estimate RNA velocity using gene-relative slopes

Description Usage Arguments Value Examples

View source: R/momentum_routines.R

Description

Estimate RNA velocity using gene-relative slopes

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
gene.relative.velocity.estimates(
  emat,
  nmat,
  deltaT = 1,
  smat = NULL,
  steady.state.cells = colnames(emat),
  kCells = 10,
  cellKNN = NULL,
  kGenes = 1,
  old.fit = NULL,
  mult = 1000,
  min.nmat.smat.correlation = 0.05,
  min.nmat.emat.correlation = 0.05,
  min.nmat.emat.slope = 0.05,
  zero.offset = FALSE,
  deltaT2 = 1,
  fit.quantile = NULL,
  diagonal.quantiles = FALSE,
  show.gene = NULL,
  do.par = TRUE,
  cell.dist = NULL,
  emat.size = NULL,
  nmat.size = NULL,
  cell.emb = NULL,
  cell.colors = NULL,
  expression.gradient = NULL,
  residual.gradient = NULL,
  K = 0.5,
  N = 1,
  n.cores = defaultNCores(),
  verbose = TRUE
)

Arguments

emat

- spliced (exonic) count matrix

nmat

- unspliced (nascent) count matrix

deltaT

- amount of time to project the cell forward

smat

- optional spanning read matrix (used in offset calculations)

steady.state.cells

- optional set of steady-state cells on which the gamma should be estimated (defaults to all cells)

kCells

- number of k nearest neighbors (NN) to use in slope calculation smoothing

cellKNN

- optional pre-calculated cell KNN matrix

kGenes

- number of genes (k) to use in gene kNN pooling

old.fit

- optional old result (in this case the slopes and offsets won't be recalculated, and the same kNN graphs will be used)

mult

- library scaling factor (1e6 in case of FPM)

min.nmat.smat.correlation

- minimum required Spearman rank correlation between n and s counts of a gene

min.nmat.emat.correlation

- minimum required Spearman rank correlation between n and e counts of a gene

min.nmat.emat.slope

- minimum sloope of n~e regression

zero.offset

- should offset be set to zero, or determined (through smat regression or using near-0 e cases)

deltaT2

- scaling of the projected difference vector (normally should be set to 1)

fit.quantile

perform gamma fit on a top/bottom quantiles of expression magnitudes

diagonal.quantiles

whether extreme quantiles should be computed diagonally

show.gene

an optional name of a gene for which the velocity estimation details should be shown (instead of estimating all velocities)

do.par

whether the graphical device parameters should be reset as part of show.gene (default=TRUE)

cell.dist

- cell distance to use in cell kNN pooling calculations

emat.size

- pre-calculated cell sizes for the emat (spliced) matrix

nmat.size

- pre-calculated cell sizes for the nmat (unspliced) matrix

cell.emb

- cell embedding to be used in show.gene function

cell.colors

- cell colors to be used in show.gene function

expression.gradient

- color palette used to show the expression magnitudes in show.gene function

residual.gradient

- color palette used to show the u residuals in show.gene function

K

- a constant in the Hill function

N

- Hill coefficient in modeling the nonlinear relationship

n.cores

- number of cores to use

verbose

- output messages about progress

Value

a list with velocity results, including the current normalized expression state ($current), projected ($projected) over a certain time ($deltaT), unscaled transcriptional change ($deltaE), fit results ($gamma, $ko, $sfit if spanning reads were used), optional cell pooling parameters ($cellKNN, $kCells), kNN-convolved normalized matrices (conv.nmat.norm and conv.emat.norm), library scale ($mult)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## Not run: 
 # use min/max quantile gamma fit (recommended option when one can afford to do cell kNN smoothing)
 # The example below uses k=5 cell kNN pooling, and top/bottom 2% exprssion quantiles
 # emat and nmat are spliced (exonic) and unspliced (intronic) molecule/read count matirces
(preferably filtered for informative genes)
 rvel <- gene.relative.velocity.estimates(emat,nmat,deltaT=1,kCells = 5,fit.quantile = 0.02)

 # alternativly, the function can be used to visualize gamma fit and regression for a
particular gene. here we pass embedding (a matrix/data frame with rows named with cell names,
and columns corresponding to the x/y coordinates)

 # and cell colors. old.fit is used to save calculation time.
 gene.relative.velocity.estimates(emat,nmat,deltaT=1,kCells = 5,fit.quantile = 0.02,
    old.fit=rvel,show.gene='Chga',cell.emb=emb,cell.colors=cell.colors)

## End(Not run)

sqjin/nlvelo documentation built on Feb. 11, 2021, 8:09 a.m.