Skip to content

sdata.transform_to_coordinate_system not working any more after updating to V0.7.2 #388

Closed
scverse/spatialdata
#1077

Description

@LucaCalderoni

Hi!
I'm working on a xenium dataset and I would like to uniform the coordinates of labels (cells) and points (transcripts) to the global coordinate system. I used sdata.transform_to_coordinate_system('global'), but it just yields this error message:

Traceback (most recent call last):
File "", line 1, in
File "C:\Users\Desktop-user\anaconda3\envs\SpatialDataLatest_prova\Lib\site-packages\spatialdata_core\spatialdata.py", line 880, in transform_to_coordinate_system
transformed = sdata.transform_element_to_coordinate_system(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Desktop-user\anaconda3\envs\SpatialDataLatest_prova\Lib\site-packages\spatialdata_core\spatialdata.py", line 819, in transform_element_to_coordinate_system
transformed = transform(
^^^^^^^^^^
File "C:\Users\Desktop-user\anaconda3\envs\SpatialDataLatest_prova\Lib\functools.py", line 909, in wrapper
return dispatch(args[0].class)(*args, **kw)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Desktop-user\anaconda3\envs\SpatialDataLatest_prova\Lib\site-packages\spatialdata_core\operations\transform.py", line 443, in _
arrays.append(data[ax].to_dask_array(lengths=True).reshape(-1, 1))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Desktop-user\anaconda3\envs\SpatialDataLatest_prova\Lib\site-packages\dask\dataframe\dask_expr_collection.py", line 1422, in to_dask_array
chunks = self._validate_chunks(arr, lengths)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Desktop-user\anaconda3\envs\SpatialDataLatest_prova\Lib\site-packages\dask\dataframe\dask_expr_collection.py", line 2471, in _validate_chunks
raise ValueError(
ValueError: The number of items in 'lengths' does not match the number of partitions. 2 != 4

This is the structure of the sdata:

SpatialData object
├── Images
│ └── 'morphology_focus': DataTree[cyx] (4, 17098, 51187), (4, 8549, 25593), (4, 4274, 12796), (4, 2137, 6398), (4, 1068, 3199)
├── Labels
│ ├── 'cell_labels': DataTree[yx] (17098, 51187), (8549, 25593), (4274, 12796), (2137, 6398), (1068, 3199)
│ └── 'nucleus_labels': DataTree[yx] (17098, 51187), (8549, 25593), (4274, 12796), (2137, 6398), (1068, 3199)
├── Points
│ └── 'transcripts': DataFrame with shape: (, 11) (3D points)
├── Shapes
│ ├── 'cell_boundaries': GeoDataFrame shape: (162254, 1) (2D shapes)
│ ├── 'cell_circles': GeoDataFrame shape: (162254, 2) (2D shapes)
│ └── 'nucleus_boundaries': GeoDataFrame shape: (156628, 1) (2D shapes)
└── Tables
└── 'table': AnnData (162254, 377)
with coordinate systems:
▸ 'global', with elements:
morphology_focus (Images), cell_labels (Labels), nucleus_labels (Labels), transcripts (Points), cell_boundaries (Shapes), cell_circles (Shapes), nucleus_boundaries (Shapes)

It didn't happen before the update. I suspect the transcripts are the problem, because if I separately launch sdata.transform_element_to_coordinate_system('cell_labels','global') everything works correctly, but the same exact error pops up if I launch sdata.transform_element_to_coordinate_system('transcripts','global'). My python is V3.12.3.
Any advice is welcome!

Activity

  1. LucaMarconato commented on Feb 18, 2026

    @LucaMarconato
    Member

    Thanks for reporting! Tracked here scverse/spatialdata#1064, @melonora is already on it.

  2. melonora commented on Feb 20, 2026

    @melonora
    Collaborator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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