cellrank.pl.cluster_lineage¶
-
cellrank.pl.
cluster_lineage
(adata, model, genes, lineage, backward=False, time_range=None, clusters=None, n_points=200, time_key='latent_time', norm=True, recompute=False, callback=None, ncols=3, sharey=False, key=None, random_state=None, use_leiden=False, 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 gene expression trends within a lineage and plot the clusters.
This function is based on Palantir, see [Setty19]. 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, identified e.g. by running
cellrank.tl.lineage_drivers()
.- 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
.lineage¶ (
str
) – Name of the lineage for which to cluster the genes.time_range¶ (
Union
[float
,Tuple
[Optional
[float
],Optional
[float
]],None
]) –Specify start and end times:
This can also be specified on per-lineage basis.
clusters¶ (
Optional
[Sequence
[str
]]) – Cluster identifiers to plot. If None, all clusters will be considered. Useful when plotting previously computed clusters.time_key¶ (
str
) – Key inadata.obs
where the pseudotime is stored.norm¶ (
bool
) – Whether to z-normalize each trend to have zero mean, unit variance.recompute¶ (
bool
) – If True, recompute the clustering, otherwise try to find already existing one.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
.sharey¶ (
Union
[str
,bool
]) – Whether to share y-axis across multiple plots.key¶ (
Optional
[str
]) – Key inadata.uns
where to save the results. If None, it will be saved aslineage_{lineage}_trend
.random_state¶ (
Optional
[int
]) – Random seed for reproducibility.use_leiden¶ (
bool
) – Whether to usescanpy.tl.leiden()
for clustering orscanpy.tl.louvain()
.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.pca_kwargs¶ (
Dict
) – Keyword arguments forscanpy.pp.pca()
.neighbors_kwargs¶ (
Dict
) – Keyword arguments forscanpy.pp.neighbors()
.clustering_kwargs¶ (
Dict
) – Keyword arguments forscanpy.tl.louvain()
orscanpy.tl.leiden()
.return_models¶ (
bool
) – If True, return the fitted models for each gene ingenes
and lineage inlineages
.kwargs¶ – Keyword arguments for
cellrank.ul.models.BaseModel.prepare()
.
- Return type
- 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
.Also updates
adata.uns
with the following:key
orlineage_{lineage}_trend
- ananndata.AnnData
object of shape (n_genes, n_points) containing the clustered genes.