stlearn.spatial.trajectory.set_root¶
- stlearn.spatial.trajectory.set_root(adata: AnnData, use_label: str, cluster: str, use_raw: bool = False)[source]¶
Automatically set the root index for trajectory analysis.
- Parameters:
adata (AnnData) – Annotated data matrix.
use_label (str) – Use label result of cluster method.
cluster (str) – Cluster identifier to use as the root cluster. Must exist in adata.obs[use_label].
use_raw (bool, default False) – If True, use adata.raw.X for calculations; otherwise use adata.X.
- Returns:
Index of the selected root cell in the AnnData object
- Return type:
int
- Raises:
ValueError – If the specified cluster is not found in the clustering results.
ZeroDivisionError – If the specified cluster contains no cells.