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 calls maxSizeCladewiseTreeCluster (Microclusters.R) when a tree is available.

The algorithm greedily splits the largest sub-clade until √n_cells partitions 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 in adata.obs[obs_key].

Parameters:
adata AnnData

AnnData whose obs_names must 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".

Return type:

None

Returns:

None Modifies adata in-place, adding a categorical adata.obs[obs_key] column.