| queryDistance | R Documentation |
Query a reference dataset to determine the distance to the k-th nearest neighbor of each point in a query dataset.
queryDistance(
X,
query,
k,
num.threads = 1,
subset = NULL,
transposed = FALSE,
...,
BNPARAM = NULL
)
X |
The reference dataset to be queried.
This should be a numeric matrix where rows correspond to reference points and columns correspond to variables (i.e., dimensions).
Alternatively, a prebuilt BiocNeighborIndex object from |
query |
A numeric matrix of query points, containing the same number of columns as |
k |
A positive integer scalar specifying the number of nearest neighbors to retrieve. Alternatively, an integer vector of length equal to the number of points in All |
num.threads |
Integer scalar specifying the number of threads to use for the search. |
subset |
An integer, logical or character vector indicating the rows of |
transposed |
A logical scalar indicating whether |
... |
Further arguments to pass to |
BNPARAM |
A BiocNeighborParam object specifying how the index should be constructed.
If |
If multiple queries are to be performed to the same X, it may be beneficial to build the index from X with buildIndex.
The resulting pointer object can be supplied as X to multiple queryKNN calls, avoiding the need to repeat index construction in each call.
Numeric vector of length equal to the number of points in query (or subset, if provided),
containing the distance from each point to its k-th nearest neighbor.
This is equivalent to but more memory efficient than using queryKNN and subsetting to the last distance.
Aaron Lun
buildIndex, to build an index ahead of time.
Y <- matrix(rnorm(100000), ncol=20)
Z <- matrix(rnorm(20000), ncol=20)
out <- queryDistance(Y, query=Z, k=5)
head(out)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.