snapatac2.pp.knn#
- snapatac2.pp.knn(adata, n_neighbors=50, use_dims=None, use_rep=None, method='hora', n_jobs=- 1, inplace=True, random_state=0)[source]#
Compute a neighborhood graph of observations.
- Parameters
adata (
AnnData|AnnDataSet|ndarray) – Annotated data matrix or numpy array.n_neighbors (
int) – The number of nearest neighbors to be searched.use_dims (
Union[int,list[int],None]) – The dimensions used for computation.use_rep (
Optional[str]) – The key for the matrixmethod (
Literal[‘hora’, ‘pynndescent’, ‘exact’]) – ‘hora’, ‘pynndescent’, or ‘exact’n_jobs (
int) – number of CPUs to useinplace (
bool) – Whether to store the result in the anndata object.random_state (
int) – Random seed for approximate nearest neighbor search.
- Returns
if
inplace=True, store KNN in.obsp['distances']. Otherwise, return a sparse matrix.- Return type
csr_matrix | None