scviva.tools.vision.compute_plasticity_scores#

scviva.tools.vision.compute_plasticity_scores(adata, newick)[source]#

Compute per-cell Fitch-Hartigan parsimony plasticity scores.

For every categorical variable in adata.obs, a {var}_plasticity column is added to adata.obs. The score for cell c is the average normalised Fitch-Hartigan parsimony across all internal nodes on the path from the tree root to c.

  • High plasticity: the metadata label switches often along the lineage path → the trait is labile / plastic.

  • Low plasticity: the label is conserved along the lineage path.

Mirrors R VISION’s computePlasticityScores().

Parameters:
adata AnnData

Must have obs_names matching tree leaf labels.

newick str

Newick-format tree string (or the adata.uns["vision_tree"] value).

Return type:

None

Returns:

None Modifies adata in-place, adding one {var}_plasticity column to adata.obs for each categorical variable found.