Skip to content

Allow customization of suffix separator when concatenating SpatialData objects #1139

@AlbertoFabbri93

Description

@AlbertoFabbri93

Hi, I would like to request a small customization option for spatialdata.concatenate() when passing a dictionary of SpatialData objects.

Currently, when a dictionary is passed, element names are made unique by appending the dictionary key as a suffix using - as the separator. For example:

concatenate({
    "sample1": sdata1,
    "sample2": sdata2,
})

renames spatial elements like:

cell_boundaries-sample1
cell_boundaries-sample2

The same -suffix convention is also applied to table region metadata, values in the region_key column, observation names, coordinate systems, and table names when applicable.

Would it be possible to add a parameter to control the separator used before the suffix?

For example:

concatenate(
    {
        "sample1": sdata1,
        "sample2": sdata2,
    },
    suffix_separator="_",
)

would produce:

cell_boundaries_sample1
cell_boundaries_sample2

Motivation

In some workflows, element names are later parsed or matched according to project-specific naming conventions. In these cases, underscores may be preferred over hyphens, or hyphens may conflict with downstream tools and naming rules.

At the moment, changing this behavior requires copying and modifying the internal _fix_ensure_unique_element_names() helper. This is inconvenient because the suffixing logic appears in several places within that function, so even a simple change to the separator requires multiple coordinated edits.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions