% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/AllGenerics.R, R/buildIndex.R
\name{buildIndex}
\alias{buildIndex}
\alias{buildIndex,missing-method}
\alias{buildIndex,NULL-method}
\alias{buildIndex,BiocNeighborParam-method}
\alias{buildIndex,list-method}
\title{Build a nearest-neighbor index}
\usage{
buildIndex(X, BNPARAM, transposed = FALSE, ...)

\S4method{buildIndex}{missing}(X, BNPARAM, transposed = FALSE, ...)

\S4method{buildIndex}{NULL}(X, BNPARAM, transposed = FALSE, ...)

\S4method{buildIndex}{BiocNeighborParam}(X, BNPARAM, transposed = FALSE, ...)

\S4method{buildIndex}{list}(X, BNPARAM, transposed = FALSE, ..., .check.nonfinite = TRUE)
}
\arguments{
\item{X}{A numeric matrix or matrix-like object where rows correspond to data points and columns correspond to variables (i.e., dimensions).}

\item{BNPARAM}{A \linkS4class{BiocNeighborParam} object specifying the type of index to be constructed.
If \code{NULL} or missing, this defaults to a \linkS4class{KmknnParam} object. 
Alternatively, this may be a list returned by \code{\link{defineBuilder}}.}

\item{transposed}{Logical scalar indicating whether \code{X} is transposed, i.e., rows are variables and columns are data points.}

\item{...}{Further arguments to be passed to individual methods.
If a method accepts arguments here, it should prefix these arguments with the algorithm name to avoid conflicts, e.g., \code{vptree.foo.bar}.}

\item{.check.nonfinite}{Boolean indicating whether to check for non-finite values in \code{X}.
This can be set to \code{FALSE} for greater efficiency.}
}
\value{
A \linkS4class{BiocNeighborIndex} object can be used in \code{\link{findKNN}} and related functions as the \code{X=} argument,
or in \code{\link{findKnnFromIndex}} and related generics as the \code{BNINDEX=} argument.
}
\description{
Build indices for nearest-neighbor searching with different algorithms.
}
\details{
Each \code{buildIndex} method is expected to return an instance of a \linkS4class{BiocNeighborIndex} subclass.
The structure of this subclass is arbitrary and left to the discretion of the method developer.

If a \code{buildIndex} method returns a \linkS4class{BiocNeighborGenericIndex} subclass,
the index can be used with the existing methods for \code{\link{findKnnFromIndex}}, etc. without further effort.
Otherwise, developers are responsible for defining methods for their subclass in each of the relevant generics.

Users should assume that the index is not serializable (i.e., saved or transferred between processes) via R's usual mechanisms.
If the index must be saved to disk, consider using \code{\link{saveIndex}} instead.
}
\examples{
Y <- matrix(rnorm(100000), ncol=20)
(k.out <- buildIndex(Y))
(a.out <- buildIndex(Y, BNPARAM=AnnoyParam()))

}
\author{
Aaron Lun
}
