mantispy.tl.grit#
- mantispy.tl.grit(adata, groupby='Metadata_Perturbation', reference='negcon', metric='pearson', use_rep=None, key_added='grit', copy=False)[source]#
Similarity of each replicate to its group, z-scored against its similarity to the controls.
For each profile, the similarities to its replicates are z-scored against its similarities to the control profiles and averaged. A perturbation’s grit is the mean over its replicates.
- Parameters:
- adata
AnnData Well-level profiles with several replicates per group.
- groupby
str(default:'Metadata_Perturbation') Column whose groups are the replicate sets.
- reference
str|None(default:'negcon') Which rows are the controls each similarity is z-scored against:
Nonefor all rows,"negcon", or the name of a booleanobscolumn.- metric
str(default:'pearson') Similarity between profiles, one of
METRICS.- use_rep
str|None(default:None) Score
obsm[use_rep]instead ofX.- key_added
str(default:'grit') Name for the outputs.
- copy
bool(default:False) Return a modified copy instead of mutating in place.
- adata
- Return type:
- Returns:
None, or the modified copy. Writes the per-replicate score toobs[key_added]anduns["mantispy"][key_added]withgroup,key_added(the mean over the group’s replicates) andn_replicates. A replicate is leftNaNwhen it is alone in its group, when fewer than two control profiles are available to it, or when those similarities have no spread, andn_replicatescounts only the replicates that were scored.- Raises:
ValueError –
referenceselects no rows.