search_nn_index: Search a nearest neighbor index.

View source: R/nearest_neighbors.R

search_nn_indexR Documentation

Search a nearest neighbor index.

Description

Search a nearest neighbor index for cells near those in the query_matrix.

Usage

search_nn_index(
  query_matrix,
  nn_index,
  k = 25,
  nn_control = list(),
  verbose = FALSE
)

Arguments

query_matrix

a reduced dimension matrix used to find the nearest neighbors in the index nn_index.

nn_index

a nearest_neighbor index.

k

an integer for the number of nearest neighbors to return for each cell. Default is 25.

nn_control

a list of parameters used to search the nearest neighbor index. See the set_nn_control help for details. Note: the default annoy search_k parameter value is set to the default value of 2 * n_trees * k. It does not know the value of n_trees that was used to build the annoy index so if a non-default n_trees value was used to build the index, you may need to set search_k in nn_control list when you run search_nn_index.

verbose

a boolean indicating whether to emit verbose output.

Value

a list list(nn.idx, nn.dists) where nn.idx is a matrix of nearest neighbor indices and nn.dists is a matrix of the distance between the index given by the row number and the index given in nn.idx. If the same reduced dim matrix is used to make the index and search the index, the index given by the row number should be in the row, usually in the first column.

Examples

  
    cds <- load_a549()
    cds <- preprocess_cds(cds)
    nn_index <- make_nn_index(SingleCellExperiment::reducedDims(cds)[['PCA']])
    nn_res <- search_nn_index(SingleCellExperiment::reducedDims(cds)[['PCA']], nn_index, 10)
  


cole-trapnell-lab/monocle3 documentation built on April 7, 2024, 9:24 p.m.