Skip to contents

Function to create a k-nearest-neighbor graph, implemented with DBSCAN

Usage

createKNNGraph.Region(
  object,
  k = 30,
  representation = "spatial",
  name = NULL,
  data.slot = NULL,
  dims = NULL,
  features = NULL,
  dist_filter = NULL,
  ...
)

Arguments

object

A Region object.

k

The number of K-nearest neighbors

representation

Which representation's embeddings should be used to compute the graph?

name

A custom name for the graph. By default, will be named according to the representation, method, and parameter specified (e.g. umap_knn_5, pca_frnn_50, spatial_del).

data.slot

A data slot to use (i.e. look for nearest neighbors in raw or normalized biomarker expression space). See Data() for details. Pass NULL to representation to use this parameter. Currently only supported for "knn".

dims

Which dimensions to use to compute distance? Only used if representation is not NULL. Pass numeric indices or names of columns from the representation being used.

features

Which features to use to compute distance? Only used if data.slot is not NULL.

dist_filter

A distance beyond which interactions will be dropped. If using a "spatial" representation, this distance will be in pixels. Passed to nn.applyDistanceCutoff(). KNN and Delaunay triangulation graphs may extend across gaps in tissue as long as there are no cells in those gaps, so this threshold can be helpful to ensure that interactions in the NN are representative of the true biological tissue structure. Default (NULL) skips this filtering.

...

Additional parameters passed to dbscan::kNN

Scroll to top