Skip to contents

computes shared nearest neighbors from embedding.

Usage

emb2snn(x, k, type = "rank", BNPARAM = NULL)

Arguments

x

A numeric matrix (with features as columns and items as rows) from which nearest neighbors will be computed.

k

The number of nearest neighbors.

type

A string specifying the type of weighting scheme to use for shared neighbors. Possible choices include "rank", "number", and "jaccard". See type in bluster::neighborsToSNNGraph() for details.

BNPARAM

A BiocNeighbors parameter object to compute kNNs. Ignored unless the input is a matrix or data.frame. If omitted, the Annoy approximation will be used if there are more than 500 elements.

Value

An igraph object.

Examples

d1 <- mockData()
emb2snn(as.matrix(d1[,seq_len(2)]),k=5)
#> IGRAPH a5be2b9 U-W- 40 261 -- 
#> + attr: weight (e/n)
#> + edges from a5be2b9:
#>  [1]  1-- 2  1-- 4  2-- 4  3-- 5  3-- 6  1-- 7  4-- 7  3-- 8  6-- 8  1-- 8
#> [11]  6-- 9  8-- 9  1-- 9  3-- 9  3--10  5--10  5--11 10--11  3--11  2--12
#> [21]  4--12  1--12  7--12  3--13  6--13  8--13  9--13  5--14 10--14 11--14
#> [31]  3--14  5--15 10--15 11--15 14--15  3--15  5--16 11--16 14--16 15--16
#> [41] 10--16  3--16  6--17  9--17 13--17  8--17  3--17  1--18  4--18  7--18
#> [51] 12--18  2--18  3--19 13--19  6--19  8--19 17--19  9--19 10--20  3--20
#> [61]  5--20 11--20 14--20 15--20 16--20  1--20 18--20  8--20  9--20  6--20
#> [71] 13--21 17--21  7--21  6--21  9--21 19--21  8--21  3--22  6--22  8--22
#> + ... omitted several edges