buildIndex: Build a nearest-neighbor index

buildIndexR Documentation

Build a nearest-neighbor index

Description

Build indices for nearest-neighbor searching with different algorithms.

Usage

buildIndex(X, transposed = FALSE, ..., BNPARAM = NULL)

Arguments

X

A numeric matrix where rows correspond to data points and columns correspond to variables (i.e., dimensions).

transposed

Logical scalar indicating whether X is transposed, i.e., rows are variables and columns are data points.

...

Further arguments to be passed to individual methods.

BNPARAM

A BiocNeighborParam object specifying the type of index to be constructed. If NULL, this defaults to a KmknnParam object.

Alternatively, this may be an external pointer constructed by defineBuilder.

Details

The type and structure of the index object returned by buildIndex methods is arbitrary and left to the discretion of the method developer. However, there are a few constraints:

  • It should not be a matrix, as this interferes with dispatch for methods like findKNN when X is just the data matrix.

  • If it is an external pointer, it should refer to a BiocNeighbors::Prebuilt object (see definition in system.file("include", "BiocNeighbors.h", package="BiocNeighbors")). This allows it to be directly used in methods like findKNN.

Value

A prebuilt index that can be used in findKNN and related functions as the X= argument. The exact type of the index is not defined, but users should assume that the index is not serializable, i.e., cannot be saved or transferred between processes.

Author(s)

Aaron Lun

Examples

Y <- matrix(rnorm(100000), ncol=20)
(k.out <- buildIndex(Y))
(a.out <- buildIndex(Y, BNPARAM=AnnoyParam()))


LTLA/kmknn documentation built on Sept. 26, 2024, 12:56 a.m.