compute_silhouette: Calculate Silhouette coefficient

View source: R/main.R

compute_silhouetteR Documentation

Calculate Silhouette coefficient

Description

Given a projected object and its reference, calculate silhouette coefficient for query cells with respect to reference cells with the same cell labels.

Usage

compute_silhouette(
  ref,
  query = NULL,
  reduction = "pca",
  ndim = NULL,
  label_col = "functional.cluster",
  normalize.scores = FALSE,
  min.cells = 20
)

Arguments

ref

Reference object

query

Query object. If not specified, the silhouette coefficient of only the reference will be calculated

reduction

Which dimensionality reduction to use for euclidian distance calculation

ndim

Number of dimensions in the dimred to use for distance calculation. If NULL, use all dimensions.

label_col

Metadata column with cell type annotations. Must be present both in reference and query

normalize.scores

Whether to normalize silhouette scores by the average cell type silhouettes of the reference

min.cells

Only report silhouette scores for cell type with at least this number of cells

Value

A dataframe with average silhouette coefficient for each cell type

Examples

data(query_example_seurat)
ref <- load.reference.map()
q <- Run.ProjecTILs(query_example_seurat, ref=ref, fast.umap.predict=TRUE)
combined <- compute_silhouette(ref, query=q)

carmonalab/ProjecTILs documentation built on April 13, 2025, 10:04 p.m.