% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ABCdeep.R
\name{ABCdeep.SingleInMultiple}
\alias{ABCdeep.SingleInMultiple}
\title{Single-source ABC with a deep-learning (autoencoder) Step 4 (ABCdeep)}
\usage{
ABCdeep.SingleInMultiple(
  data,
  weighting = "var",
  normalize = NULL,
  gr = c(),
  bag = TRUE,
  numsim = 1000,
  numvar = 100,
  NC = NULL,
  topk_frac = 0.2,
  latent_dim = "auto",
  hidden_units = 32L,
  ae_epochs = 80L,
  ae_lr = 0.001,
  cluster_in_latent = "ward",
  linkage = "ward.D2",
  nugget_type = "between",
  nugget_args = list(),
  min_samples = 40L,
  seed = NULL
)
}
\arguments{
\item{data}{Numeric matrix, \strong{objects (samples) in rows}, features in
columns (the MosaiClusteR convention).}

\item{weighting}{Feature weighting used to rank features for the top-K focus:
\code{"var"}, \code{"cv"}, \code{"nugget"} or equal (as in
\code{\link{ABCpp.SingleInMultiple}}).}

\item{normalize}{Optional normalisation applied before the internal min-max
scaling (see \code{\link{Normalization}}); \code{NULL}/\code{FALSE} = none.}

\item{gr}{Unused; kept for interface compatibility.}

\item{bag}{Logical; bootstrap the objects each iteration (Step 2).}

\item{numsim}{Number of iterations \eqn{R}.}

\item{numvar}{Kept for backward compatibility; unused.}

\item{NC}{Base-cluster count (\code{NULL} = \eqn{\lfloor\sqrt{N}\rfloor}).}

\item{topk_frac}{Fraction of the highest-weighted features the autoencoder is
trained/embedded on (default 0.2). Focusing on the informative features
drops the noise that would dilute a full-feature embedding on sparse signals,
while keeping enough features for dense signals; the count is floored at
\code{min(G, 20)} and capped at \code{min(G, 4000)}.}

\item{latent_dim}{Autoencoder bottleneck size: an integer, or \code{"auto"}
(default) = \code{max(NC + 2, 8)}, capped at the hidden width and \eqn{K-1}.}

\item{hidden_units}{Hidden-layer width of the encoder/decoder.}

\item{ae_epochs}{Training epochs for the one-time autoencoder fit.}

\item{ae_lr}{Adam learning rate.}

\item{cluster_in_latent}{Latent clustering (Step 4b): \code{"ward"} (default,
hierarchical) or \code{"kmeans"}.}

\item{linkage}{Agglomeration method when \code{cluster_in_latent = "ward"}.}

\item{nugget_type, nugget_args}{Passed to the nugget weighting when
\code{weighting = "nugget"}.}

\item{min_samples}{Emit a warning when \code{nrow(data)} is below this (the
autoencoder is underdetermined at very small \eqn{N}); default 40.}

\item{seed}{Optional RNG seed (controls the autoencoder init and the
bootstrap).}
}
\value{
A data frame, \code{numsim} rows by one column per object; entries are
base-cluster labels (\code{0} = object not selected that iteration) -- the
same contract as \code{\link{ABCpp.SingleInMultiple}}.
}
\description{
A deep-learning variant of \code{\link{ABCpp.SingleInMultiple}} that keeps the
ABC algorithm of \insertCite{Amaratunga2008}{MosaiClusteR} intact and replaces
\strong{only Step 4}: instead of clustering the raw feature sub-matrix, a
neural autoencoder embeds the objects into a latent space and the latent
vectors are clustered into \code{NC} base clusters. The stacked label matrix
is fused across sources by \code{\link{f.clustABC.MultiSource}}, exactly as in
\code{\link{M_ABCpp}}.
}
\section{Speed (trained once, forward pass per iteration)}{

The autoencoder is trained a single time on the source's top-\code{topk_frac}
most-informative features; each of the \code{numsim} iterations then performs
only a forward pass over the bootstrapped objects. The network is a
self-contained, vectorised R autoencoder (He initialisation, ReLU, Adam, MSE)
-- there is no Python, TensorFlow or torch dependency, and \strong{no PCA or
other fallback}: a single code path.
}

\examples{
data(mosaic_toy)
lab <- ABCdeep.SingleInMultiple(mosaic_toy$List[[1]], numsim = 40, NC = 3,
                                ae_epochs = 40, seed = 1)
dim(lab)
}
\references{
\insertAllCited{}
}
\seealso{
\code{\link{M_ABCdeep}}, \code{\link{ABCpp.SingleInMultiple}},
\code{\link{f.clustABC.MultiSource}}
}
