
Compute Quantitative Quality Metrics for Low-Dimensional Cell Embeddings
Source:R/10_visualizations.R
compute_embedding_quality_metrics.RdComputes quantitative cluster separability (Silhouette width), unsupervised cluster recovery (Adjusted Rand Index), and distribution preservation metrics (Mean UMI, Mean detected features, sparsity percentage, and relative percentage error) between reference and simulated datasets.
Usage
compute_embedding_quality_metrics(
embedding_data,
metric_coords = c("Dim1", "Dim2")
)Arguments
- embedding_data
A
data.frameproduced bycompute_dataset_embeddings.- metric_coords
Character vector of the 2 coordinate columns used to compute distances (default:
c("Dim1", "Dim2")).
Value
A data.frame (with check.names = FALSE) containing one row per dataset with columns:
DatasetDataset label (e.g.,
"Reference"or simulator name).RoleDataset role (
"Reference"or"Simulated").Cells (N)Number of cells in the embedding.
Mean SilhouetteMean silhouette width across cell-type labels rounded to 4 decimals (or
NA_real_).ARI (Cluster Fidelity)Adjusted Rand Index between clustering and cell-type labels rounded to 4 decimals (or
NA_real_).Mean Library SizeMean total counts per cell rounded to 1 decimal.
Mean Detected FeaturesMean detected features per cell rounded to 1 decimal.
Library Size Diff (%)Relative percent difference in mean library size vs. Reference (present when a
"Reference"row exists).
Examples
data(example_scrna, package = "scSimEval")
emb <- compute_dataset_embeddings(
reference = example_scrna$ref,
simulated = list("Splatter" = example_scrna$sim),
reduction = "umap",
cell_types = example_scrna$cell_types
)
compute_embedding_quality_metrics(emb)
#> Dataset Role Cells (N) Mean Silhouette ARI (Cluster Fidelity)
#> 1 Reference Reference 100 -0.0144 0.2105
#> 2 Splatter Simulated 100 0.0591 0.2102
#> Mean Library Size Mean Detected Features Library Size Diff (%)
#> 1 73.5 25.8 0.00
#> 2 84.0 23.9 14.29