scviva.tools.vision.cluster_cells_tree#
- scviva.tools.vision.cluster_cells_tree(adata, newick, target=10, obs_key='VISION_Clusters_Tree')[source]#
Cluster cells by their position in a phylogenetic tree.
Mirrors R VISION’s tree-based clustering path in
clusterCells()(methods-Vision.R), which callsmaxSizeCladewiseTreeCluster(Microclusters.R) when a tree is available.The algorithm greedily splits the largest sub-clade until
√n_cellspartitions exist, then merges small partitions back down to target using tree-distance (trivial_dist) as the merge criterion. Results are stored as a categorical column inadata.obs[obs_key].- Parameters:
- adata
AnnData AnnData whose
obs_namesmust match leaf labels in newick.- newick
str Newick-format tree string (or the value of
adata.uns["vision_tree"]).- target
int Desired number of clusters. Default 10, matching R VISION’s default.
- obs_key
str Column name written to
adata.obs. Default"VISION_Clusters_Tree".
- adata
- Return type:
- Returns:
None Modifies adata in-place, adding a categorical
adata.obs[obs_key]column.