buildAnnoy {BiocNeighbors} | R Documentation |
Build an Annoy index and save it to file in preparation for a nearest-neighbors search.
buildAnnoy(X, ntrees=50, directory=tempdir(), fname=tempfile(tmpdir=directory, fileext=".idx"))
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. |
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.
A AnnoyIndex object containing:
path
, a string containing the path to the index file.
dim
, an integer vector of length 2 containing dim(X)
for later reference.
NAMES
, a character vector or NULL
equal to rownames(X)
.
Aaron Lun
See AnnoyIndex
for details on the output class.
See findAnnoy
and queryAnnoy
for dependent functions.
Y <- matrix(rnorm(100000), ncol=20) out <- buildAnnoy(Y) out