runKNN | R Documentation |
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.
runKNN(obj, eigs.dims, weight.by.lambda, k, nn.eps, save.knn, filename, snn, snn.prune)
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). |
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).
Returns the object with object@kmat filled
data(demo.sp); demo.sp = runKNN(obj=demo.sp, eigs.dims=1:5, k=15, snn=FALSE, save.knn=FALSE);
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.