cellrank.pl.heatmap

cellrank.pl.heatmap(adata, model, genes, lineages=None, backward=False, mode='lineages', time_key='latent_time', time_range=None, callback=None, cluster_key=None, show_absorption_probabilities=False, cluster_genes=False, keep_gene_order=False, scale=True, n_convolve=5, show_all_genes=False, cbar=True, lineage_height=0.33, fontsize=None, xlabel=None, cmap=<matplotlib.colors.ListedColormap object>, dendrogram=True, return_genes=False, return_models=False, n_jobs=1, backend='loky', show_progress_bar=True, figsize=None, dpi=None, save=None, **kwargs)[source]

Plot a heatmap of smoothed gene expression along specified lineages.

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

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

    Model based on cellrank.ul.models.BaseModel to fit.

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

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

  • lineages (Union[str, Sequence[str], None]) – Names of the lineages for which to plot. If None, plot all lineages.

  • backward (bool) – Direction of the process.

  • mode (str) –

    Valid options are:

    • ’lineages’ - group by genes for each lineage in lineages.

    • ’genes’ - group by lineages for each gene in genes.

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

  • time_range (Union[float, Tuple[Optional[float], Optional[float]], None, List[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.

    This can also be specified on per-lineage basis.

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

  • cluster_key (Union[str, Sequence[str], None]) – Key(s) in adata.obs containing categorical observations to be plotted on top of the heatmap. Only available when mode='lineages'.

  • show_absorption_probabilities (bool) – Whether to also plot absorption probabilities alongside the smoothed expression. Only available when mode='lineages'.

  • cluster_genes (bool) – Whether to cluster genes using seaborn.clustermap() when mode='lineages'.

  • keep_gene_order (bool) – Whether to keep the gene order for later lineages after the first was sorted. Only available when cluster_genes=False and mode='lineages'.

  • scale (bool) – Whether to normalize the gene expression 0-1 range.

  • n_convolve (Optional[int]) – Size of the convolution window when smoothing absorption probabilities.

  • show_all_genes (bool) – Whether to show all genes on y-axis.

  • cbar (bool) – Whether to show the colorbar.

  • lineage_height (float) – Height of a bar when mode='genes'.

  • fontsize (Optional[float]) – Size of the title’s font.

  • xlabel (Optional[str]) – Label on the x-axis. If None, it is determined based on time_key.

  • cmap (ListedColormap) – Colormap to use when visualizing the smoothed expression.

  • dendrogram (bool) – Whether to show dendrogram when cluster_genes=True.

  • return_genes (bool) – Whether to return the sorted or clustered genes. Only available when mode='lineages'.

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

  • show_progress_bar (bool) – Whether to show a progress bar. Disabling it may 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 (str) – 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[Path, str, None]) – Filename where to save the plot.

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

Return type

Union[Dict[str, DataFrame], Tuple[Mapping[str, Mapping[str, BaseModel]], Dict[str, DataFrame]], None]

Returns