Skip to content

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

@spatts14

Description

@spatts14

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions