Skip to content

Commit

Permalink
Update dev branch (scverse#2421)
Browse files Browse the repository at this point in the history
* Fix anndata-dev install

* Fix test_ingest by setting X dtype explicitly

* Fix log1p test (implicit copy was no longer being made)

* Fix test that relied on implicit dtype conversion

* Fix dataset that now loaded in as float64 instead of float32

* Update visium default figure for matplotlib 3.7

* skip plotting test that changed on mpl 3.7 if mpl < 3.7 is installed

* Update release notes
  • Loading branch information
ivirshup authored Feb 17, 2023
1 parent d64282a commit 27493a4
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
displayName: 'Install dependencies'
- script: |
'pip install -v "anndata[dev,test] @ git+https://github.com/scverse/anndata"'
pip install -v "anndata[dev,test] @ git+https://github.com/scverse/anndata"
displayName: 'Install development anndata'
condition: eq(variables['ANNDATA_DEV'], 'yes')
Expand Down
14 changes: 5 additions & 9 deletions docs/release-notes/1.9.2.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
### 1.9.2 {small}`the future`


```{rubric} Documentation
```
### 1.9.2 {small}`2023-02-16`

```{rubric} Bug fixes
```
- {func}`~scanpy.pp.highly_variable_genes` `layer` argument now works in tandem with `batches` {pr}`2302` {smaller}`D Schaumont`
- {func}`~scanpy.pp.highly_variable_genes` with `flavor='cell_ranger'` now handles the case in {issue}`2230` where the number of calculated dispersions is less than `n_top_genes` {pr}`2231` {smaller}`L Zappia`

```{rubric} Performance
```
* {func}`~scanpy.pp.highly_variable_genes` `layer` argument now works in tandem with `batches` {pr}`2302` {smaller}`D Schaumont`
* {func}`~scanpy.pp.highly_variable_genes` with `flavor='cell_ranger'` now handles the case in {issue}`2230` where the number of calculated dispersions is less than `n_top_genes` {pr}`2231` {smaller}`L Zappia`
* Fix compatibility with matplotlib 3.7 {pr}`2414` {smaller}`I Virshup` {smaller}`P Fisher`
* Fix scrublet numpy matrix compatibility issue {pr}`2395` {smaller}`A Gayoso`
5 changes: 3 additions & 2 deletions scanpy/datasets/_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ def paul15() -> ad.AnnData:
backup_url = 'http://falexwolf.de/data/paul15.h5'
_utils.check_presence_download(filename, backup_url)
with h5py.File(filename, 'r') as f:
X = f['data.debatched'][()]
# Coercing to float32 for backwards compatibility
X = f['data.debatched'][()].astype(np.float32)
gene_names = f['data.debatched_rownames'][()].astype(str)
cell_names = f['data.debatched_colnames'][()].astype(str)
clusters = f['cluster.id'][()].flatten().astype(int)
Expand All @@ -194,7 +195,7 @@ def paul15() -> ad.AnnData:
# remove 10 corrupted gene names
infogenes_names = np.intersect1d(infogenes_names, adata.var_names)
# restrict data array to the 3461 informative genes
adata = adata[:, infogenes_names]
adata = adata[:, infogenes_names].copy()
# usually we'd set the root cell to an arbitrary cell in the MEP cluster
# adata.uns['iroot'] = np.flatnonzero(adata.obs['paul15_clusters'] == '7MEP')[0]
# here, set the root cell as in Haghverdi et al. (2016)
Expand Down
Binary file modified scanpy/tests/_images/master_spatial_visium_default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions scanpy/tests/test_embedding_plots.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from functools import partial
from pathlib import Path

import matplotlib as mpl
import matplotlib.pyplot as plt
from matplotlib.colors import Normalize
from matplotlib.testing.compare import compare_images
Expand Down Expand Up @@ -304,6 +305,11 @@ def test_visium_circles(image_comparer): # standard visium data


def test_visium_default(image_comparer): # default values
from packaging.version import parse as parse_version

if parse_version(mpl.__version__) < parse_version("3.7.0"):
pytest.xfail("Matplotlib 3.7.0+ required for this test")

save_and_compare_images = image_comparer(ROOT, FIGS, tol=5)
adata = sc.read_visium(HERE / '_data' / 'visium_data' / '1.0.0')
adata.obs = adata.obs.astype({'array_row': 'str'})
Expand Down
5 changes: 3 additions & 2 deletions scanpy/tests/test_ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
[7.0, 9.4, 6.8, 9.1, 8.0],
[8.9, 8.6, 9.6, 1.0, 2.0],
[6.5, 8.9, 2.2, 4.5, 8.9],
]
],
dtype=np.float32,
)

T = np.array([[2.0, 3.5, 4.0, 1.0, 4.7], [3.2, 2.0, 5.0, 5.0, 8.0]])
T = np.array([[2.0, 3.5, 4.0, 1.0, 4.7], [3.2, 2.0, 5.0, 5.0, 8.0]], dtype=np.float32)


@pytest.fixture
Expand Down
17 changes: 9 additions & 8 deletions scanpy/tests/test_preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@


def test_log1p(tmp_path):
A = np.random.rand(200, 10)
A = np.random.rand(200, 10).astype(np.float32)
A_l = np.log1p(A)
ad = AnnData(A)
ad2 = AnnData(A)
ad3 = AnnData(A)
ad = AnnData(A.copy())
ad2 = AnnData(A.copy())
ad3 = AnnData(A.copy())
ad3.filename = tmp_path / 'test.h5ad'
sc.pp.log1p(ad)
assert np.allclose(ad.X, A_l)
Expand Down Expand Up @@ -84,18 +84,19 @@ def test_mean_var_sparse():


def test_normalize_per_cell():
adata = AnnData(np.array([[1, 0], [3, 0], [5, 6]]))
A = np.array([[1, 0], [3, 0], [5, 6]], dtype=np.float32)
adata = AnnData(A.copy())
sc.pp.normalize_per_cell(adata, counts_per_cell_after=1, key_n_counts='n_counts2')
assert adata.X.sum(axis=1).tolist() == [1.0, 1.0, 1.0]
# now with copy option
adata = AnnData(np.array([[1, 0], [3, 0], [5, 6]]))
adata = AnnData(A.copy())
# note that sc.pp.normalize_per_cell is also used in
# pl.highest_expr_genes with parameter counts_per_cell_after=100
adata_copy = sc.pp.normalize_per_cell(adata, counts_per_cell_after=1, copy=True)
assert adata_copy.X.sum(axis=1).tolist() == [1.0, 1.0, 1.0]
# now sparse
adata = AnnData(np.array([[1, 0], [3, 0], [5, 6]]))
adata_sparse = AnnData(sp.csr_matrix([[1, 0], [3, 0], [5, 6]]))
adata = AnnData(A.copy())
adata_sparse = AnnData(sp.csr_matrix(A.copy()))
sc.pp.normalize_per_cell(adata)
sc.pp.normalize_per_cell(adata_sparse)
assert adata.X.sum(axis=1).tolist() == adata_sparse.X.sum(axis=1).A1.tolist()
Expand Down

0 comments on commit 27493a4

Please sign in to comment.