Skip to contents

fitTransitionModel fits transition models on the data using the python cellrank package.

Usage

fitTransitionModel(
  anndata_file,
  conda_env = "scicsr",
  mode = "pseudotime",
  pseudotime_key = "csr_pot",
  do_pca = TRUE,
  do_neighbors = TRUE
)

Arguments

anndata_file

filename pointing to the AnnData file.

conda_env

character, if not NULL this named conda environment is used to run CellRank. (Default: NULL, i.e. no conda environment will be used, the program assumes the python packages scanpy, scvelo and cellrank are installed in the local python)

mode

character, either 'pseudotime' (uses the cellrank 'PseudotimeKernel') or 'velocity' (cellrank 'VelocityKernel'). (Default: 'pseudotime')

pseudotime_key

character, column name which indicates the ranking to be used as pseudotime ordering of the cells. Not considered if mode is 'velocity'. (Default: 'csr_pot')

do_pca

Should principal component analysis (PCA) be re-computed on the data? (Default: TRUE)

do_neighbors

Should k-nearest neighbour (kNN) graph be re-computed on the data? (Default: TRUE)

Value

a list with three entries:

cellrank_obj

Python cellrank.tl.estimators.CFLARE object containing details of the fitted transition model

transition_matrix

The matrix holding cell-to-cell transition probability (i.e. cellrank_obj.transition_matrix), but converted into a dense matrix. This is the single-cell transition matrix for downstream uses.

CellID

a vector of cell identifiers in the order of each row/column of transition_matrix.

Details

fitTransitionModel currently implements either the velocity kernel in cellrank (i.e. uses RNA velocity information to fit transition probabilities) or the pseudotime kernel; a user-indicated column in the metadata will be used as pseudotime reference to fit transition probabiltiies. **NOTE:** In cases where the warning 'Biased KNN graph is disconnected' which will subsequently cause the fitTPT() function in the pipeline to falied with error, in our experience it is likely to be caused by subsetting the data prior to computing transitions. Try setting do_pca = FALSE will preserve the original PCA and avoid this error.