sccloud.neighbors¶
-
sccloud.neighbors(data, K=100, rep='pca', n_jobs=-1, random_state=0, full_speed=False)[source]¶ Compute k nearest neighbors and affinity matrix, which will be used for diffmap and graph-based community detection algorithms.
- Parameters
data (
anndata.AnnData) – Annotated data matrix with rows for cells and columns for genes.K (
int, optional, default:100) – Number of neighbors, including the data point itself.rep (
str, optional, default:"pca") – Embedding representation used to calculate kNN. IfNone, usedata.X; otherwise, keyword'X_' + repmust exist indata.obsm.n_jobs (
int, optional, default:-1) – Number of threads to use. If-1, use all available threads.random_state (
int, optional, default:0) – Random seed set for reproducing results.full_speed (
bool, optional, default:False) –If
True, use multiple threads in constructinghnswindex. However, the kNN results are not reproducible.Otherwise, use only one thread to make sure results are reproducible.
- Return type
None- Returns
NoneUpdate
data.uns–data.uns[rep + "_knn_indices"]: kNN index matrix. Row i is the index list of kNN of cell i (excluding itself), sorted from nearest to farthest.data.uns[rep + "_knn_distances"]: kNN distance matrix. Row i is the distance list of kNN of cell i (excluding itselt), sorted from smallest to largest.data.uns["W_" + rep]: kNN graph of the data in terms of affinity matrix.
Examples
>>> scc.neighbors(adata)