cellrank.pl.heatmap¶
- cellrank.pl.heatmap(adata, model, genes, time_key, lineages=None, backward=False, mode='lineages', time_range=None, callback=None, cluster_key=None, show_fate_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, title=None, cmap=<matplotlib.colors.ListedColormap object>, dendrogram=True, return_genes=False, return_models=False, return_figure=False, n_jobs=1, backend='loky', show_progress_bar=True, figsize=None, dpi=None, save=None, gene_order=None, **kwargs)[source]¶
Plot a heatmap of smoothed gene expression along specified lineages.
See also
See Visualizing and Clustering Gene Expression Trends on how to visualize the gene trends.
This requires a pseudotemporal ordering of cellular dynamics, computed using a method like DPT [Haghverdi et al., 2016] or Palantir [Setty et al., 2019]. The function combines the pseudotemporal ordering with CellRank’s fate probabilities to visualize each gene’s expression along specific trajectories. In the heatmap, genes are ordered according to their peak in pseudotime, which emphasizes expression cascades of sequential activation.
- Parameters:
adata (
AnnData) – Annotated data object.model (
BaseModel|Mapping[str,Mapping[str,BaseModel]]) – Model based onBaseModelto fit. If adict, gene and lineage specific models can be specified. Use'*'to indicate all genes or lineages, for example{'gene_1': {'*': ...}, 'gene_2': {'lineage_1': ..., '*': ...}}.lineages (
str|Sequence[str] |None) – Names of the lineages for which to plot. IfNone, plot all lineages.backward (
bool) – Direction of the process.mode (
Literal['genes','lineages']) –Valid options are:
'lineages'- group bygenesfor each lineage inlineages.'genes'- group bylineagesfor each gene ingenes.
time_range (
float|tuple[float|None,float|None] |None|list[float|tuple[float|None,float|None] |None]) –Specify start and end times:
tuple- it specifies the minimum and maximum pseudotime. Both values can beNone, in which case the minimum is the earliest pseudotime and the maximum is automatically determined.float- it specifies the maximum pseudotime.
This can also be specified on per-lineage basis.
callback (
Callable|Mapping[str,Mapping[str,Callable]] |None) – Function which takes aBaseModeland some keyword arguments forprepare()and returns the prepared model. Can be specified in gene- and lineage-specific manner, similarly to themodel.cluster_key (
str|Sequence[str] |None) – Key inobscontaining categorical observations to be plotted on the top of heatmap. Only available whenmode = 'lineages'.show_fate_probabilities (
bool) – Whether to also plot fate probabilities alongside the smoothed expression. Only available whenmode = 'lineages'.cluster_genes (
bool) – Whether to cluster genes usingclustermap()whenmode = 'lineages'.keep_gene_order (
bool) – Whether to keep the gene order for later lineages after the first was sorted. Only available whencluster_genes = Falseandmode = 'lineages'.scale (
bool) – Whether to normalize the gene expression to \([0, 1]\).n_convolve (
int|None) – Size of the convolution window when smoothing fate 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 whenmode = 'genes'.xlabel (
str|None) – Label on the x-axis. IfNone, it is determined based ontime_key.cmap (
ListedColormap) – Colormap to use when visualizing the smoothed expression.dendrogram (
bool) – Whether to show dendrogram whencluster_genes = True.return_genes (
bool) – Whether to return the sorted or clustered genes. Only available whenmode = 'lineages'.return_models (
bool) – IfTrue, return the fitted models for each gene ingenesand lineage inlineages.return_figure (
bool) – Whether to return the figure object. Setsreturn_genes = Trueshow_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. IfNoneor 1, the execution is sequential.backend (
Literal['loky','multiprocessing','threading']) – Which backend to use for parallelization. SeeParallelfor valid options.
- Return type:
dict[str,DataFrame] |tuple[Mapping[str,Mapping[str,BaseModel]],dict[str,DataFrame]] |None- Returns:
: If
return_models = False, just plots the figure and optionally saves it based onsave. Otherwise returns the fitted models as{'gene_1': {'lineage_1': <model_11>, ...}, ...}. Models which have failed will be instances ofcellrank.models.FailedModel. The returned models can be passed back asmodelto reuse the already computed gene trends instead of recomputing them.If
return_genes = Trueandmode = 'lineages', returns aDataFrame
containing the clustered or sorted genes. - If
return_figure = True, returns a tuple containing the figure and genes.