buildAnnoy {BiocNeighbors}R Documentation

Build an Annoy index

Description

Build an Annoy index and save it to file in preparation for a nearest-neighbors search.

Usage

buildAnnoy(X, ntrees=50, directory=tempdir(), 
    fname=tempfile(tmpdir=directory, fileext=".idx")) 

Arguments

X

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

ntrees

Integer scalar specifying the number of trees, where more trees provide greater accuracy at the cost of more computational work.

directory

String containing the path to the directory in which to save the index file.

fname

String containing the path to the index file.

Details

This function is automatically called by findAnnoy and related functions. However, it can be called directly by the user to save time if multiple queries are to be performed to the same X.

It is advisable to change directory to a location that is amenable to parallel read operations on HPC file systems. Of course, if index files are manually constructed, the user is also responsible for their clean-up after all calculations are completed.

Value

A AnnoyIndex object containing:

Author(s)

Aaron Lun

See Also

See AnnoyIndex for details on the output class.

See findAnnoy and queryAnnoy for dependent functions.

Examples

Y <- matrix(rnorm(100000), ncol=20)
out <- buildAnnoy(Y)
out

[Package BiocNeighbors version 1.0.0 Index]