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 inadata.var_names
or inadata.raw.var_names
, ifuse_raw=True
.lineages¶ (
Union
[str
,Sequence
[str
],None
]) – Names of the lineages for which to plot. If None, plot all lineages.Valid options are:
’lineages’ - group by
genes
for each lineage inlineages
.’genes’ - group by
lineages
for each gene ingenes
.
time_key¶ (
str
) – Key inadata.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:
This can also be specified on per-lineage basis.
callback¶ (
Union
[Callable
,Mapping
[str
,Mapping
[str
,Callable
]],None
]) – Function which takes acellrank.ul.models.BaseModel
and some keyword arguments forcellrank.ul.models.BaseModel.prepare()
and returns the prepared model. Can be specified in gene- and lineage-specific manner, similarly tomodel
.cluster_key¶ (
Union
[str
,Sequence
[str
],None
]) – Key(s) inadata.obs
containing categorical observations to be plotted on top of the heatmap. Only available whenmode='lineages'
.show_absorption_probabilities¶ (
bool
) – Whether to also plot absorption probabilities alongside the smoothed expression. Only available whenmode='lineages'
.cluster_genes¶ (
bool
) – Whether to cluster genes usingseaborn.clustermap()
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 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.lineage_height¶ (
float
) – Height of a bar whenmode='genes'
.xlabel¶ (
Optional
[str
]) – Label on the x-axis. If None, 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
) – If True, return the fitted models for each gene ingenes
and lineage inlineages
.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¶ (
str
) – Which backend to use for parallelization. Seejoblib.Parallel
for valid options.figsize¶ (
Optional
[Tuple
[float
,float
]]) – Size of the figure.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
None – If
return_models=False
, just plots the figure and optionally saves it based onsave
.Dict[str, Dict[str,
cellrank.ul.models.BaseModel
]] – Otherwise returns the fitted models as{'gene_1': {'lineage_1': <model_11>, ...}, ...}
. Models which have failed will be instances ofcellrank.ul.models.FailedModel
.pandas.DataFrame
– Ifreturn_genes=True
andmode='lineages'
, returnspandas.DataFrame
containing the clustered or sorted genes.