scib_metrics.silhouette_batch#
- scib_metrics.silhouette_batch(X, labels, batch, rescale=True, chunk_size=256, metric='euclidean', between_cluster_distances='nearest')[source]#
Average silhouette width (ASW) with respect to batch ids within each label [Luecken et al., 2022].
Default parameters (‘euclidean’, ‘nearest’) match scIB implementation.
Additional options enable BRAS compatible usage (see
bras()documentation).- Parameters:
- X
ndarray Array of shape (n_cells, n_features).
- labels
ndarray Array of shape (n_cells,) representing label values
- batch
ndarray Array of shape (n_cells,) representing batch values
- rescale
bool(default:True) Scale asw into the range [0, 1]. If True, higher values are better.
- chunk_size
int(default:256) Size of chunks to process at a time for distance computation.
- metric
Literal['euclidean','cosine'] (default:'euclidean') The distance metric to use. The distance function can be ‘euclidean’ (default) or ‘cosine’.
- between_cluster_distances
Literal['nearest','mean_other','furthest'] (default:'nearest') Method for computing inter-cluster distances. - ‘nearest’: Standard silhouette (distance to nearest cluster) - ‘mean_other’: BRAS-specific (mean distance to all other clusters) - ‘furthest’: BRAS-specific (distance to furthest cluster)
- X
- Return type:
- Returns:
silhouette score