search_neighbors: Search nearest neighbors

View source: R/search_neighbors.R

search_neighborsR Documentation

Search nearest neighbors

Description

Search [shared] K-nearest neighbor graph to find the samples that are most similar to those matching a substring search.

Usage

search_neighbors(
  seurat,
  graph_name = NULL,
  var1_search = NULL,
  label_col = NULL,
  var2_group = NULL,
  group_col = NULL,
  max_neighbors = Inf,
  add_original_names = TRUE,
  verbose = TRUE
)

Arguments

seurat

Seurat object.

graph_name

Name of the graph to use. If none provided, will use the last graph available. If no graphs are available, new ones will be computed using Seurat::FindNeighbors.

var1_search

Substring search term to filter var1 by. If a vector is supplied instead, this will be interpreted as an "or" query.

label_col

meta.data column used to name the rows/columns of the graph. label_col will also be used in the search for var1_search substring.

var2_group

Substring search term to filter var2 by, according to group_col.

group_col

meta.data column used to filter var2 when var2_group is used.

max_neighbors

The max number of neighbors (var2) per term (var1).

add_original_names

Add original names into the results. This can be useful when var1 names are forced to be unique internally.

verbose

Whether to print messages.

Examples

 
data("pseudo_seurat") 
### No group filter
top_neighbors <- search_neighbors(seurat = pseudo_seurat, 
                                  var1_search = "purkinje", 
                                  max_neighbors=5)
### With group filter
top_neighbors2 <- search_neighbors(seurat = pseudo_seurat,
                                  var1_search = "purkinje",
                                  var2_group = "human",
                                  group_col = "species",
                                  max_neighbors=5)

neurogenomics/scNLP documentation built on Oct. 8, 2024, 5:30 p.m.