Skip to content

Commit

Permalink
Remove magic_impute (#1079)
Browse files Browse the repository at this point in the history
  • Loading branch information
WeilerP committed Jun 7, 2023
1 parent e8fa7a1 commit 8aaa334
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 53 deletions.
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ dev = [
"hnswlib",
"hypothesis",
"louvain",
"magic-impute",
"pre-commit>=2.9.0",
"pybind11",
"pytest-cov",
Expand Down
13 changes: 0 additions & 13 deletions scvelo/preprocessing/moments.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,19 +154,6 @@ def second_order_moments_u(adata):
return Muu


# TODO: Add docstrings
def magic_impute(adata, knn=5, t=2, verbose=0, **kwargs):
"""TODO."""
logg.info(
"To be used carefully. Magic has not yet been tested for this application."
)
import magic

magic_operator = magic.MAGIC(verbose=verbose, knn=knn, t=t, **kwargs)
adata.layers["Ms"] = magic_operator.fit_transform(adata.layers["spliced"])
adata.layers["Mu"] = magic_operator.transform(adata.layers["unspliced"])


def get_moments(
adata, layer=None, second_order=None, centered=True, mode="connectivities"
):
Expand Down
39 changes: 0 additions & 39 deletions tests/preprocessing/test_moments.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

from scvelo.preprocessing.moments import (
get_moments,
magic_impute,
moments,
second_order_moments,
second_order_moments_u,
Expand Down Expand Up @@ -167,44 +166,6 @@ def test_analytic_example(self, sparse: bool):
)


class TestMagicImpute:
@pytest.mark.parametrize("dataset", ["pancreas", "dentategyrus"])
@pytest.mark.parametrize("n_obs", [50, 100])
def test_output(self, adata, capfd, dataset: str, n_obs: int):
adata = adata(dataset=dataset, n_obs=n_obs, raw=False, preprocessed=True)
del adata.layers["Mu"]
del adata.layers["Ms"]

magic_impute(adata=adata)

ground_truth_unspliced = np.load(
file=(
f"tests/_data/test_moments/magic_impute/dataset={dataset}-n_obs={n_obs}"
f"-layer=unspliced_magic_impute.npy"
)
)
np.testing.assert_almost_equal(
adata.layers["Mu"], ground_truth_unspliced, decimal=5
)

ground_truth_spliced = np.load(
file=(
f"tests/_data/test_moments/magic_impute/dataset={dataset}-n_obs={n_obs}"
f"-layer=spliced_magic_impute.npy"
)
)
np.testing.assert_almost_equal(
adata.layers["Ms"], ground_truth_spliced, decimal=5
)

expected_log = (
"To be used carefully. Magic has not yet been tested for this "
"application.\n"
)
actual_log, _ = capfd.readouterr()
assert actual_log == expected_log


class TestMoments:
def _compare_adatas(self, adata_1, adata_2):
# Check `.layers`
Expand Down

0 comments on commit 8aaa334

Please sign in to comment.