Build kNN graph either from distance (from == "dist") or from coordinates (from == "coordinates")
build_knn_graph(
X,
k = 5,
from = c("dist", "coordinates"),
use.nn2 = TRUE,
return_neighbors_order = FALSE,
dist_method = "euclidean",
cor_method = "pearson",
p = 2,
directed = FALSE,
DoSNN = FALSE,
which.snn = c("bluster", "dbscan"),
pruning = NULL,
kmin = 0,
...
)
a list with components
graph.knn - igraph object
order - Nxk matrix with indices of k nearest neighbors ordered by relevance (from 1st to k-th)
either distance or matrix of coordinates (rows are samples and cols are coordinates)
kNN parameter
from which data type to build kNN network: "dist" if X is a distance (dissimilarity) or "coordinates" if X is a matrix with coordinates as cols and cells as rows
whether use nn2 method to buid kNN network faster (available only for "coordinates" option)
whether return order of neighbors (not available for nn2 option)
method to compute dist (if X is a matrix of coordinates) available: c("cor", "euclidean", "maximum", "manhattan", "canberra", "binary", "minkowski")
if distance is computed as correlation (dist_method == "cor), which type of correlation to use (available: "pearson", "kendall", "spearman")
p param in "dist"
function
whether to build a directed graph
whether to apply shared nearest neighbors (default is FALSE
)
whether to use neighborsToSNNGraph or sNN for sNN graph construction
quantile to perform edge pruning (default is NULL
- no pruning applied) based on PCA distance distribution
keep at least kmin
edges in single-cell graph when pruning applied (idnored if is.null(pruning)
)
other parameters of neighborsToSNNGraph or sNN