mantispy.tl.effect_size#
- mantispy.tl.effect_size(adata, groupby='Metadata_Perturbation', reference='negcon', method='cohens_d', pvalues=True, min_obs=2, key_added='effect', copy=False)#
Per-feature effect size of each group against the reference.
- Parameters:
adata (
AnnData) – Object to score, at cell or profile resolution.groupby (
str(default:'Metadata_Perturbation')) – Column defining the groups to score.reference (
str|None(default:'negcon')) – Rows to compare against:"negcon",Nonefor everything, or a booleanobscolumn. The reference group is also scored against itself as a calibration check; its effects should be near zero.method (
str(default:'cohens_d')) –"cohens_d"is the difference in means over the pooled standard deviation."robust_z"is the difference in medians in units of control MAD, which a few extreme cells cannot move.pvalues (
bool(default:True)) – Compute a Mann-Whitney p-value for each effect. At single-cell resolution nearly every feature is significant, so turn them off when ranking by effect.min_obs (
int(default:2)) – Groups with fewer rows than this are left unscored asNaN.key_added (
str(default:'effect')) – Name for the outputs.copy (
bool(default:False)) – Return a modified copy instead of mutating in place.
- Return type:
- Returns:
None, or the modified copy. Writesvarm[key_added], a(n_vars, n_groups)float32 array with columns in the order ofuns["mantispy"][key_added + "_groups"], anduns["mantispy"][key_added], a tidy frame withgroup,feature,effect,pvalue(Mann-Whitney U, two-sided,NaNwhenpvalues=False) andqvalue(Benjamini-Hochberg over the whole table, since it is one family of tests).- Raises:
ValueError –
methodis not one ofMETHODS, orreferenceselects fewer than two rows.
Notes
The p-value tests whether the distributions differ, and its significance grows with the number of rows. The effect size measures by how much, and does not grow with the number of rows. At single-cell resolution nearly everything is significant, so rank by effect and use the q-value only to filter.