diff --git a/muon/_core/preproc.py b/muon/_core/preproc.py index 2e39562..695c3aa 100644 --- a/muon/_core/preproc.py +++ b/muon/_core/preproc.py @@ -18,6 +18,7 @@ from sklearn.utils import check_random_state from anndata import AnnData +import scanpy from scanpy import logging from scanpy.tools._utils import _choose_representation from scanpy.neighbors._connectivity import umap @@ -26,6 +27,13 @@ from umap.umap_ import nearest_neighbors from numba import njit, prange +from packaging.version import Version + +if Version(scanpy.__version__) < Version("1.10"): + from scanpy.neighbors import _compute_connectivities_umap +else: + from scanpy.neighbors._connectivity import umap as _compute_connectivities_umap + from mudata import MuData # Computational methods for preprocessing @@ -585,7 +593,7 @@ def neighdist(cell, nz): neighbordistances = _sparse_csr_fast_knn(neighbordistances, n_neighbors + 1) logging.info("Calculating connectivities...") - connectivities = umap( + connectivities = _compute_connectivities_umap( knn_indices=neighbordistances.indices.reshape( (neighbordistances.shape[0], n_neighbors + 1) ),