Skip to contents

Calculate number of nearest neighbours between batches out of a knn graph

Usage

GetNeighborsPerBatch(
  object,
  batch.var,
  graph.name = "RNA_nn",
  count.self = TRUE
)

# S4 method for class 'Seurat,character'
GetNeighborsPerBatch(
  object,
  batch.var,
  graph.name = "RNA_nn",
  count.self = TRUE
)

Arguments

object

a Seurat object

batch.var

name of a column in the Seurat object's metadata containing batch information

graph.name

name of a Graph or Neighbor instance stored in object. When available, prefer the distance based network to the connectivities graph (especially when computed with the UMAP method).

count.self

whether to include self-to-self vertices in the calculation

Value

a square count matrix of size number of batches (see Details section)

Details

The output matrix will likely not be symmetrical. This is due to the approximate nature of the nearest neighbour search algorithm used to compute the knn graph. It must be read by row. For instance, the number of times cells of batch 1 have cells of batch 3 in their nn is matrix[1,3]

See also

The classes Graph and Neighbor