campmc.mt.recovery_scores#
- campmc.mt.recovery_scores(adata, *, partition_key, label_key, rare_threshold=0.01)[source]#
Score how well a partition recovers rare cell types.
Assigns each metacell the majority label among its members, then computes balanced accuracy over rare types plus ARI/NMI restricted to rare cells. Rare types are those with frequency at most
rare_threshold.- Parameters:
- adata
AnnData Annotated data with partition and cell-type columns in
obs.- partition_key
str Column in
adata.obswith metacell assignments.- label_key
str Column in
adata.obswith ground-truth (or reference) labels.- rare_threshold
float(default:0.01) Maximum fraction of cells for a type to be considered rare.
- adata
- Return type:
- Returns:
DataFrame Single-row table with
balanced_accuracy,ari,nmi, andn_rare_types.
Examples
import campmc as cp import scanpy as sc adata = sc.datasets.pbmc68k_reduced() cp.partition(adata, method="camp3", gamma=50, random_state=0) cp.mt.recovery_scores( adata, partition_key="camp", label_key="louvain", rare_threshold=0.05, )
balanced_accuracy ari nmi n_rare_types 0 0.5 0.974249 0.967538 4