BiocNeighborIndex {BiocNeighbors} | R Documentation

## The BiocNeighborIndex class

### Description

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

### Details

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.

### Methods

In the following code snippets, `x` and `object` are BiocNeighborIndex objects.

The main user-accessible methods are:

`show(object)`:

  Display the class and dimensions of `object`.

`dim(x)`:

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

`dimnames(x)`:

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

`x[[i]]`:

  Return the value of slot `i`, as used in the constructor for `x`.

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

`bndata(object)`:

  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)`.

`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"`.

`bndistance(object)`:

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

### Author(s)

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.

[Package BiocNeighbors version 1.10.0 Index]