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: None for all rows, "negcon", or the name of a boolean obs column.

metric str (default: 'pearson')

Similarity between profiles, one of METRICS.

use_rep str | None (default: None)

Score obsm[use_rep] instead of X.

key_added str (default: 'grit')

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 the per-replicate score to obs[key_added] and uns["mantispy"][key_added] with group, key_added (the mean over the group’s replicates) and n_replicates. A replicate is left NaN when it is alone in its group, when fewer than two control profiles are available to it, or when those similarities have no spread, and n_replicates counts only the replicates that were scored.

Raises:

ValueError – reference selects no rows.