mantispy.metrics.silhouette_batch

mantispy.metrics.silhouette_batch#

mantispy.metrics.silhouette_batch(adata, label_key, batch_key, use_rep='X_pca')#

How well mixed the batches are within each biological label.

Computed per label as 1 - mean|silhouette over batch| and averaged over labels. Higher is better; a silhouette near zero means the batches are indistinguishable within that label.

A label is skipped when mixing is undefined for it, which is when it has fewer than two batches or as many batches as rows (one well per plate on three plates, for example).

Parameters:
  • adata (AnnData) – Object with the embedding to measure in.

  • label_key (str) – obs column with the biological grouping, whose labels the batches are mixed within.

  • batch_key (str) – obs column with the nuisance grouping.

  • use_rep (str (default: 'X_pca')) – obsm key of the embedding.

Return type:

DataFrame

Returns:

A one-row tidy frame holding silhouette_batch, whose value is NaN when every label was skipped.

Raises:

KeyErrorobsm holds nothing under use_rep.