% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/R-neighbourhood.R
\name{count_all_inlaids}
\alias{count_all_inlaids}
\title{Count inlaid composition for all clusters}
\usage{
count_all_inlaids(
  df,
  clusters = NULL,
  inlaid_col = "cluster",
  cluster_col = "cluster"
)
}
\arguments{
\item{df}{A data.frame containing at least the columns `x`, `y`, cluster
identifier column, and `spot_id`.
  - `x`, `y`: numeric coordinates of spots
- cluster column (name specified by `cluster_col`): cluster assignment for
#' each spot
- inlaid column (name specified by `inlaid_col`): inlaid/annotation for each
spot
  - `spot_id`: unique identifier for each spot}

\item{clusters}{Optional vector of cluster labels to process. If `NULL`,
all unique clusters in `df` are used.}

\item{inlaid_col}{Character. Name of the column containing inlaid/annotation
values.
  Default is `"cluster"`.}

\item{cluster_col}{Character. Name of the column containing cluster
assignments.
  Default is `"cluster"`.}
}
\value{
A data.frame with columns:
\describe{
  \item{cluster}{The source cluster being analyzed.}
  \item{inlaid}{The inlaid/annotation type.}
  \item{count}{Number of spots with this inlaid type in the cluster.}
\item{proportion}{Proportion of this inlaid type among all spots in cluster.}
}
Rows are grouped by source cluster and sorted by count within each group
(descending).
}
\description{
This function counts inlaid/annotation composition within each cluster in a
single call. It returns a dataframe with counts of inlaid types for each
source cluster.
}
\examples{
data("visium_simulated_spe", package = "Battlefield")
spe <- visium_simulated_spe
df <- data.frame(
  spot_id = colnames(spe),
  x = SpatialExperiment::spatialCoords(spe)[, 1],
  y = SpatialExperiment::spatialCoords(spe)[, 2],
  cluster = SummarizedExperiment::colData(spe)$cluster,
inlaid = sample(paste0("type_", 1:3), length(colnames(spe)), replace = TRUE)
)
# Get inlaid statistics for all clusters
all_inlaids <- count_all_inlaids(df, inlaid_col = "inlaid")
head(all_inlaids)

}
