CC @LucaMarconato
The merging utility in scverse/spatialdata (i.e. concatenate) forces users to define SpatialData objects in a dictionary to avoid duplicated elements (by manually giving names for deduplication). This is currently not necessary in HelenaLC/spatialdataR (i.e. combine) and a default set of keys are applied to element names.
The R approach I favor since the method works more smoothly, but we can also follow a similar approach giving names to sd's, thus both calls below would work but in second the user defines these keys.
combine(sdata)
combine(list(s1 = sdata, s2 = sdata)
Here are behaviours of two implementations:
In scverse/spatialdata:
>>> from spatialdata import concatenate
>>> concatenate([sdata, sdata])
KeyError: 'Images must have unique names across the SpatialData objects to concatenate. Please pass a `dict[str, SpatialData]` to `concatenate()` to address this (see docstring).'
>>> concatenate({"s1": sdata, "s2": sdata})
SpatialData object
├── Images
│ ├── 'blobs_image-s1': DataArray[cyx] (3, 64, 64)
│ ├── 'blobs_image-s2': DataArray[cyx] (3, 64, 64)
│ ├── 'blobs_multiscale_image-s1': DataTree[cyx] (3, 64, 64), (3, 32, 32), (3, 16, 16)
│ └── 'blobs_multiscale_image-s2': DataTree[cyx] (3, 64, 64), (3, 32, 32), (3, 16, 16)
├── Labels
│ ├── 'blobs_labels-s1': DataArray[yx] (64, 64)
│ ├── 'blobs_labels-s2': DataArray[yx] (64, 64)
│ ├── 'blobs_multiscale_labels-s1': DataTree[yx] (64, 64), (32, 32), (16, 16)
│ └── 'blobs_multiscale_labels-s2': DataTree[yx] (64, 64), (32, 32), (16, 16)
...
In HelenaLC/spatialdataR:
> combine(sdata, sdata)
class: SpatialData
- images(4):
- blobs_image (3,64,64)
- blobs_multiscale_image (3,64,64)
- blobs_image.1 (3,64,64)
- blobs_multiscale_image.1 (3,64,64)
...
CC @LucaMarconato
The merging utility in
scverse/spatialdata(i.e.concatenate) forces users to define SpatialData objects in a dictionary to avoid duplicated elements (by manually giving names for deduplication). This is currently not necessary inHelenaLC/spatialdataR(i.e.combine) and a default set of keys are applied to element names.The R approach I favor since the method works more smoothly, but we can also follow a similar approach giving names to sd's, thus both calls below would work but in second the user defines these keys.
combine(sdata)combine(list(s1 = sdata, s2 = sdata)Here are behaviours of two implementations:
In
scverse/spatialdata:In
HelenaLC/spatialdataR: