Learn R Programming

Seurat (version 3.1.4)

FindNeighbors: SNN Graph Construction

Description

Constructs a Shared Nearest Neighbor (SNN) Graph for a given dataset. We first determine the k-nearest neighbors of each cell. We use this knn graph to construct the SNN graph by calculating the neighborhood overlap (Jaccard index) between every cell and its k.param nearest neighbors.

Usage

FindNeighbors(object, ...)

# S3 method for default FindNeighbors( object, distance.matrix = FALSE, k.param = 20, compute.SNN = TRUE, prune.SNN = 1/15, nn.method = "rann", annoy.metric = "euclidean", nn.eps = 0, verbose = TRUE, force.recalc = FALSE, ... )

# S3 method for Assay FindNeighbors( object, features = NULL, k.param = 20, compute.SNN = TRUE, prune.SNN = 1/15, nn.method = "rann", annoy.metric = "euclidean", nn.eps = 0, verbose = TRUE, force.recalc = FALSE, ... )

# S3 method for dist FindNeighbors( object, k.param = 20, compute.SNN = TRUE, prune.SNN = 1/15, nn.method = "rann", annoy.metric = "euclidean", nn.eps = 0, verbose = TRUE, force.recalc = FALSE, ... )

# S3 method for Seurat FindNeighbors( object, reduction = "pca", dims = 1:10, assay = NULL, features = NULL, k.param = 20, compute.SNN = TRUE, prune.SNN = 1/15, nn.method = "rann", annoy.metric = "euclidean", nn.eps = 0, verbose = TRUE, force.recalc = FALSE, do.plot = FALSE, graph.name = NULL, ... )

Arguments

object

An object

...

Arguments passed to other methods

distance.matrix

Boolean value of whether the provided matrix is a distance matrix; note, for objects of class dist, this parameter will be set automatically

k.param

Defines k for the k-nearest neighbor algorithm

compute.SNN

also compute the shared nearest neighbor graph

prune.SNN

Sets the cutoff for acceptable Jaccard index when computing the neighborhood overlap for the SNN construction. Any edges with values less than or equal to this will be set to 0 and removed from the SNN graph. Essentially sets the strigency of pruning (0 --- no pruning, 1 --- prune everything).

nn.method

Method for nearest neighbor finding. Options include: rann, annoy

annoy.metric

Distance metric for annoy. Options include: euclidean, cosine, manhattan, and hamming

nn.eps

Error bound when performing nearest neighbor seach using RANN; default of 0.0 implies exact nearest neighbor search

verbose

Whether or not to print output to the console

force.recalc

Force recalculation of SNN.

features

Features to use as input for building the SNN

reduction

Reduction to use as input for building the SNN

dims

Dimensions of reduction to use as input

assay

Assay to use in construction of SNN

do.plot

Plot SNN graph on tSNE coordinates

graph.name

Optional naming parameter for stored SNN graph. Default is assay.name_snn.

Value

Returns the object with object@snn filled

Examples

Run this code
# NOT RUN {
pbmc_small
# Compute an SNN on the gene expression level
pbmc_small <- FindNeighbors(pbmc_small, features = VariableFeatures(object = pbmc_small))

# More commonly, we build the SNN on a dimensionally reduced form of the data
# such as the first 10 principle components.

pbmc_small <- FindNeighbors(pbmc_small, reduction = "pca", dims = 1:10)

# }

Run the code above in your browser using DataLab