Skip to content

Support .obsm keys in render_labels(color=...) #587

@timtreis

Description

@timtreis

Feature request

render_labels(color=...) currently resolves keys from .obs columns and .var_names only. It would be useful to also support .obsm keys (or columns within obsm DataFrames).

Use case

In squidpy's tiling QC (sq.experimental.tl.calculate_tiling_qc), we compute several per-cell scores that logically belong in .obsm rather than polluting .obs:

# Current workaround: scores stored in .obs because sdata-plot can't read .obsm
# Ideally these would live in adata.obsm["tiling_qc"]
for col in combined.columns:
    adata.obs[col] = combined[col].values

Where the limitation lives

_validate_col_for_column_table() in src/spatialdata_plot/pl/utils.py (around line 2850) only checks:

col_for_color not in sdata[table_name].obs.columns and col_for_color not in sdata[table_name].var_names

No .obsm lookup is attempted.

Suggested behavior

Allow color="obsm_key:column" or similar syntax to reference a column within an .obsm DataFrame/array.

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