spatialdata icon indicating copy to clipboard operation
spatialdata copied to clipboard

Xenium 5k cannot be imported because of mismatch in morphology naming

Open spatts14 opened this issue 3 months ago • 4 comments

Issue:

I am trying to load a xenium file from the output from the machine using sdata sdata = xenium(xenium_path). It seems the xenium function expects the morpology names to be exactly like this morphology_focus_0000.ome.tif, morphology_focus_0001.ome.tif, etc.

However, the output from the machine gives them as the following: ch0000_dapi.ome.tif ch0001_atp1a1_cd45_e-cadherin.ome.tif ch0002_18s.ome.tif ch0003_alphasma_vimentin.ome.tif

I'm assuming this has recently changed by 10X on what their outputs from the machine are.

The exact error I am getting is as follows:

ValueError                                Traceback (most recent call last)
Cell In[3], [line 1](vscode-notebook-cell:?execution_count=3&line=1)
----> [1](vscode-notebook-cell:?execution_count=3&line=1) sdata = xenium(xenium_path)

File ~/PhD_projects/Xenium_5k_analysis_pipeline/xenium_5k/lib/python3.10/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/~/PhD_projects/Xenium_5k_analysis_pipeline/xenium_5k/lib/python3.10/site-packages/spatialdata_io/_utils.py:48) return f(*args, **kwargs)

File ~/PhD_projects/Xenium_5k_analysis_pipeline/xenium_5k/lib/python3.10/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/~/PhD_projects/Xenium_5k_analysis_pipeline/xenium_5k/lib/python3.10/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', 'ch0003_alphasma_vimentin.ome.tif', 'ch0002_18s.ome.tif', 'ch0001_atp1a1_cd45_e-cadherin.ome.tif'}

Expected behavior I would expect that sdata = xenium(xenium_path) would load the xenium output without issue.

Desktop (optional):

  • OS: 2.6 GHz 6-Core Intel Core i7 Mac; MacOS 15.6.1
  • Version of spatialdata '0.5.0'

Additional context I could manually rename the files, but each ROI outputs its own xenium folder and I will have 30+ samples. It would be great to update the code to address the name in output nomenclature from 10x

spatts14 avatar Oct 06 '25 21:10 spatts14

It looks like someone had the same problem https://github.com/scverse/spatialdata-io/issues/325#issue-3425909824 but has not been addressed

spatts14 avatar Oct 06 '25 23:10 spatts14

I encountered the same issue, arising from the following process: while downloads from 10x public Xenium datasets can be read by spatialdata, after resegmentation with xeniumranger, I encountered your same issues. I hypothesize that the issue arise from new naming convention by the updaded xeniumranger software.

my temporary solution: just change the name of the four images to the old style, will not be significant impact on downstream analysis

ZedaoLiu avatar Oct 31 '25 01:10 ZedaoLiu

Hi @ZedaoLiu, the latest spatialdata-io main (unreleased) should address the problem described here. Please let us know if it works for you.

A release will be made soon.

LucaMarconato avatar Nov 02 '25 18:11 LucaMarconato

Hi @ZedaoLiu, the latest spatialdata-io main (unreleased) should address the problem described here. Please let us know if it works for you.

A release will be made soon.

Hi @LucaMarconato , Thx!!! for your kind reply and contribution for such an extremely valuable tool spatialdata.

I also have a similar feature request, 10x Xenium now supports protein panels, I tried using spatialdata-io to load an example dataset , but there raises error that only 4 images are supported for morphology focus (while all protein subpanel images should be read in).

I would be greatly appreciated if your team could consider this request. Thank you again for your kind work.

ZedaoLiu avatar Nov 03 '25 00:11 ZedaoLiu