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)
A snap object
A vector of the dimensions to use in construction of the KNN graph.
Weight the cell embeddings by the sd of each PC
K for the k-nearest neighbor algorithm.
Error bound when performing nearest neighbor seach using RANN. default of 0.0 implies exact nearest neighbor search
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.
Write KNN directly to file named here as an edge list compatible with runCluster.
Setting to TRUE can convert KNN graph into a SNN graph.
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).
Returns the object with object@kmat filled
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).
# NOT RUN {
data(demo.sp);
demo.sp = runKNN(obj=demo.sp, eigs.dims=1:5, k=15, snn=FALSE, save.knn=FALSE);
# }
Run the code above in your browser using DataLab