Neighbors.compute_neighbors(n_neighbors=30, knn=True, n_pcs=None, use_rep=None, method='umap', random_state=0, write_knn_indices=False, metric='euclidean', metric_kwds=mappingproxy({}))

Compute distances and connectivities of neighbors.

n_neighbors : intint (default: 30)

Use this number of nearest neighbors.

knn : boolbool (default: True)

Restrict result to n_neighbors nearest neighbors.

n_pcs : int, NoneOptional[int] (default: None)

Use this many PCs. If n_pcs==0 use .X if use_rep is None.

use_rep : str, NoneOptional[str] (default: None)

Use the indicated representation. 'X' or any key for .obsm is valid. If None, the representation is chosen automatically: For .n_vars < 50, .X is used, otherwise ‘X_pca’ is used. If ‘X_pca’ is not present, it’s computed with default parameters.

Return type



Writes sparse graph attributes .distances and .connectivities. Also writes .knn_indices and .knn_distances if write_knn_indices==True.