mantispy.tl.moa_enrichment#
- mantispy.tl.moa_enrichment(adata, moa_key='Metadata_MOA', groupby='Metadata_Perturbation', k=10, metric='cosine', use_rep=None, key_added='moa_enrichment', copy=False)[source]#
Test which mechanisms are over-represented among each profile’s nearest neighbors.
For each profile and mechanism, a hypergeometric test asks whether the mechanism is more common among the
knearest neighbors than among all other profiles.- Parameters:
- adata
AnnData Profiles to test, one row per treatment or per well.
- moa_key
str(default:'Metadata_MOA') obscolumn holding the mechanism labels.- groupby
str(default:'Metadata_Perturbation') obscolumn naming each profile in the output table.- k
int(default:10) Number of neighbors considered, capped at
n_obs - 1. Smaller values are more local and less powerful.- metric
str(default:'cosine') As in
nn_moa_classify().- use_rep
str|None(default:None) As in
nn_moa_classify().- key_added
str(default:'moa_enrichment') Name for the output table.
- copy
bool(default:False) Return a modified copy instead of mutating in place.
- adata
- Return type:
- Returns:
None, or the modified copy. Writesuns["mantispy"][key_added]withgroup,moa,n_neighbours,pvalueandqvalue, one row per annotated profile and per mechanism found among its neighbors.- Raises:
ValueError –
kis less than 1, orobs[moa_key]has no annotated rows.
Notes
Unannotated profiles are not tested, but they can be neighbors. They take up places among the
kneighbors without adding to any mechanism’s count, and they are part of the population the test draws from. The profile itself is excluded from both its neighborhood and the population.