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 (
Union
[BaseModel
,Mapping
[str
,Mapping
[str
,BaseModel
]]]) – Model based onBaseModel
to 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 (
Union
[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 bygenes
for each lineage inlineages
.'genes'
- group bylineages
for each gene ingenes
.
time_range (
Union
[float
,tuple
[Optional
[float
],Optional
[float
]],None
,list
[Union
[float
,tuple
[Optional
[float
],Optional
[float
]],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 (
Union
[Callable
,Mapping
[str
,Mapping
[str
,Callable
]],None
]) – Function which takes aBaseModel
and some keyword arguments forprepare()
and returns the prepared model. Can be specified in gene- and lineage-specific manner, similarly to themodel
.cluster_key (
Union
[str
,Sequence
[str
],None
]) – Key inobs
containing 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 = False
andmode = 'lineages'
.scale (
bool
) – Whether to normalize the gene expression to \([0, 1]\).n_convolve (
Optional
[int
]) – 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 (
Optional
[str
]) – 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 ingenes
and lineage inlineages
.return_figure (
bool
) – Whether to return the figure object. Setsreturn_genes = True
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. IfNone
or 1, the execution is sequential.backend (
Literal
['loky'
,'multiprocessing'
,'threading'
]) – Which backend to use for parallelization. SeeParallel
for valid options.figsize (
Optional
[tuple
[float
,float
]]) – Size of the figure.save (
Union
[Path
,str
,None
]) – Filename where to save the plot.
- Return type:
Union
[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
.If
return_genes = True
andmode = 'lineages'
, returns aDataFrame
containing the clustered or sorted genes. - If
return_figure = True
, returns a tuple containing the figure and genes.