Xenium read error
Hi,
I am using spatialdata-io v0.3.0 and trying to read the data from the Xenium bundle with this command
xenium_bundle_path = "/path/to/xenium/data" zarr_path = "/path/to/workdir" sdata = xenium(xenium_bundle_path)
but I got this error:
ValueError: Expected files in the morphology focus directory to be named as morphology_focus_0000.ome.tif to morphology_focus_0003.ome.tif, found {'ch0000_dapi.ome.tif', 'ch0001_atp1a1_cd45_e-cadherin.ome.tif', 'ch0003_alphasma_vimentin.ome.tif', 'ch0002_18s.ome.tif'}
I think this may have happened because I am using new Xenium version and spatialdata-io doesn't support it yet:
Instrument software version | 4.0.1.4 Analysis version | xenium-4.0.1.0
Plus there's a warning like this
miniconda3/envs/squidpy/lib/python3.10/site-packages/spatialdata_io/_utils.py:48: UserWarning: The "cell_id" column in the cells metadata table does not match the "cell_id" column in the annotation table. This could be due to trying to read a new version that is not supported yet. Please report this issue.
hi, running into the problem. did you find any work around?
@philinscience No, but Seurat doesn't have this issue.
I have the same issue - it seems like 10X changed the morphology output names. The work around is manually renaming the morphology_focus files to match the expected output.
does https://github.com/scverse/spatialdata-io/pull/312 resolve the issue?
@whtns thanks for flagging.
All my packages are up to date and I've updated anndata to the most recent version (V0.12.2) and It still isn't working for me. Is there something I've missed?
# Name Version Build Channel
anndata 0.12.2 pypi_0 pypi
scanpy 1.11.4 pyhd8ed1ab_0 conda-forge
spatial-image 1.2.3 pyhd8ed1ab_1 conda-forge
spatialdata 0.5.0 pyhd8ed1ab_0 conda-forge
spatialdata-io 0.3.0 pyhd8ed1ab_0 conda-forge
squidpy 1.6.5 pyhd8ed1ab_0 conda-forge
This is the error I'm getting
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[4], [line 1](vscode-notebook-cell:?execution_count=4&line=1)
----> [1](vscode-notebook-cell:?execution_count=4&line=1) sdata = xenium(xenium_path)
File ~/miniforge3/envs/xenium_5k/lib/python3.12/site-packages/spatialdata_io/_utils.py:48, in deprecation_alias.<locals>.deprecation_decorator.<locals>.wrapper(*args, **kwargs)
46 class_name = f.__qualname__
47 rename_kwargs(f.__name__, kwargs, aliases, class_name)
---> [48](https://file+.vscode-resource.vscode-cdn.net/Users/sarapatti/PhD_projects/Xenium_5k_analysis_pipeline/~/miniforge3/envs/xenium_5k/lib/python3.12/site-packages/spatialdata_io/_utils.py:48) return f(*args, **kwargs)
File ~/miniforge3/envs/xenium_5k/lib/python3.12/site-packages/spatialdata_io/readers/xenium.py:298, in xenium(path, cells_boundaries, nucleus_boundaries, cells_as_circles, cells_labels, nucleus_labels, transcripts, morphology_mip, morphology_focus, aligned_images, cells_table, n_jobs, imread_kwargs, image_models_kwargs, labels_models_kwargs)
293 raise ValueError(
294 "Expected 1 (no segmentation kit) or 4 (segmentation kit) files in the morphology focus directory, "
295 f"found {len(files)}: {files}"
296 )
297 if files != {XeniumKeys.MORPHOLOGY_FOCUS_CHANNEL_IMAGE.value.format(i) for i in range(len(files))}:
--> [298](https://file+.vscode-resource.vscode-cdn.net/Users/sarapatti/PhD_projects/Xenium_5k_analysis_pipeline/~/miniforge3/envs/xenium_5k/lib/python3.12/site-packages/spatialdata_io/readers/xenium.py:298) raise ValueError(
299 "Expected files in the morphology focus directory to be named as "
300 f"{XeniumKeys.MORPHOLOGY_FOCUS_CHANNEL_IMAGE.value.format(0)} to "
301 f"{XeniumKeys.MORPHOLOGY_FOCUS_CHANNEL_IMAGE.value.format(len(files) - 1)}, found {files}"
302 )
303 if len(files) == 1:
304 channel_names = {
305 0: XeniumKeys.MORPHOLOGY_FOCUS_CHANNEL_0.value,
306 }
ValueError: Expected files in the morphology focus directory to be named as morphology_focus_0000.ome.tif to morphology_focus_0003.ome.tif, found {'ch0000_dapi.ome.tif', 'ch0001_atp1a1_cd45_e-cadherin.ome.tif', 'ch0002_18s.ome.tif', 'ch0003_alphasma_vimentin.ome.tif'}```
Hi @spatts14, it should now be addressed in main, but we haven't made a release of the code yet. Please pip install from GitHub and let us know if it addresses your problem.