Skip to main content
Ctrl+K
cellrank - Home cellrank - Home

Getting started

  • Installation
  • Quickstart

Guides

  • Tutorials
    • General
      • Getting Started with CellRank
    • Kernels
      • CellRank Meets RNA Velocity
      • CellRank Meets Pseudotime
      • CellRank Meets CytoTRACE
      • CellRank Meets Experimental Time
    • Estimators
      • Computing Initial and Terminal States
      • Estimating Fate Probabilities and Driver Genes
      • Visualizing and Clustering Gene Expression Trends

Reference

  • API
    • Kernels
      • cellrank.kernels.VelocityKernel
      • cellrank.kernels.ConnectivityKernel
      • cellrank.kernels.PseudotimeKernel
      • cellrank.kernels.CytoTRACEKernel
      • cellrank.kernels.RealTimeKernel
      • cellrank.kernels.PrecomputedKernel
    • 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_fate_probabilities
    • Datasets
      • cellrank.datasets.pancreas
      • cellrank.datasets.lung
      • cellrank.datasets.reprogramming_morris
      • cellrank.datasets.reprogramming_schiebinger
      • cellrank.datasets.zebrafish
      • cellrank.datasets.bone_marrow
    • Developer API
  • About CellRank
  • Moving from v1 to v2

Project

  • Release Notes
  • Contributing guide
  • Citation
  • Bibliography
  • Team
  • GitHub
  • Discourse
  • API
  • Plotting
  • cellrank.pl.cluster_trends
  • GitHub
  • Discourse
  • scverse.org
  • Core
  • AnnData
  • decoupler
  • MuData
  • Muon
  • Pertpy
  • rapids-singlecell
  • Scanpy
  • Scirpy
  • scvi-tools
  • SnapATAC2
  • SpatialData
  • Squidpy
  • Ecosystem
  • AESTETIK
  • AlphaPeptTools
  • AmbiDose
  • annbatch
  • anndata for R
  • anndataR
  • annsel
  • AnnZarro
  • ATLAS
  • benGRN
  • bento-tools
  • biolord
  • cell2location
  • Cell_BLAST
  • CellAnnotator
  • CellCharter
  • CellMapper
  • CellOracle
  • CellphoneDB
  • CellRank
  • cellxgene
  • Cirrocumulus
  • clone2vec
  • cuspa
  • dandelion
  • delnx
  • DOTools_py
  • DoubletDetection
  • DRVI
  • dvp-io
  • dynamo-release
  • epiScanpy
  • eschr
  • fava
  • flashdeconv
  • flowsom
  • GATAC
  • GPTBioInsightor
  • grassp
  • GRnnData
  • gssnng
  • harpy
  • hotspot
  • illico
  • infercnvpy
  • kompot
  • LazySlide
  • liana
  • mantispy
  • Marsilea
  • maxspin
  • moscot
  • Mowgli
  • Multivelo
  • ncountr
  • NicheNetPy
  • nichepca
  • novae
  • omicverse
  • Palantir
  • Panpipes
  • ParTIpy
  • PathML
  • pcdl
  • PEAKQC
  • pegasus
  • PILOT
  • popV
  • pycea
  • pychromVAR
  • pyCrossTalkeR
  • PyDESeq2
  • pyLemur
  • pySCENIC
  • pytximport
  • pyUCell
  • Rectangle
  • SC2Spa
  • SCALEX
  • scanpro
  • scATrans
  • scCellFie
  • scDataLoader
  • scFair
  • scFates
  • scGen
  • schist
  • scib
  • scib-metrics
  • scib-rapids
  • scmcp
  • scPRINT
  • scPRINT-2
  • scTriangulate
  • scVelo
  • scviva-tools
  • scxmatch
  • scXpand
  • scyan
  • sift-sc
  • sincei
  • Sobolev Alignment
  • sopa
  • spatial-eggplant
  • spatialdataR
  • spatialproteomics
  • spatiomic
  • STMiner
  • Symphonypy
  • tangram
  • TAU Community Detection
  • TreeData
  • vitessce
  • wsidata
  • zellkonverter

cellrank.pl.cluster_trends#

cellrank.pl.cluster_trends(adata, model, genes, lineage, time_key, backward=False, time_range=None, clusters=None, n_points=200, 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.

See also

  • See Visualizing and Clustering Gene Expression Trends on how to visualize the gene trends.

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

Annotated data object.

model BaseModel | Mapping[str, Mapping[str, BaseModel]]

Model based on 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 var_names.

lineage str

Name of the lineage for which to cluster the genes.

time_key str

Key in obs where the pseudotime is stored.

backward bool

Direction of the process.

time_range float | tuple[float | None, float | None] | None

Specify start and end times:

  • 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.

  • float - it specifies the maximum pseudotime.

clusters Sequence[str] | None

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.

covariate_key str | Sequence[str] | None

Keys in obs containing observations to be plotted at the bottom of each plot.

gene_symbols

Key in var to use instead of var_names.

ratio float

Height ratio of each covariate in covariate_key.

cmap str | None

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 Callable | Mapping[str, Mapping[str, Callable]] | None

Function which takes a BaseModel and some keyword arguments for prepare() and returns the prepared model. Can be specified in gene- and lineage-specific manner, similarly to the model.

ncols int

Number of columns for the plot.

sharey str | bool

Whether to share y-axis across multiple plots.

key str | None

Key in uns where to save the results. If None, it will be saved as 'lineage_{lineage}_trend' .

random_state int | None

Random seed for reproducibility.

show_progress_bar bool

Whether to show a progress bar. Disabling it may slightly improve performance.

n_jobs int | None

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 Parallel for valid options.

figsize tuple[float, float] | None

Size of the figure.

dpi int | None

Dots per inch.

save str | Path | None

Filename where to save the plot.

pca_kwargs dict

Keyword arguments for pca().

neighbors_kwargs dict

Keyword arguments for neighbors().

clustering_kwargs dict

Keyword arguments for leiden().

return_models bool

If True, return the fitted models for each gene in genes and lineage in lineages.

kwargs Any

Keyword arguments for prepare().

Return type:

Mapping[str, Mapping[str, BaseModel]] | None

Returns:

If return_models = False, just plots the figure and optionally saves it based on save. Otherwise returns the fitted models as {'gene_1': {'lineage_1': <model_11>, ...}, ...}. Models which have failed will be instances of cellrank.models.FailedModel. The returned models can be passed back as model to reuse the already computed gene trends instead of recomputing them. Also updates adata.uns with the following:

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

previous

cellrank.pl.heatmap

next

cellrank.pl.aggregate_fate_probabilities

On this page
  • cluster_trends()
Edit on GitHub
© 2026, Theislab scverse is a NumFOCUS affiliated project. Governance · Discourse · Get involved