% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/plotting.r
\name{calc_sil}
\alias{calc_sil}
\title{Calculate Average Silhouette Width}
\usage{
calc_sil(dist_mat, labels, digits = 3)
}
\arguments{
\item{dist_mat}{Sample distance matrix.}

\item{labels}{Vector of factors or character strings. The cluster assignments
for each row in \code{dist_mat} (i.e., the grouping variable).}

\item{digits}{Integer (default: \code{3}). The number of decimal places to
round the final score.}
}
\value{
A numeric value representing the mean silhouette width, typically
ranging from -1 (poor clustering) to +1 (excellent clustering).
}
\description{
Calculates the average silhouette width for a given feature matrix, using
pre-defined cluster assignments (\code{labels}). This metric assesses the
quality of the clustering.
}
\examples{
library(SummarizedExperiment)
data(example_data)
se <- ecoda(
    data = example_data$Gongsharma_full$cell_counts$authors_HR,
    metadata = example_data$Gongsharma_full$metadata
)

# Extract necessary components
dist_mat <- dist(t(assay(se, "clr")))
labels <- colData(se)$subject.cmv

# Run the calculation
calc_sil(dist_mat, labels)
}
