ComputeSilhouette_Ser: Compute Silhouette Score for a Seurat Object

View source: R/Seurat_based.R

ComputeSilhouette_SerR Documentation

Compute Silhouette Score for a Seurat Object

Description

This function calculates the silhouette score for a Seurat object based on the provided dimensional reduction method (e.g., PCA, UMAP) and the metadata label (e.g., batch or biological annotation).

Usage

ComputeSilhouette_Ser(
  SerObj,
  reduction = "pca",
  dims = 1:15,
  batch.label = "cell_type"
)

Arguments

SerObj

A Seurat object containing the single-cell RNA-seq data.

reduction

Character. The dimensional reduction method to use for computing the silhouette score (e.g., "pca", "umap"). Default is '"pca"'.

dims

Numeric vector. The dimensions of the reduced embedding to use. Default is '1:15'.

batch.label

Character. The metadata label from 'SerObj@meta.data' to use for silhouette computation (e.g., "batch", "cell_type"). Default is '"cell_type"'.

Value

The average silhouette width for the given reduction and metadata label. Higher scores indicate better separation of the specified groups.

Examples

# Compute silhouette score for PCA reduction using cell_type as labels
silhouette_score <- ComputeSilhouette_Ser(SerObj, reduction = "pca", dims = 1:15, batch.label = "cell_type")

# Compute silhouette score for UMAP reduction using batch as labels
silhouette_score <- ComputeSilhouette_Ser(SerObj, reduction = "umap", dims = 1:10, batch.label = "batch")


eisascience/scCustFx documentation built on June 2, 2025, 3:59 a.m.