Esempio n. 1
0
 def test_filter_genes(self, adata, adata_dist):
     filter_genes(adata_dist, min_cells=2)
     result = materialize_as_ndarray(adata_dist.X)
     filter_genes(adata, min_cells=2)
     assert result.shape == adata.shape
     assert result.shape == (adata.n_obs, adata.n_vars)
     npt.assert_allclose(result, adata.X)
Esempio n. 2
0
 def test_normalize_per_cell(self, adata, adata_dist):
     normalize_per_cell(adata_dist)
     result = materialize_as_ndarray(adata_dist.X)
     normalize_per_cell(adata)
     assert result.shape == adata.shape
     assert result.shape == (adata.n_obs, adata.n_vars)
     npt.assert_allclose(result, adata.X)
Esempio n. 3
0
 def test_log1p(self, adata, adata_dist):
     log1p(adata_dist)
     result = materialize_as_ndarray(adata_dist.X)
     log1p(adata)
     assert result.shape == adata.shape
     assert result.shape == (adata.n_obs, adata.n_vars)
     npt.assert_allclose(result, adata.X)
Esempio n. 4
0
 def test_scale(self, adata, adata_dist):
     if isinstance(adata_dist.X, da.Array):
         return  # fails for dask
     scale(adata_dist)
     result = materialize_as_ndarray(adata_dist.X)
     scale(adata)
     assert result.shape == adata.shape
     assert result.shape == (adata.n_obs, adata.n_vars)
     npt.assert_allclose(result, adata.X)
Esempio n. 5
0
 def test_recipe_zheng17(self, adata, adata_dist):
     recipe_zheng17(adata_dist, n_top_genes=100)
     result = materialize_as_ndarray(adata_dist.X)
     recipe_zheng17(adata, n_top_genes=100)
     assert result.shape == adata.shape
     assert result.shape == (adata.n_obs, adata.n_vars)
     # Note the low tolerance required to get this to pass.
     # Not sure why results diverge so much. (Seems to be scaling again.)
     # Find the element that differs the most with
     # import numpy
     # am = (numpy.absolute(result - adata.X)/ numpy.absolute(adata.X)).argmax()
     # ind = numpy.unravel_index(am, result.shape)
     # print(result[ind], adata.X[ind])
     npt.assert_allclose(result, adata.X, 1e-1)