Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spatialdata object created from remote .zarr store does not preserve "path" property #879

Open
adkinsrs opened this issue Feb 14, 2025 · 0 comments

Comments

@adkinsrs
Copy link

Local representation of the SpatialData object when read in locally. This is a Visium HD dataset that I created originally using spatialdata_io.visium_hd + some post-processing stuff.

SpatialData object, with associated Zarr store: /<path>/11692b64-b34a-4dbe-adc9-784a87a7a856.zarr
├── Images
│     ├── 'spatialdata_hires_image': DataArray[cyx] (3, 4352, 6000)
│     └── 'spatialdata_lowres_image': DataArray[cyx] (3, 435, 600)
├── Shapes
│     └── 'spatialdata_square_008um': GeoDataFrame shape: (127839, 1) (2D shapes)
└── Tables
      ├── 'square_008um': AnnData (127839, 19059)
      └── 'table': AnnData (127839, 19059)
with coordinate systems:
    ▸ 'downscaled_hires', with elements:
        spatialdata_hires_image (Images), spatialdata_square_008um (Shapes)
    ▸ 'downscaled_lowres', with elements:
        spatialdata_lowres_image (Images), spatialdata_square_008um (Shapes)
    ▸ 'global', with elements:
        spatialdata_square_008um (Shapes)

Recommendation: attach a minimal working example
Generally, the easier it is for us to reproduce the issue, the faster we can work on it. It is not required, but if you can, please:

Reproducible example

This is a public dataset and the datastore should be downloadable

import spatialdata as sd
rem_path = "https://devel.umgear.org/datasets/spatial/11692b64-b34a-4dbe-adc9-784a87a7a856.zarr"
sdata = sd.read_zarr(rem_path, selection=["images", "tables"])
print(sdata)
# ERROR

Describe the bug

This isn't the largest issue as I do not see a real-world situation were I have to print "sdata" outside of debugging but I'm sure this issue would have downstream effects elsewhere. It seems that the "path" property of the SpatialData object is not created.

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/homebrew/lib/python3.12/site-packages/spatialdata/_core/spatialdata.py", line 1971, in __repr__
    return self._gen_repr()
           ^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.12/site-packages/spatialdata/_core/spatialdata.py", line 2121, in _gen_repr
    elements_only_in_sdata, elements_only_in_zarr = self._symmetric_difference_with_zarr_store()
                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.12/site-packages/spatialdata/_core/spatialdata.py", line 1105, in _symmetric_difference_with_zarr_store
    elements_in_zarr = self.elements_paths_on_disk()
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.12/site-packages/spatialdata/_core/spatialdata.py", line 1073, in elements_paths_on_disk
    store = parse_url(self.path, mode="r").store
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'store'

Expected behavior
The SpatialData object is printed much like the local representation

Desktop (optional):

  • Tested in MacOS Sequoia 15.3 as well as a Dockerized Ubuntu:jammy image

Additional context
Relevant package versions. If you need me to go into a deeper dive, let me know

Python 3.12.7

spatialdata==0.3.0
spatialdata_io==0.1.6
pandas==2.2.1
anndata==0.10.6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants