Contents Menu Expand Light mode Dark mode Auto light/dark mode
CellRank 1.5.1 documentation
Logo

General

  • Installation
  • API
    • Kernels
      • cellrank.kernels.VelocityKernel
      • cellrank.kernels.ConnectivityKernel
      • cellrank.kernels.PseudotimeKernel
      • cellrank.kernels.CytoTRACEKernel
      • cellrank.kernels.PrecomputedKernel
      • cellrank.external.kernels.StationaryOTKernel
      • cellrank.external.kernels.WOTKernel
    • Estimators
      • cellrank.estimators.GPCCA
      • cellrank.estimators.CFLARE
    • Models
      • cellrank.models.GAM
      • cellrank.models.GAMR
      • cellrank.models.SKLearnModel
    • Plotting
      • cellrank.pl.circular_projection
      • cellrank.pl.gene_trends
      • cellrank.pl.log_odds
      • cellrank.pl.heatmap
      • cellrank.pl.cluster_trends
      • cellrank.pl.aggregate_absorption_probabilities
    • Datasets
      • cellrank.datasets.pancreas
      • cellrank.datasets.lung
      • cellrank.datasets.reprogramming_morris
      • cellrank.datasets.reprogramming_schiebinger
      • cellrank.datasets.zebrafish
      • cellrank.datasets.pancreas_preprocessed
      • cellrank.datasets.bone_marrow
    • Developer API
  • Release Notes
    • CellRank dev (2023-03-26)
    • CellRank 1.5.1 (2022-01-13)
    • CellRank 1.5.0 (2021-09-13)
    • CellRank 1.4.0 (2021-06-30)
    • CellRank 1.3.1 (2021-04-09)
    • CellRank 1.3.0 (2021-03-29)
    • CellRank 1.2.0 (2021-02-02)
    • CellRank 1.1.0 (2020-11-17)
    • CellRank 1.0.0 (2020-10-17)
  • Contributing guide
  • References

Gallery

  • Tutorials
    • CellRank basics
    • CellRank meets pseudotime
    • CellRank meets CytoTRACE
    • Creating a new kernel
  • Examples

About

  • About CellRank
  • How to cite us
  • Team
  • GitHub
  • Discourse
  v: latest
Versions
latest
stable
Downloads
html
On Read the Docs
Project Home
Builds
Back to top
Edit this page

cellrank.pl.cluster_trends#

cellrank.pl.cluster_trends(adata, model, genes, lineage, backward=False, time_range=None, clusters=None, n_points=200, time_key='latent_time', covariate_key=None, ratio=0.05, cmap='viridis', norm=True, recompute=False, callback=None, ncols=3, sharey=False, key=None, random_state=None, show_progress_bar=True, n_jobs=1, backend='loky', figsize=None, dpi=None, save=None, pca_kwargs=mappingproxy({'svd_solver': 'arpack'}), neighbors_kwargs=mappingproxy({'use_rep': 'X'}), clustering_kwargs=mappingproxy({}), return_models=False, **kwargs)[source]#

Cluster and plot gene expression trends within a lineage.

This function is based on Palantir [Setty et al., 2019]. It can be used to discover modules of genes that drive development along a given lineage. Consider running this function on a subset of genes which are potential lineage drivers.

Parameters:
  • adata (anndata.AnnData) – Annotated data object.

  • model (Union[BaseModel, Mapping[str, Mapping[str, BaseModel]]]) –

    Model based on cellrank.models.BaseModel to fit.

    If a dict, gene and lineage specific models can be specified. Use '*' to indicate all genes or lineages, for example {'gene_1': {'*': ...}, 'gene_2': {'lineage_1': ..., '*': ...}}.

  • genes (Sequence[str]) – Genes in anndata.AnnData.var_names or in anndata.AnnData.raw.var_names, if use_raw = True.

  • lineage (str) – Name of the lineage for which to cluster the genes.

  • backward (bool) – Direction of the process.

  • time_range (Union[float, Tuple[Optional[float], Optional[float]], None]) –

    Specify start and end times:

    • If a tuple, it specifies the minimum and maximum pseudotime. Both values can be None, in which case the minimum is the earliest pseudotime and the maximum is automatically determined.

    • If a float, it specifies the maximum pseudotime.

  • clusters (Optional[Sequence[str]]) – Cluster identifiers to plot. If None, all clusters will be considered. Useful when plotting previously computed clusters.

  • n_points (int) – Number of points used for prediction.

  • time_key (str) – Key in anndata.AnnData.obs where the pseudotime is stored.

  • covariate_key (Union[str, Sequence[str], None]) – Key(s) in anndata.AnnData.obs containing observations to be plotted at the bottom of each plot.

  • gene_symbols – Key in anndata.AnnData.var to use instead of anndata.AnnData.var_names.

  • ratio (float) – Height ratio of each covariate in covariate_key.

  • cmap (Optional[str]) – Colormap to use for continuous covariates in covariate_key.

  • norm (bool) – Whether to z-normalize each trend to have zero mean, unit variance.

  • recompute (bool) – If True, recompute the clustering, otherwise try to find already existing one.

  • callback (Union[Callable, Mapping[str, Mapping[str, Callable]], None]) – Function which takes a cellrank.models.BaseModel and some keyword arguments for cellrank.models.BaseModel.prepare() and returns the prepared model. Can be specified in gene- and lineage-specific manner, similarly to model.

  • ncols (int) – Number of columns for the plot.

  • sharey (Union[str, bool]) – Whether to share y-axis across multiple plots.

  • key (Optional[str]) – Key in anndata.AnnData.uns where to save the results. If None, it will be saved as 'lineage_{lineage}_trend' .

  • random_state (Optional[int]) – Random seed for reproducibility.

  • show_progress_bar (bool) – Whether to show a progress bar. Disabling it may slightly improve performance.

  • n_jobs (Optional[int]) – Number of parallel jobs. If -1, use all available cores. If None or 1, the execution is sequential.

  • backend (Literal['loky', 'multiprocessing', 'threading']) – Which backend to use for parallelization. See joblib.Parallel for valid options.

  • figsize (Optional[Tuple[float, float]]) – Size of the figure.

  • dpi (Optional[int]) – Dots per inch.

  • save (Union[str, Path, None]) – Filename where to save the plot.

  • pca_kwargs (Dict) – Keyword arguments for scanpy.pp.pca().

  • neighbors_kwargs (Dict) – Keyword arguments for scanpy.pp.neighbors().

  • clustering_kwargs (Dict) – Keyword arguments for scanpy.tl.leiden().

  • return_models (bool) – If True, return the fitted models for each gene in genes and lineage in lineages.

  • kwargs (Any) – Keyword arguments for cellrank.models.BaseModel.prepare().

Return type:

Optional[Mapping[str, Mapping[str, BaseModel]]]

Returns:

: None

If return_models = False, just plots the figure and optionally saves it based on save.

Dict[str, Dict[str, cellrank.models.BaseModel]]

Otherwise returns the fitted models as {'gene_1': {'lineage_1': <model_11>, ...}, ...}. Models which have failed will be instances of cellrank.models.FailedModel.

Also updates adata.uns with the following:

  • key or lineage_{lineage}_trend - an anndata.AnnData object of shape (n_genes, n_points) containing the clustered genes.

Next
cellrank.pl.aggregate_absorption_probabilities
Previous
cellrank.pl.heatmap
Copyright © 2023, Marius Lange, Michal Klein, Philipp Weiler
Made with Furo
On this page
  • cellrank.pl.cluster_trends
    • cluster_trends()