scanpy.Neighbors.compute_neighbors
- 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.
- Parameters:
- n_neighbors :
int(default:30) Use this number of nearest neighbors.
- knn :
bool(default:True) Restrict result to
n_neighborsnearest neighbors.- n_pcs :
Optional[int] (default:None) Use this many PCs. If
n_pcs==0use.Xifuse_rep is None.- use_rep :
Optional[str] (default:None) Use the indicated representation.
'X'or any key for.obsmis valid. IfNone, the representation is chosen automatically: For.n_vars<scanpy.settings.N_PCS(default: 50),.Xis used, otherwise ‘X_pca’ is used. If ‘X_pca’ is not present, it’s computed with default parameters orn_pcsif present.
- n_neighbors :
- Return type:
- Returns:
: Writes sparse graph attributes
.distancesand.connectivities. Also writes.knn_indicesand.knn_distancesifwrite_knn_indices==True.