% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/AllGenerics.R, R/findNeighbors-methods.R
\docType{methods}
\name{findNeighbors}
\alias{findNeighbors}
\alias{findNeighbors-methods}
\alias{findNeighbors,missing,missing-method}
\alias{findNeighbors,missing,KmknnParam-method}
\alias{findNeighbors,KmknnIndex,missing-method}
\alias{findNeighbors,KmknnIndex,KmknnParam-method}
\alias{findNeighbors,missing,VptreeParam-method}
\alias{findNeighbors,VptreeIndex,missing-method}
\alias{findNeighbors,VptreeIndex,VptreeParam-method}
\title{Find all neighbors in range}
\usage{
findNeighbors(X, threshold, ..., BNINDEX, BNPARAM)
}
\arguments{
\item{X}{A numeric data matrix where rows are points and columns are dimensions.
This can be missing if \code{BNINDEX} is supplied.}

\item{threshold}{A numeric scalar or vector specifying the maximum distance for considering neighbors.}

\item{...}{Further arguments to pass to specific methods.
This is guaranteed to include \code{subset}, \code{get.index}, \code{get.distance} \code{BPPARAM} and \code{raw.index}.
See \code{?"\link{findNeighbors-functions}"} for more details.}

\item{BNINDEX}{A \linkS4class{BiocNeighborIndex} object containing precomputed index information.
This can be missing if \code{X} and \code{BNPARAM} is supplied, see Details.}

\item{BNPARAM}{A \linkS4class{BiocNeighborParam} object specifying the algorithm to use.
This can be missing if \code{BNINDEX} is supplied, see Details.}
}
\value{
A list is returned containing \code{index}, a list of integer vectors specifying the identities of the neighbors of each point;
and \code{distance}, a list of numeric vectors containing the distances to those neighbors.
See \code{?"\link{findNeighbors-functions}"} for more details.
}
\description{
Find all neighbors within a given distance for each point in a data set.
}
\details{
The class of \code{BNINDEX} and \code{BNPARAM} will determine the dispatch to specific functions.
Only one of these arguments needs to be defined to resolve dispatch.
However, if both are defined, they cannot specify different algorithms.

If \code{BNINDEX} is supplied, \code{X} does not need to be specified.
In fact, any value of \code{X} will be ignored as all necessary information for the search is already present in \code{BNINDEX}.
Similarly, any parameters in \code{BNPARAM} will be ignored.

If both \code{BNINDEX} and \code{BNPARAM} are missing, the function will default to the KMKNN algorithm by setting \code{BNPARAM=KmknnParam()}.
}
\examples{
Y <- matrix(rnorm(100000), ncol=20)
k.out <- findNeighbors(Y, threshold=3)
a.out <- findNeighbors(Y, threshold=3, BNPARAM=VptreeParam())

k.dex <- buildKmknn(Y)
k.out2 <- findNeighbors(Y, threshold=3, BNINDEX=k.dex)
k.out3 <- findNeighbors(Y, threshold=3, BNINDEX=k.dex, BNPARAM=KmknnParam())

v.dex <- buildVptree(Y)
v.out2 <- findNeighbors(Y, threshold=3, BNINDEX=v.dex)
v.out3 <- findNeighbors(Y, threshold=3, BNINDEX=v.dex, BNPARAM=VptreeParam())

}
\seealso{
\code{\link{rangeFindKmknn}}
and \code{\link{rangeFindVptree}} for specific methods.
}
\author{
Aaron Lun
}
