% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/R-border.R
\name{build_all_borders}
\alias{build_all_borders}
\title{Build border spots for all oriented cluster pairs}
\usage{
build_all_borders(
  df,
  k = 6,
  max_dist = NULL,
  mode = "both",
  pairs = NULL,
  coord_cols = c("x", "y"),
  cluster_col = "cluster"
)
}
\arguments{
\item{df}{A data.frame containing at least coordinate columns and a cluster
label column.}

\item{k}{Integer. Number of nearest neighbors to consider (excluding self)
when
  computing borders. Default is 6.}

\item{max_dist}{Optional numeric. Maximum Euclidean distance for neighbors to
be
  considered. If `NULL`, no distance filtering is applied.}

\item{mode}{Character. One of "inner", "outer", or "both". Controls which
border
  direction(s) to select for each pair. Default is "both".}

\item{pairs}{Optional data.frame of oriented cluster pairs, typically
produced by
[directed_cluster_interface_pairs()]. Must contain `cluster` and `interface`
  columns. If `NULL`, it is computed from `df[[cluster_col]]`.}

\item{coord_cols}{Character vector of length 2 giving the coordinate column
names.
  Default is `c("x","y")`.}

\item{cluster_col}{Character. Name of the column containing cluster labels.
Default is `"cluster"`.}
}
\value{
A data.frame produced by row-binding the result of border selection
for
each oriented pair. Typically contains the original columns of `df` plus
interface
annotation columns from the border selector.

**Note on mode column**: The `mode` column in the returned data.frame will
always contain
either "inner" or "outer", never "both". Even when the `mode` parameter is
set to "both",
each border spot row is labeled with its actual direction (cluster→interface
is "inner",
interface→cluster is "outer").
}
\description{
This function iterates over all **ordered** cluster pairs (A -> B) and
returns
a single data.frame containing the border spots for each interface, as
computed
by a border-detection function (e.g. [select_border_spots()]).
}
\details{
If `pairs_df` is not provided, it is generated from the cluster labels using
[directed_cluster_interface_pairs()].
}
\examples{
# Example with synthetic data
set.seed(1)
df_ex <- data.frame(
  x = rnorm(200),
  y = rnorm(200),
  cluster = sample(c("A","B","C"), 200, replace = TRUE)
)
all_borders <- build_all_borders(df_ex, k = 6)
head(all_borders)
}
