runKNN: K Nearest Neighbour Graph Construction

View source: R/runKNN.R

runKNNR Documentation

K Nearest Neighbour Graph Construction

Description

Constructs a K Nearest Neighbor (SNN) Graph from a snap object. The k-nearest neighbors of each cell were identified and used to create a KNN graph.

Usage

runKNN(obj, eigs.dims, weight.by.lambda, k, nn.eps, save.knn, filename, snn,
  snn.prune)

Arguments

obj

A snap object

eigs.dims

A vector of the dimensions to use in construction of the KNN graph.

weight.by.lambda

Weight the cell embeddings by the sd of each PC

k

K for the k-nearest neighbor algorithm.

nn.eps

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

save.knn

Default is to store the KNN in object@kmat. Setting to FALSE can be used together with a provided filename to only write the KNN out as an edge file to disk. This is compatible with runCluster.

filename

Write KNN directly to file named here as an edge list compatible with runCluster.

snn

Setting to TRUE can convert KNN graph into a SNN graph.

snn.prune

Sets the cutoff for acceptable Jaccard index when computing the neighborhood overlap. 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).

Details

Using the selected significant principal components (PCs), we next calculated pairwise Euclidean distance between every two cells, using this distance, we created a k-nearest neighbor graph in which every cell is represented as a node and edges are drawn between cells within k nearest neighbors. Edge weight between any two cells can be refined by shared overlap in their local neighborhoods using Jaccard similarity (snn).

Value

Returns the object with object@kmat filled

Examples

data(demo.sp);
demo.sp = runKNN(obj=demo.sp, eigs.dims=1:5, k=15, snn=FALSE, save.knn=FALSE);


r3fang/SnapATAC documentation built on March 29, 2022, 4:33 p.m.