diff --git a/docs/api/tools.md b/docs/api/tools.md index 53b39eb567..1d51559e5a 100644 --- a/docs/api/tools.md +++ b/docs/api/tools.md @@ -20,7 +20,6 @@ Any transformation of the data matrix that is not *preprocessing*. In contrast t pp.pca tl.tsne tl.umap - tl.densmap tl.draw_graph tl.diffmap ``` diff --git a/docs/release-notes/2946.feature.md b/docs/release-notes/2946.feature.md index b356574215..7a48bae2a8 100644 --- a/docs/release-notes/2946.feature.md +++ b/docs/release-notes/2946.feature.md @@ -1 +1 @@ -Add DensMAP support with {func}`~scanpy.tl.densmap` {smaller}`M Keller` +Add DensMAP support via `method="densmap"` in {func}`~scanpy.tl.umap` {smaller}`M Keller` diff --git a/src/scanpy/tools/__init__.py b/src/scanpy/tools/__init__.py index ca79727038..714ab234e4 100644 --- a/src/scanpy/tools/__init__.py +++ b/src/scanpy/tools/__init__.py @@ -24,7 +24,7 @@ from ._score_genes import score_genes, score_genes_cell_cycle from ._sim import sim from ._tsne import tsne -from ._umap import densmap, umap +from ._umap import umap if TYPE_CHECKING: from typing import Any @@ -58,5 +58,4 @@ def __getattr__(name: str) -> Any: "sim", "tsne", "umap", - "densmap", ] diff --git a/src/scanpy/tools/_umap.py b/src/scanpy/tools/_umap.py index 7f1e083e28..117278a79d 100644 --- a/src/scanpy/tools/_umap.py +++ b/src/scanpy/tools/_umap.py @@ -1,7 +1,6 @@ from __future__ import annotations import warnings -from functools import partial from typing import TYPE_CHECKING, Literal import numpy as np @@ -346,7 +345,3 @@ def umap( ), ) return adata if copy else None - - -# Convenience function for densMAP -densmap = partial(umap, method="densmap") diff --git a/tests/test_embedding.py b/tests/test_embedding.py index b21fdb13b7..f595cafccf 100644 --- a/tests/test_embedding.py +++ b/tests/test_embedding.py @@ -93,23 +93,18 @@ def test_diffmap(): def test_densmap(): pbmc = pbmc68k_reduced() - sc.tl.densmap(pbmc) + sc.tl.umap(pbmc, method="densmap") d1 = pbmc.obsm["X_densmap"].copy() - sc.tl.densmap(pbmc) + sc.tl.umap(pbmc, method="densmap") d2 = pbmc.obsm["X_densmap"].copy() assert_array_equal(d1, d2) - # Should have same result via sc.tl.umap with "densmap" as method - sc.tl.umap(pbmc, method="densmap") - d3 = pbmc.obsm["X_densmap"].copy() - assert_array_equal(d1, d3) - # Checking if specifying random_state works, arrays shouldn't be equal - sc.tl.densmap(pbmc, random_state=1234) + sc.tl.umap(pbmc, method="densmap", random_state=1234) d4 = pbmc.obsm["X_densmap"].copy() assert_raises(AssertionError, assert_array_equal, d1, d4) # Checking if specifying dens_lambda works, arrays shouldn't be equal - sc.tl.densmap(pbmc, method_kwds=dict(dens_lambda=2.3456)) + sc.tl.umap(pbmc, method="densmap", method_kwds=dict(dens_lambda=2.3456)) d5 = pbmc.obsm["X_densmap"].copy() assert_raises(AssertionError, assert_array_equal, d1, d5)