dynamo.tl.score_cells

dynamo.tl.score_cells(adata, genes=None, layer=None, basis=None, n_neighbors=30, beta=0.1, iteration=5, metric='euclidean', metric_kwds=None, cores=1, seed=19491001, return_score=True, **kwargs)[source]

Score cells based on a set of genes.

Parameters:
  • adata (AnnData) – An AnnData object that contains the reconstructed vector field function in the uns attribute.

  • genes (Optional[List[str]]) – The gene names whose gene expression will be used for predicting cell fate. By default (when genes is set to None), the genes used for velocity embedding (var.use_for_transition) will be used for vector field reconstruction. Note that the genes to be used need to have velocity calculated and corresponds to those used in the dyn.tl.VectorField function. Defaults to None.

  • layer (Optional[str]) – Which layer of the data will be used for predicting cell fate with the reconstructed vector field function. The layer once provided, will override the basis argument and then predicting cell fate in high dimensional space. Defaults to None.

  • basis (Optional[str]) – The embedding data to use for predicting cell fate. If basis is either umap or pca, the reconstructed trajectory will be projected back to high dimensional space via the inverse_transform function. Defaults to None.

  • n_neighbors (int) – Number of nearest neighbors. Defaults to 30.

  • beta (float) – The weight that will apply to the current query cell. Defaults to 0.1.

  • iteration (int) – Number of smooth iterations. Defaults to 5.

  • metric (Union[str, Callable]) – The distance metric to use for the tree. The default metric is , and with p=2 is equivalent to the standard Euclidean metric. See the documentation of DistanceMetric for a list of available metrics. If metric is “precomputed”, X is assumed to be a distance matrix and must be square during fit. X may be a sparse graph, in which case only “nonzero” elements may be considered neighbors. Defaults to “euclidean”.

  • metric_kwds (Optional[Dict[str, Any]]) – Additional keyword arguments for the metric function. Defaults to None.

  • cores (int) – The number of parallel jobs to run for neighbors search. None means 1 unless in a joblib.parallel_backend context. -1 means using all processors. Defaults to 1.

  • seed (int) – Random seed to ensure the reproducibility of each run. Defaults to 19491001.

  • return_score (bool) – Whether to return the score. If False, save the smoothed score to cell_scores column in the .obs attribute and also to the dictionary corresponding to the score_cells key in the .uns attribute. Defaults to True.

Raises:
  • ValueErrorX_pca unavailable in .obsm.

  • ValueErrorbasis not available in .obsm.

  • ValueErrorgenes not provided and no “use_for_pca” in .obs.

  • ValueError – Input genes have no overlap with genes in the AnnData object.

Return type:

Optional[ndarray]

Returns:

The calculated cell scores if return score is true, otherwise the scores would be updated as annotations of the AnnData object inplace.