Skip to content

Commit bbcc109

Browse files
authored
Merge pull request #24 from metaspace2020/fix-dependencies
Fix dependencies
2 parents d0fa972 + 588156a commit bbcc109

File tree

9 files changed

+38
-32
lines changed

9 files changed

+38
-32
lines changed

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Set up Python
2323
uses: actions/setup-python@v4
2424
with:
25-
python-version: "3.9"
25+
python-version: "3.11"
2626
- name: Install dependencies
2727
run: |
2828
python -m pip install --upgrade pip wheel

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- name: Set up Python
2222
uses: actions/setup-python@v4
2323
with:
24-
python-version: 3.9
24+
python-version: 3.11
2525

2626
- name: Install dependencies
2727
run: |

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
strategy:
2222
fail-fast: false
2323
matrix:
24-
python-version: ["3.9", "3.10", "3.11"]
24+
python-version: ["3.11", "3.12", "3.13"]
2525
os: [ubuntu-latest]
2626

2727
steps:

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
# so a file named "default.css" will overwrite the builtin "default.css".
6767
html_static_path = ["_static"]
6868

69-
# Doctest allows to execute example code with directives "" using "make doctest".
69+
# Doctest allows to execute example code with directives "testcode" using "make doctest".
7070
# Compared to the Python standard library module, this extension detects code blocks
7171
# without requiring ">>> " as prefix.
7272
# Remove doctest flags within the examples ("#doctest: +SKIP"), not to distract readers.

docs/examples.rst

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ Plain AnnData with ScanPy
3131
SquidPy
3232
-------
3333

34+
.. note:: Example may not work
35+
SquidPy (0.4.1) is not anymore compatible with the dependencies used in this project.
36+
3437
.. testcode::
38+
:skipif: True
3539

3640
from metaspace_converter import metaspace_to_anndata
3741
import squidpy as sq
@@ -92,26 +96,21 @@ Here using a reversed colormap which better represents intense values on bright
9296

9397
# Workaround: spatialdata-plot currently does not use points transformation
9498
sdata.points["maldi_points"] = sdata.transform_element_to_coordinate_system(
95-
sdata.points["maldi_points"], "global"
99+
"maldi_points", "global"
96100
)
97101

98102
(
99103
sdata.pl.render_images("optical_image")
100104
.pl.render_points(
101105
"maldi_points",
102-
color=sdata.table.var.index[0],
106+
color=sdata.tables["table"].var.index[0],
103107
alpha=1,
104108
size=2,
105109
cmap="viridis_r",
106110
)
107-
.pl.show(title=sdata.table.var.index[0], coordinate_systems="global")
111+
.pl.show(title=sdata.tables["table"].var.index[0], coordinate_systems="global")
108112
)
109113

110-
.. testoutput::
111-
:hide:
112-
113-
...
114-
115114
.. image:: ./_static/img/example_img_sd.png
116115
:alt: Visualization with SpatialData
117116

metaspace_converter/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class COL:
2020
MICROMETER: Final = "micrometer"
2121
OPTICAL_IMAGE_KEY: Final = "optical_image"
2222
POINTS_KEY: Final = "maldi_points"
23+
TABLE_KEY: Final = "table"
2324
REGION_KEY: Final = "region"
2425
INSTANCE_KEY: Final = "instance_id"
2526
X: Final = "x"

metaspace_converter/tests/to_spatialdata_test.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import numpy as np
22
import pytest
3+
import xarray as xr
34
from multiscale_spatial_image import MultiscaleSpatialImage
45

56
from metaspace_converter.constants import COORD_SYS_GLOBAL, OPTICAL_IMAGE_KEY, POINTS_KEY, X, Y
@@ -48,18 +49,18 @@ def test_metaspace_to_spatialdata(
4849
)
4950

5051
# Check table
51-
assert actual.table is not None
52+
assert "table" in actual.tables
5253
dataset = sm.dataset(id=dataset_id)
53-
assert actual.table.n_obs == np.prod(get_ion_image_shape(dataset))
54-
assert actual.table.n_vars == len(dataset.annotations(fdr=fdr, database=database))
54+
assert actual.tables["table"].n_obs == np.prod(get_ion_image_shape(dataset))
55+
assert actual.tables["table"].n_vars == len(dataset.annotations(fdr=fdr, database=database))
5556
assert {
5657
COL.ion_image_shape_y,
5758
COL.ion_image_shape_x,
5859
COL.ion_image_pixel_y,
5960
COL.ion_image_pixel_x,
60-
}.issubset(actual.table.obs.columns)
61-
assert np.all(actual.table.var["fdr"] <= fdr)
62-
actual_database = actual.table.uns[METASPACE_KEY]["metaspace_to_anndata_parameters"]["database"]
61+
}.issubset(actual.tables["table"].obs.columns)
62+
assert np.all(actual.tables["table"].var["fdr"] <= fdr)
63+
actual_database = actual.tables["table"].uns[METASPACE_KEY]["metaspace_to_anndata_parameters"]["database"]
6364
assert actual_database == list(database)
6465

6566
# Check optical image, if requested
@@ -72,7 +73,7 @@ def test_metaspace_to_spatialdata(
7273
if add_optical_image and add_points:
7374
# All points should be positioned within the image bounds.
7475
points_over_image = actual.transform_element_to_coordinate_system(
75-
actual.points[points_name_added], target_coordinate_system=COORD_SYS_GLOBAL
76+
points_name_added, target_coordinate_system=COORD_SYS_GLOBAL
7677
)[[Y, X]].compute()
7778
image_min = (0, 0)
7879
image_max = _get_image_shape(actual.images[optical_name_added])
@@ -83,7 +84,7 @@ def test_metaspace_to_spatialdata(
8384

8485

8586
def _get_image_shape(image: MultiscaleSpatialImage) -> tuple[int, int]:
86-
assert isinstance(image, MultiscaleSpatialImage)
87+
assert isinstance(image, xr.DataTree)
8788
sizes = image["scale0"].sizes
8889
return sizes["y"], sizes["x"]
8990

metaspace_converter/to_spatialdata.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
OPTICAL_IMAGE_KEY,
2020
POINTS_KEY,
2121
REGION_KEY,
22+
TABLE_KEY,
2223
XY,
2324
YX,
2425
YXC,
@@ -40,6 +41,7 @@ def metaspace_to_spatialdata(
4041
optical_name_added: str = OPTICAL_IMAGE_KEY,
4142
add_points: bool = True,
4243
points_name_added: str = POINTS_KEY,
44+
table_name: str = TABLE_KEY,
4345
sm: Optional[SMInstance] = None,
4446
**annotation_filter,
4547
) -> SpatialData:
@@ -67,7 +69,8 @@ def metaspace_to_spatialdata(
6769
add_points: Whether to also add ion image pixel coordinates as SpatialData points. This
6870
allows to spatially visualize the ion image values. If False, only ion intensities are
6971
added to the table and coordinates are added to ``obs``.
70-
points_name_added: Name of the element where to store the points in the SpatialData object
72+
points_name: Name of the element where to store the points in the SpatialData object
73+
table_name_added: The name for the SpatialData table to which annotations will be saved.
7174
sm: Optionally a cached SMInstance
7275
annotation_filter: Additional keyword arguments passed to the METASPACE API.
7376
@@ -101,7 +104,7 @@ def metaspace_to_spatialdata(
101104
**annotation_filter,
102105
)
103106
table = _create_spatialdata_table(adata)
104-
sdata = SpatialData(table=table)
107+
sdata = SpatialData(tables={table_name: table})
105108

106109
# Create image
107110
if has_optical_image(dataset) and add_optical_image:

pyproject.toml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "metaspace-converter"
7-
version = "1.1.1"
7+
version = "1.1.2"
88
authors = [
99
{name = "Tim Daniel Rose", email = "tim.rose@embl.de"},
1010
{name = "Andreas Eisenbarth", email = "andreas.eisenbarth@embl.de"},
1111
]
1212
description = "Convert Metaspace datasets to AnnData"
13-
requires-python = ">=3.9"
13+
requires-python = ">=3.11"
1414
license = {text = "Apache-2.0"}
1515
classifiers = [
1616
"License :: OSI Approved :: Apache Software License",
@@ -21,27 +21,29 @@ classifiers = [
2121
"Operating System :: Microsoft :: Windows",
2222
"Operating System :: POSIX :: Linux",
2323
"Programming Language :: Python :: 3",
24-
"Programming Language :: Python :: 3.9",
25-
"Programming Language :: Python :: 3.10",
2624
"Programming Language :: Python :: 3.11",
25+
"Programming Language :: Python :: 3.12",
26+
"Programming Language :: Python :: 3.13",
2727
]
2828
dependencies = [
2929
"anndata>=0.9.2",
3030
"metaspace2020>=2.0.6",
3131
"numpy",
3232
"pandas",
33-
"spatial-image>=0.3",
34-
"spatialdata>=0.0.15",
33+
"spatial-image>=1.1.0",
34+
"spatialdata>=0.7.2",
3535
]
3636
dynamic = ["readme"]
3737

3838
[project.optional-dependencies]
3939
test = [
40-
"multiscale-spatial-image>=0.11",
40+
"multiscale-spatial-image>=2.0.0",
4141
"pytest>=7.2",
4242
"pytest-cov>=4.1",
43+
"scikit-image>=0.22", # Avoid binary incompatibility with Numpy 2.0
4344
]
4445
docs = [
46+
"anndata~=0.12.10",
4547
"sphinx~=7.2",
4648
"sphinx-autodoc-typehints",
4749
"sphinx-codeautolink",
@@ -51,9 +53,9 @@ docs = [
5153
# "myst-nb",
5254
# "ipython~=8.6.0",
5355
# For example code in documentation
54-
"scanpy~=1.9.6",
55-
"spatialdata-plot~=0.0.6",
56-
"squidpy~=1.3.1",
56+
"scanpy~=1.11.5",
57+
"spatialdata-plot~=0.2.9",
58+
#"squidpy~=1.4.1", # Has not been updated to anndata>0.10.9, which is incompatible with SpatialData
5759
]
5860

5961
[project.urls]

0 commit comments

Comments
 (0)