BiocNeighborIndex: The BiocNeighborIndex class

Description Details Methods Author(s) See Also


A virtual class for indexing structures of different nearest-neighbor search algorithms.


The BiocNeighborIndex class is a virtual base class on which other index objects are built. There are 4 concrete subclasses:

KmknnIndex: exact nearest-neighbor search with the KMKNN algorithm.

VptreeIndex: exact nearest-neighbor search with a VP tree.

AnnoyIndex: approximate nearest-neighbor search with the Annoy algorithm.

HnswIndex: approximate nearest-neighbor search with the HNSW algorithm.

These objects hold indexing structures for a given data set - see the associated documentation pages for more details. It also retains information about the input data as well as the sample names.


The main user-accessible methods are:


Display the class and dimensions of a BiocNeighborIndex object.


Return the dimensions of a BiocNeighborIndex x, in terms of the matrix used to construct it.


Return the dimension names of a BiocNeighborIndex x. Only the row names of the input matrix are stored, in the same order.

More advanced methods (intended for developers of other packages) are:


Return a numeric matrix containing the data used to construct object. Each column should represent a data point and each row should represent a variable (i.e., it is transposed compared to the usual input, for efficient column-major access in C++ code). Columns may be reordered from the input matrix according to bnorder(object).


Return an integer vector specifying the new ordering of columns in bndata(object). This generally only needs to be considered if raw.index=TRUE, see ?"BiocNeighbors-raw-index".


Return a string specifying the distance metric to be used for searching, usually "Euclidean" or "Manhattan". Obviously, this should be the same as the distance metric used for constructing the index.


Aaron Lun

See Also

KmknnIndex, VptreeIndex, AnnoyIndex, and HnswIndex for direct constructors.

buildIndex for construction on an actual data set.

findKNN and queryKNN for dispatch.

BiocNeighbors documentation built on Dec. 9, 2020, 2:01 a.m.