spatialdata-io 0.1.3.post0__tar.gz → 0.1.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/.pre-commit-config.yaml +2 -2
  2. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/CHANGELOG.md +8 -0
  3. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/PKG-INFO +20 -12
  4. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/README.md +18 -11
  5. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/_version.py +2 -2
  6. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/pyproject.toml +1 -0
  7. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/src/spatialdata_io/converters/legacy_anndata.py +2 -0
  8. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/src/spatialdata_io/readers/cosmx.py +12 -11
  9. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/src/spatialdata_io/readers/visium_hd.py +21 -8
  10. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/src/spatialdata_io/readers/xenium.py +37 -10
  11. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/tests/test_xenium.py +2 -2
  12. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/.bumpversion.cfg +0 -0
  13. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/.codecov.yaml +0 -0
  14. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/.editorconfig +0 -0
  15. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/.flake8 +0 -0
  16. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/.github/codecov.yml +0 -0
  17. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/.github/workflows/build.yaml +0 -0
  18. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/.github/workflows/prepare_test_data.yaml +0 -0
  19. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/.github/workflows/release.yaml +0 -0
  20. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/.github/workflows/test.yaml +0 -0
  21. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/.gitignore +0 -0
  22. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/.mypy.ini +0 -0
  23. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/.readthedocs.yaml +0 -0
  24. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/LICENSE +0 -0
  25. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/docs/Makefile +0 -0
  26. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/docs/_static/.gitkeep +0 -0
  27. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/docs/_templates/.gitkeep +0 -0
  28. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/docs/_templates/autosummary/class.rst +0 -0
  29. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/docs/api.md +0 -0
  30. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/docs/changelog.md +0 -0
  31. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/docs/conf.py +0 -0
  32. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/docs/contributing.md +0 -0
  33. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/docs/extensions/.gitkeep +0 -0
  34. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/docs/extensions/typed_returns.py +0 -0
  35. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/docs/index.md +0 -0
  36. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/docs/make.bat +0 -0
  37. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/docs/references.bib +0 -0
  38. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/docs/references.md +0 -0
  39. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/docs/template_usage.md +0 -0
  40. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/src/spatialdata_io/__init__.py +0 -0
  41. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/src/spatialdata_io/_constants/__init__.py +0 -0
  42. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/src/spatialdata_io/_constants/_constants.py +0 -0
  43. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/src/spatialdata_io/_constants/_enum.py +0 -0
  44. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/src/spatialdata_io/_docs.py +0 -0
  45. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/src/spatialdata_io/_utils.py +0 -0
  46. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/src/spatialdata_io/converters/__init__.py +0 -0
  47. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/src/spatialdata_io/experimental/__init__.py +0 -0
  48. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/src/spatialdata_io/readers/__init__.py +0 -0
  49. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/src/spatialdata_io/readers/_utils/__init__.py +0 -0
  50. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/src/spatialdata_io/readers/_utils/_read_10x_h5.py +0 -0
  51. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/src/spatialdata_io/readers/_utils/_utils.py +0 -0
  52. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/src/spatialdata_io/readers/codex.py +0 -0
  53. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/src/spatialdata_io/readers/curio.py +0 -0
  54. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/src/spatialdata_io/readers/dbit.py +0 -0
  55. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/src/spatialdata_io/readers/iss.py +0 -0
  56. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/src/spatialdata_io/readers/mcmicro.py +0 -0
  57. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/src/spatialdata_io/readers/merscope.py +0 -0
  58. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/src/spatialdata_io/readers/seqfish.py +0 -0
  59. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/src/spatialdata_io/readers/steinbock.py +0 -0
  60. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/src/spatialdata_io/readers/stereoseq.py +0 -0
  61. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/src/spatialdata_io/readers/visium.py +0 -0
  62. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/tests/__init__.py +0 -0
  63. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/tests/converters/__init__.py +0 -0
  64. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/tests/converters/test_legacy_anndata.py +0 -0
  65. {spatialdata_io-0.1.3.post0 → spatialdata_io-0.1.4}/tests/test_basic.py +0 -0
@@ -23,7 +23,7 @@ repos:
23
23
  hooks:
24
24
  - id: isort
25
25
  - repo: https://github.com/pre-commit/mirrors-mypy
26
- rev: v1.10.1
26
+ rev: v1.11.0
27
27
  hooks:
28
28
  - id: mypy
29
29
  additional_dependencies: [numpy, types-PyYAML]
@@ -70,7 +70,7 @@ repos:
70
70
  - flake8-bugbear
71
71
  - flake8-blind-except
72
72
  - repo: https://github.com/asottile/pyupgrade
73
- rev: v3.16.0
73
+ rev: v3.17.0
74
74
  hooks:
75
75
  - id: pyupgrade
76
76
  args: [--py3-plus, --py39-plus, --keep-runtime-typing]
@@ -10,6 +10,14 @@ and this project adheres to [Semantic Versioning][].
10
10
 
11
11
  ## [0.1.4] - xxxx-xx-xx
12
12
 
13
+ ## [0.1.4] - 2024-08-07
14
+
15
+ ### Changed
16
+
17
+ - (Xenium) changed default target of table to labels; radii of circles computed from cells, not nuclei #179
18
+ - (Visium HD) changed default geometry to squares from circles for the bins; added parameter to choose #183
19
+ - (CosMx) dropping points element with zero-length from the cosmx reader #191
20
+
13
21
  ## [0.1.3] - 2024-07-03
14
22
 
15
23
  ### Added
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: spatialdata-io
3
- Version: 0.1.3.post0
3
+ Version: 0.1.4
4
4
  Summary: SpatialData IO for common techs
5
5
  Project-URL: Documentation, https://spatialdata-io.readthedocs.io/
6
6
  Project-URL: Source, https://github.com/scverse/spatialdata-io
@@ -49,6 +49,7 @@ Requires-Dist: readfcs
49
49
  Requires-Dist: scanpy
50
50
  Requires-Dist: scikit-image
51
51
  Requires-Dist: spatialdata>=0.2.1
52
+ Requires-Dist: tifffile>=2023.8.12
52
53
  Provides-Extra: dev
53
54
  Requires-Dist: bump2version; extra == 'dev'
54
55
  Requires-Dist: pre-commit; extra == 'dev'
@@ -82,17 +83,20 @@ Description-Content-Type: text/markdown
82
83
 
83
84
  This package contains reader functions to load common spatial omics formats into SpatialData. Currently, we provide support for:
84
85
 
85
- - 10x Genomics Visium
86
- - 10x Genomics Visium HD
87
- - 10x Genomics Xenium
88
- - Akoya PhenoCycler (formerly CODEX)
89
- - Curio Seeker
86
+ - 10x Genomics Visium®
87
+ - 10x Genomics Visium HD®
88
+ - 10x Genomics Xenium®
89
+ - Akoya PhenoCycler® (formerly CODEX®)
90
+ - Curio Seeker®
90
91
  - DBiT-seq
91
92
  - MCMICRO (output data)
92
- - NanoString CosMx
93
+ - NanoString CosMx®
94
+ - Spatial Genomics GenePS® (seqFISH)
93
95
  - Steinbock (output data)
94
- - STOmics Stereo-seq
95
- - Vizgen MERSCOPE (MERFISH)
96
+ - STOmics Stereo-seq®
97
+ - Vizgen MERSCOPE® (MERFISH)
98
+
99
+ Note: all mentioned technologies are registered trademarks of their respective companies.
96
100
 
97
101
  ## Getting started
98
102
 
@@ -129,9 +133,13 @@ If you found a bug, please use the [issue tracker][issue-tracker].
129
133
  Technologies that can be read into `SpatialData` objects using third-party libraries:
130
134
 
131
135
  - METASPACE (MALDI, ...): [metaspace-converter](https://github.com/metaspace2020/metaspace-converter)
132
- - PhenoCycler: [SOPA](https://github.com/gustaveroussy/sopa)
133
- - MACSima: [SOPA](https://github.com/gustaveroussy/sopa)
134
- - Hyperion (Imaging Mass Cytometry): [SOPA](https://github.com/gustaveroussy/sopa)
136
+ - PhenoCycler®: [SOPA](https://github.com/gustaveroussy/sopa)
137
+ - MACSima®: [SOPA](https://github.com/gustaveroussy/sopa)
138
+ - Hyperion® (Imaging Mass Cytometry): [SOPA](https://github.com/gustaveroussy/sopa)
139
+
140
+ ## Disclaimer
141
+
142
+ This library is community maintained and is not officially endorsed by the aforementioned spatial technology companies. As such, we cannot offer any warranty of the correctness of the representation. Furthermore, we cannot ensure the correctness of the readers for every data version as the technologies evolve and update their formats. If you find a bug or notice a misrepresentation of the data please report it via our [Bug Tracking System](https://github.com/scverse/spatialdata-io/issues?q=sort%3Aupdated-desc+is%3Aissue+is%3Aopen) so that it can be addressed either by the maintainers of this library or by the community.
135
143
 
136
144
  ## Citation
137
145
 
@@ -12,17 +12,20 @@
12
12
 
13
13
  This package contains reader functions to load common spatial omics formats into SpatialData. Currently, we provide support for:
14
14
 
15
- - 10x Genomics Visium
16
- - 10x Genomics Visium HD
17
- - 10x Genomics Xenium
18
- - Akoya PhenoCycler (formerly CODEX)
19
- - Curio Seeker
15
+ - 10x Genomics Visium®
16
+ - 10x Genomics Visium HD®
17
+ - 10x Genomics Xenium®
18
+ - Akoya PhenoCycler® (formerly CODEX®)
19
+ - Curio Seeker®
20
20
  - DBiT-seq
21
21
  - MCMICRO (output data)
22
- - NanoString CosMx
22
+ - NanoString CosMx®
23
+ - Spatial Genomics GenePS® (seqFISH)
23
24
  - Steinbock (output data)
24
- - STOmics Stereo-seq
25
- - Vizgen MERSCOPE (MERFISH)
25
+ - STOmics Stereo-seq®
26
+ - Vizgen MERSCOPE® (MERFISH)
27
+
28
+ Note: all mentioned technologies are registered trademarks of their respective companies.
26
29
 
27
30
  ## Getting started
28
31
 
@@ -59,9 +62,13 @@ If you found a bug, please use the [issue tracker][issue-tracker].
59
62
  Technologies that can be read into `SpatialData` objects using third-party libraries:
60
63
 
61
64
  - METASPACE (MALDI, ...): [metaspace-converter](https://github.com/metaspace2020/metaspace-converter)
62
- - PhenoCycler: [SOPA](https://github.com/gustaveroussy/sopa)
63
- - MACSima: [SOPA](https://github.com/gustaveroussy/sopa)
64
- - Hyperion (Imaging Mass Cytometry): [SOPA](https://github.com/gustaveroussy/sopa)
65
+ - PhenoCycler®: [SOPA](https://github.com/gustaveroussy/sopa)
66
+ - MACSima®: [SOPA](https://github.com/gustaveroussy/sopa)
67
+ - Hyperion® (Imaging Mass Cytometry): [SOPA](https://github.com/gustaveroussy/sopa)
68
+
69
+ ## Disclaimer
70
+
71
+ This library is community maintained and is not officially endorsed by the aforementioned spatial technology companies. As such, we cannot offer any warranty of the correctness of the representation. Furthermore, we cannot ensure the correctness of the readers for every data version as the technologies evolve and update their formats. If you find a bug or notice a misrepresentation of the data please report it via our [Bug Tracking System](https://github.com/scverse/spatialdata-io/issues?q=sort%3Aupdated-desc+is%3Aissue+is%3Aopen) so that it can be addressed either by the maintainers of this library or by the community.
65
72
 
66
73
  ## Citation
67
74
 
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '0.1.3.post0'
16
- __version_tuple__ = version_tuple = (0, 1, 3)
15
+ __version__ = version = '0.1.4'
16
+ __version_tuple__ = version_tuple = (0, 1, 4)
@@ -33,6 +33,7 @@ dependencies = [
33
33
  "dask-image",
34
34
  "pyarrow",
35
35
  "readfcs",
36
+ "tifffile>=2023.8.12",
36
37
  ]
37
38
 
38
39
  [project.optional-dependencies]
@@ -268,6 +268,8 @@ def from_legacy_anndata(adata: AnnData) -> SpatialData:
268
268
  keys = set(adata.uns[SPATIAL][dataset_id].keys())
269
269
  tissue_hires_scalef = None
270
270
  tissue_lowres_scalef = None
271
+ hires = None
272
+ lowres = None
271
273
  if SCALEFACTORS in keys:
272
274
  scalefactors = adata.uns[SPATIAL][dataset_id][SCALEFACTORS]
273
275
  if TISSUE_HIRES_SCALEF in scalefactors:
@@ -271,17 +271,18 @@ def cosmx(
271
271
  sub_table[CosmxKeys.INSTANCE_KEY] = sub_table[CosmxKeys.INSTANCE_KEY].astype("category")
272
272
  # we rename z because we want to treat the data as 2d
273
273
  sub_table.rename(columns={"z": "z_raw"}, inplace=True)
274
- points[f"{fov}_points"] = PointsModel.parse(
275
- sub_table,
276
- coordinates={"x": CosmxKeys.X_LOCAL_TRANSCRIPT, "y": CosmxKeys.Y_LOCAL_TRANSCRIPT},
277
- feature_key=CosmxKeys.TARGET_OF_TRANSCRIPT,
278
- instance_key=CosmxKeys.INSTANCE_KEY,
279
- transformations={
280
- fov: Identity(),
281
- "global": aff,
282
- "global_only_labels": aff,
283
- },
284
- )
274
+ if len(sub_table) > 0:
275
+ points[f"{fov}_points"] = PointsModel.parse(
276
+ sub_table,
277
+ coordinates={"x": CosmxKeys.X_LOCAL_TRANSCRIPT, "y": CosmxKeys.Y_LOCAL_TRANSCRIPT},
278
+ feature_key=CosmxKeys.TARGET_OF_TRANSCRIPT,
279
+ instance_key=CosmxKeys.INSTANCE_KEY,
280
+ transformations={
281
+ fov: Identity(),
282
+ "global": aff,
283
+ "global_only_labels": aff,
284
+ },
285
+ )
285
286
 
286
287
  # TODO: what to do with fov file?
287
288
  # if fov_file is not None:
@@ -14,6 +14,7 @@ import numpy as np
14
14
  import pandas as pd
15
15
  import scanpy as sc
16
16
  from dask_image.imread import imread
17
+ from geopandas import GeoDataFrame
17
18
  from imageio import imread as imread2
18
19
  from multiscale_spatial_image import MultiscaleSpatialImage
19
20
  from spatial_image import SpatialImage
@@ -38,6 +39,7 @@ def visium_hd(
38
39
  dataset_id: str | None = None,
39
40
  filtered_counts_file: bool = True,
40
41
  bin_size: int | list[int] | None = None,
42
+ bins_as_squares: bool = True,
41
43
  fullres_image_file: str | Path | None = None,
42
44
  load_all_images: bool = False,
43
45
  imread_kwargs: Mapping[str, Any] = MappingProxyType({}),
@@ -63,6 +65,9 @@ def visium_hd(
63
65
  bin_size
64
66
  When specified, load the data of a specific bin size, or a list of bin sizes. By default, it loads all the
65
67
  available bin sizes.
68
+ bins_as_squares
69
+ If `True`, the bins are represented as squares. If `False`, the bins are represented as circles. For a correct
70
+ visualization one should use squares.
66
71
  fullres_image_file
67
72
  Path to the full-resolution image. By default the image is searched in the ``{vx.MICROSCOPE_IMAGE!r}``
68
73
  directory.
@@ -219,19 +224,27 @@ def visium_hd(
219
224
  axes=("x", "y"),
220
225
  )
221
226
  # parse shapes
227
+ shapes_name = dataset_id + "_" + bin_size_str
228
+ radius = scalefactors[VisiumHDKeys.SCALEFACTORS_SPOT_DIAMETER_FULLRES] / 2.0
229
+ transformations = {
230
+ "global": transform_original,
231
+ "downscaled_hires": transform_hires,
232
+ "downscaled_lowres": transform_lowres,
233
+ }
222
234
  circles = ShapesModel.parse(
223
235
  adata.obsm["spatial"],
224
236
  geometry=0,
225
- radius=scalefactors[VisiumHDKeys.SCALEFACTORS_SPOT_DIAMETER_FULLRES] / 2.0,
237
+ radius=radius,
226
238
  index=adata.obs[VisiumHDKeys.INSTANCE_KEY].copy(),
227
- transformations={
228
- "global": transform_original,
229
- "downscaled_hires": transform_hires,
230
- "downscaled_lowres": transform_lowres,
231
- },
239
+ transformations=transformations,
232
240
  )
233
- shapes_name = dataset_id + "_" + bin_size_str
234
- shapes[shapes_name] = circles
241
+ if not bins_as_squares:
242
+ shapes[shapes_name] = circles
243
+ else:
244
+ squares_series = circles.buffer(radius, cap_style=3)
245
+ shapes[shapes_name] = ShapesModel.parse(
246
+ GeoDataFrame(geometry=squares_series), transformations=transformations
247
+ )
235
248
 
236
249
  # parse table
237
250
  adata.obs[VisiumHDKeys.REGION_KEY] = shapes_name
@@ -56,7 +56,7 @@ def xenium(
56
56
  *,
57
57
  cells_boundaries: bool = True,
58
58
  nucleus_boundaries: bool = True,
59
- cells_as_circles: bool = True,
59
+ cells_as_circles: bool | None = None,
60
60
  cells_labels: bool = True,
61
61
  nucleus_labels: bool = True,
62
62
  transcripts: bool = True,
@@ -96,10 +96,8 @@ def xenium(
96
96
  nucleus_boundaries
97
97
  Whether to read nucleus boundaries (polygons).
98
98
  cells_as_circles
99
- Whether to read cells also as circles. Useful for performant visualization. The radii of the nuclei,
100
- not the ones of cells, will be used; using the radii of cells would make the visualization too cluttered
101
- (the cell boundaries are computed as a maximum expansion of the nuclei location and therefore the
102
- corresponding circles would show considerable overlap).
99
+ Whether to read cells also as circles (the center and the radius of each circle is computed from the
100
+ corresponding labels cell).
103
101
  cells_labels
104
102
  Whether to read cell labels (raster). The polygonal version of the cell labels are simplified
105
103
  for visualization purposes, and using the raster version is recommended for analysis.
@@ -128,7 +126,34 @@ def xenium(
128
126
  Returns
129
127
  -------
130
128
  :class:`spatialdata.SpatialData`
129
+
130
+ Notes
131
+ -----
132
+ Old versions. Until spatialdata-io v0.1.3post0: previously, `cells_as_circles` was `True` by default; the table was associated to the
133
+ circles when `cells_as_circles` was `True`, and the table was associated to the polygons when `cells_as_circles`
134
+ was `False`; the radii of the circles were computed form the nuclei instead of the cells.
135
+
136
+ Performance. You can improve visualization performance (at the cost of accuracy) by setting `cells_as_circles` to `True`.
137
+
138
+ Examples
139
+ --------
140
+ This code shows how to change the annotation target of the table from the cell circles to the cell labels.
141
+ >>> from spatialdata_io import xenium
142
+ >>> sdata = xenium("path/to/raw/data", cells_as_circles=True)
143
+ >>> sdata["table"].obs["region"] = "cell_labels"
144
+ >>> sdata.set_table_annotates_spatialelement(
145
+ ... table_name="table", region="cell_labels", region_key="region", instance_key="cell_labels"
146
+ ... )
147
+ >>> sdata.write("path/to/data.zarr")
131
148
  """
149
+ if cells_as_circles is None:
150
+ cells_as_circles = True
151
+ warnings.warn(
152
+ "The default value of `cells_as_circles` will change to `False` in the next release. "
153
+ "Please pass `True` explicitly to maintain the current behavior.",
154
+ DeprecationWarning,
155
+ stacklevel=3,
156
+ )
132
157
  image_models_kwargs, labels_models_kwargs = _initialize_raster_models_kwargs(
133
158
  image_models_kwargs, labels_models_kwargs
134
159
  )
@@ -138,7 +163,7 @@ def xenium(
138
163
  # to trigger the warning if the version cannot be parsed
139
164
  version = _parse_version_of_xenium_analyzer(specs, hide_warning=False)
140
165
 
141
- specs["region"] = "cell_circles" if cells_as_circles else "cell_boundaries"
166
+ specs["region"] = "cell_circles" if cells_as_circles else "cell_labels"
142
167
 
143
168
  # the table is required in some cases
144
169
  if not cells_table:
@@ -210,14 +235,16 @@ def xenium(
210
235
  if cell_labels_indices_mapping is not None and table is not None:
211
236
  if not pd.DataFrame.equals(cell_labels_indices_mapping["cell_id"], table.obs[str(XeniumKeys.CELL_ID)]):
212
237
  warnings.warn(
213
- "The cell_id column in the cell_labels_table does not match the cell_id column derived from the cell "
214
- "labels data. This could be due to trying to read a new version that is not supported yet. Please "
215
- "report this issue.",
238
+ "The cell_id column in the cell_labels_table does not match the cell_id column derived from the "
239
+ "cell labels data. This could be due to trying to read a new version that is not supported yet. "
240
+ "Please report this issue.",
216
241
  UserWarning,
217
242
  stacklevel=2,
218
243
  )
219
244
  else:
220
245
  table.obs["cell_labels"] = cell_labels_indices_mapping["label_index"]
246
+ if not cells_as_circles:
247
+ table.uns[TableModel.ATTRS_KEY][TableModel.INSTANCE_KEY] = "cell_labels"
221
248
 
222
249
  if nucleus_boundaries:
223
250
  polygons["nucleus_boundaries"] = _get_polygons(
@@ -506,7 +533,7 @@ def _get_tables_and_circles(
506
533
  table = TableModel.parse(adata, region=specs["region"], region_key="region", instance_key=str(XeniumKeys.CELL_ID))
507
534
  if cells_as_circles:
508
535
  transform = Scale([1.0 / specs["pixel_size"], 1.0 / specs["pixel_size"]], axes=("x", "y"))
509
- radii = np.sqrt(adata.obs[XeniumKeys.CELL_NUCLEUS_AREA].to_numpy() / np.pi)
536
+ radii = np.sqrt(adata.obs[XeniumKeys.CELL_AREA].to_numpy() / np.pi)
510
537
  circles = ShapesModel.parse(
511
538
  circ,
512
539
  geometry=0,
@@ -51,13 +51,13 @@ def test_roundtrip_with_data_limits() -> None:
51
51
  "dataset,expected",
52
52
  [
53
53
  ("Xenium_V1_human_Breast_2fov_outs", "{'y': (0, 3529), 'x': (0, 5792), 'z': (10, 25)}"),
54
- ("Xenium_V1_human_Lung_2fov_outs", "{'y': (-1, 3556), 'x': (0, 5794), 'z': (7, 32)}"),
54
+ ("Xenium_V1_human_Lung_2fov_outs", "{'y': (0, 3553), 'x': (0, 5793), 'z': (7, 32)}"),
55
55
  ],
56
56
  )
57
57
  def test_example_data(dataset: str, expected: str) -> None:
58
58
  f = Path("./data") / dataset
59
59
  assert f.is_dir()
60
- sdata = xenium(f)
60
+ sdata = xenium(f, cells_as_circles=False)
61
61
  from spatialdata import get_extent
62
62
 
63
63
  extent = get_extent(sdata, exact=False)