From a metadata file, given a list of cells with the corrisponding annotated cell type, build a neighbor matrix reporting the number of occurrences for each cell type

nnMat(
  data,
  label = NULL,
  method = c("Q", "C", "D", "K", "M"),
  layers = 1,
  snap = NULL,
  k = NULL,
  d.max = NULL,
  soi = F,
  ids_anno = NULL,
  return.seurat = T
)

Arguments

data

a Seurat object containing Kandinsky data

label

character string specifying the variable name to be used to define cell annotation groups

method

character string specifying the method to be used to identify neighbours. Must be one of the following: 'Q': queen contiguity method,check for contact (not overlap) between any edge or side od two polygons (refers to the queen movement rule in chess). Currently only applicable for Visium/Visium-HD data; 'C': centroid-based method, use maximum centroid distance threshold to identify spot/cell neighbours; 'D': Delaunay triangulation method; 'K': KNN method, define k closest neighbours to each spot/cell; 'M': membrane-based method, check for the occurrence of a physical contact/intersection within a distance threshold between cell boundaries. Not applicable in the case of Visium spots. When argument method is not specified or is set to NULL, the function will use nb slot already stored in Kandinsky object to create neighbour matrix

layers

numeric, number of concentric contiguous layers to include in spot neighbourhood. Only Applied when 'nb.method = Q'. Default is 1.

snap

numeric, extra distance accepted between polygon borders for contiguity relation. Applied when 'method' is set to Q. Can't work with point geometries like cell centroids.

k

numeric, number of nearest neighbours to be searched. Applied when method is set to K.

d.max

numeric, maximum centroid or membrane distance threshold. Applied when method is set to C or M.

soi

boolean, whether or not filter Delaunay network to keep sphere of influence (SOI) graph. Default is FALSE.

ids_anno

optional, character string specifying any extra variable to be added to the final distance matrix

return.seurat

boolean, whether returning neighbour matrix alone (FALSE) or the input Seurat object with a new nnMat slot as part of the Kandinsky data

See also

Other nnMat: nn_query()