mantispy.tl.wasserstein_features#

mantispy.tl.wasserstein_features(adata, groupby='Metadata_Perturbation', reference='negcon', key_added='wasserstein', copy=False)[source]#

Wasserstein-1 distance per feature between each group and the reference.

Parameters:
adata AnnData

Object to score. Most useful at single-cell resolution, where a group is a distribution rather than a point.

groupby str (default: 'Metadata_Perturbation')

As in effect_size().

reference str | None (default: 'negcon')

As in effect_size().

key_added str (default: 'wasserstein')

Name for the outputs.

copy bool (default: False)

Return a modified copy instead of mutating in place.

Return type:

AnnData | None

Returns:

None, or the modified copy. Writes varm[key_added], a tidy uns["mantispy"][key_added] with group, feature and distance, and the group order in uns["mantispy"][key_added + "_groups"], laid out as in effect_size().

Raises:

ValueError – reference selects no rows.

Notes

The distance compares whole distributions, so a perturbation that widens a feature without moving its mean (a mixed response where only some cells react) is detected here but not by effect_size(). The distance is in the feature’s units, so normalize first to compare features with each other.