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 (
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': ..., '*': ...}}
.lineage (
str
) – Name of the lineage for which to cluster the genes.backward (
bool
) – Direction of the process.time_range (
Union
[float
,Tuple
[Optional
[float
],Optional
[float
]],None
]) –Specify start and end times:
clusters (
Optional
[Sequence
[str
]]) – Cluster identifiers to plot. IfNone
, all clusters will be considered. Useful when plotting previously computed clusters.n_points (
int
) – Number of points used for prediction.covariate_key (
Union
[str
,Sequence
[str
],None
]) – Keys inobs
containing observations to be plotted at the bottom of each plot.ratio (
float
) – Height ratio of each covariate incovariate_key
.cmap (
Optional
[str
]) – Colormap to use for continuous covariates incovariate_key
.norm (
bool
) – Whether to z-normalize each trend to have zero mean, unit variance.recompute (
bool
) – IfTrue
, recompute the clustering, otherwise try to find already existing one.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
.ncols (
int
) – Number of columns for the plot.sharey (
Union
[str
,bool
]) – Whether to share y-axis across multiple plots.key (
Optional
[str
]) – Key inuns
where to save the results. IfNone
, it will be saved as'lineage_{lineage}_trend'
.random_state (
Optional
[int
]) – Random seed for reproducibility.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.neighbors_kwargs (
Dict
) – Keyword arguments forneighbors()
.return_models (
bool
) – IfTrue
, return the fitted models for each gene ingenes
and lineage inlineages
.
- Return type
- 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
. Also updatesadata.uns
with the following:key
or'lineage_{lineage}_trend'
-AnnData
object of shape(n_genes, n_points)
containing the clustered genes.