Skip to content

Commit

Permalink
Revert convenience sc.tl.densmap
Browse files Browse the repository at this point in the history
  • Loading branch information
keller-mark committed Dec 17, 2024
1 parent 5838162 commit ba2e887
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 18 deletions.
1 change: 0 additions & 1 deletion docs/api/tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down
2 changes: 1 addition & 1 deletion docs/release-notes/2946.feature.md
Original file line number Diff line number Diff line change
@@ -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`
3 changes: 1 addition & 2 deletions src/scanpy/tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -58,5 +58,4 @@ def __getattr__(name: str) -> Any:
"sim",
"tsne",
"umap",
"densmap",
]
5 changes: 0 additions & 5 deletions src/scanpy/tools/_umap.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

import warnings
from functools import partial
from typing import TYPE_CHECKING, Literal

import numpy as np
Expand Down Expand Up @@ -346,7 +345,3 @@ def umap(
),
)
return adata if copy else None


# Convenience function for densMAP
densmap = partial(umap, method="densmap")
13 changes: 4 additions & 9 deletions tests/test_embedding.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit ba2e887

Please sign in to comment.