mantispy.metrics.evaluate_correction#
- mantispy.metrics.evaluate_correction(adata, *, reps=('X_pca',), label_key='Metadata_Perturbation', batch_key='Metadata_Batch', covariates=(), map_key=None, perplexity=30)#
Run every metric for every representation and stack the results.
Every argument after
adatais keyword-only, so a later metric parameter can be added without changing what an existing argument means.- Parameters:
adata (
AnnData) – Object holding the representations inobsm.reps (
Sequence[str] (default:('X_pca',))) – Representations to compare, e.g.("X_pca", "X_pca_harmony").label_key (
str(default:'Metadata_Perturbation')) –obscolumn with the biological grouping.batch_key (
str(default:'Metadata_Batch')) –obscolumn with the nuisance grouping.covariates (
Sequence[str] (default:())) – Furtherobscolumns to measure each representation against, numeric or categorical, one row each. A representation can be dominated by something that is neither the batch nor the label, such as the cell count, and nothing else here would report it.map_key (
str|None(default:None)) – Name of a table written bymap(), to add its mean mAP as one more row. That table is read rather than recomputed, so the row appears once, under the representation that run scored, and not once per entry ofreps.perplexity (
float(default:30)) – Perplexity for bothlisi()rows. The default needs more than 90 rows, and on a smaller object those two rows are NaN unless a smaller value is passed.
- Return type:
- Returns:
A tidy frame with
metric,representation,key,valueandbetter, the last saying which direction is an improvement for that metric. A covariate’s row has nobetter: whether its share of the variance should be small depends on what the covariate is. A cell count is a nuisance in a genetic screen, where the layout was not randomized, and partly a treatment effect in a compound screen, where a compound that kills cells is supposed to lower it. A metric that is undefined for this object, such as a LISI whose perplexity the row count cannot support or a silhouette over one row per label, is NaN in that frame rather than an error, so one undefined metric still leaves the others readable.- Raises: