Skip to contents

Integrated from scCluBench (Xu et al., AAAI 2026). Aligns predicted clusters to ground truth classes using the Hungarian bipartite matching algorithm, then computes the fraction of correctly mapped cells.

Usage

calc_clustering_accuracy(pred, truth)

Arguments

pred

Vector of predicted cluster labels.

truth

Vector of ground truth cell type labels.

Value

Clustering accuracy between 0 and 1.

Examples

pred <- factor(rep(c("A", "B"), each = 20))
truth <- factor(rep(c("A", "B"), each = 20))
calc_clustering_accuracy(pred, truth)
#> [1] 1