scverse / spatialdata

An open and interoperable data framework for spatial omics data
https://spatialdata.scverse.org/
BSD 3-Clause "New" or "Revised" License
230 stars 43 forks source link

Error on the tutorial Deep learning example on image tiles #652

Closed aalia09123 closed 2 months ago

aalia09123 commented 2 months ago

Hi, I have been trying to follow the Deep learning example on image tiles tutorial on the spatialdata scverse website. However, I keep running into this error : KeyError: 'coords'. in the 'Preparing the Data' step. Could I please get some assistance with this?

angela18199 commented 2 months ago

I am getting the same error when I tried to run this notebook When I tried to load data, landmarks_sdata = sd.read_zarr(LANDMARKS_SDATA_PATH) gives me


KeyError Traceback (most recent call last) Cell In[37], line 4 1 bc_sc_atlas_adata = sc.read(BC_SC_ATLAS_PATH) 2 bc_sc_atlas_adata.obs["dataset"] = "atlas" ----> 4 xe_rep1_sdata = sd.read_zarr(XE_REP1_PATH) 5 xe_rep1_adata = xe_rep1_sdata["table"] 6 xe_rep1_adata.obs["dataset"] = "xe_rep1"

File ~/miniconda3/envs/py39_2/lib/python3.9/site-packages/spatialdata/_io/io_zarr.py:121, in read_zarr(store, selection) 119 f_elem = group[subgroup_name] 120 f_elem_store = os.path.join(f_store_path, f_elem.path) --> 121 shapes[subgroup_name] = _read_shapes(f_elem_store) 122 count += 1 123 logger.debug(f"Found {count} elements in {group}")

File ~/miniconda3/envs/py39_2/lib/python3.9/site-packages/spatialdata/_io/io_shapes.py:33, in _read_shapes(store, fmt) 30 assert isinstance(store, (str, Path)) 31 f = zarr.open(store, mode="r") ---> 33 coords = np.array(f["coords"]) 34 index = np.array(f["Index"]) 35 typ = fmt.attrs_from_dict(f.attrs.asdict())

File ~/miniconda3/envs/py39_2/lib/python3.9/site-packages/zarr/hierarchy.py:511, in Group.getitem(self, item) 509 raise KeyError(item) 510 else: --> 511 raise KeyError(item)

KeyError: 'coords'

I followed all the steps in the notebook and used the data provided. I am not sure why this doesn't work.

LucaMarconato commented 2 months ago

Thanks both for reporting. The error you are getting is due to a bug on an internal pipeline that we use to convert the raw datasets to Zarr and upload them to S3. We accidentally ran the pipeline using the latest unreleased version of spatialdata (main branch in GitHub), which introduces some changes in the file format (performance optimization).

The new unreleased version is backward compatible, but since it's unreleased you are being affected by the format change. We will release the new version of spatialdata ASAP so that the issue is fixed.

LucaMarconato commented 2 months ago

I just made a release for spatialdata, spatialdata-io, napari-spatialdata and spatialdata-plot. The packages should be available via pip within minutes, and should be available in conda earliest in a few hours and latest in 1-2 days.

tkcaccia commented 2 months ago

It sounds great. Thank you for your fast reply. Currently, spatialdata is at the version 0.2.1 Are we expecting the version 0.2.2?

LucaMarconato commented 2 months ago

Yes, you should be able to install 0.2.2 already from pip: https://pypi.org/project/spatialdata/

angela18199 commented 2 months ago

Thank you for the fast reply and quick fix!