findDistance | R Documentation |
Find the distance to the k-th nearest neighbor for each point in a dataset.
findDistance(X, k, num.threads = 1, subset = NULL, ..., BNPARAM = NULL)
X |
A numeric matrix where rows correspond to data points and columns correspond to variables (i.e., dimensions).
Alternatively, a prebuilt BiocNeighborIndex object from |
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 specifying the indices of points in |
... |
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 findDistance
calls, avoiding the need to repeat index construction in each call.
Numeric vector of length equal to the number of points in X
(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 findKNN
and subsetting to the last distance.
Aaron Lun
buildIndex
, to build an index ahead of time.
Y <- matrix(rnorm(100000), ncol=20)
out <- findDistance(Y, k=8)
summary(out)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.