From 8aaa334fa5715cd5820493020cb4bd951c63ce2a Mon Sep 17 00:00:00 2001 From: Philipp Weiler Date: Wed, 7 Jun 2023 17:24:06 -0400 Subject: [PATCH] Remove `magic_impute` (#1079) --- pyproject.toml | 1 - scvelo/preprocessing/moments.py | 13 ---------- tests/preprocessing/test_moments.py | 39 ----------------------------- 3 files changed, 53 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index e0bb5658..7a7045ad 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -74,7 +74,6 @@ dev = [ "hnswlib", "hypothesis", "louvain", - "magic-impute", "pre-commit>=2.9.0", "pybind11", "pytest-cov", diff --git a/scvelo/preprocessing/moments.py b/scvelo/preprocessing/moments.py index 2fd99efe..590bd12e 100644 --- a/scvelo/preprocessing/moments.py +++ b/scvelo/preprocessing/moments.py @@ -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" ): diff --git a/tests/preprocessing/test_moments.py b/tests/preprocessing/test_moments.py index 525802c2..2ce03fb7 100644 --- a/tests/preprocessing/test_moments.py +++ b/tests/preprocessing/test_moments.py @@ -9,7 +9,6 @@ from scvelo.preprocessing.moments import ( get_moments, - magic_impute, moments, second_order_moments, second_order_moments_u, @@ -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`