scverse / scverse/spatialdata

Table `region_key` column is not `categorical` anymore after `concatenate()`

Open
#221 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
394
Forks
95
Avg merge
4d 3h
Merged PRs (30d)
7

Description

While working on the Lundeberg data I have a list of SpatialData objects for which the table has a region_key column with a categorical dtype. After concatenating the table I get a table which has dtype object for that column.

I am simply doing

sdata_patient1_visium_expression.table.obs['region'] = sdata_patient1_visium_expression.table.obs['region'].astype('category')

for the moment, but we'll have to fix this (I think the problem is concatenate() but I haven't investigated), add tests, and remove the line above from the Lundeberg notebook.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the concatenate() entry point used for the list of SpatialData tables and inspect how the table.obs region_key column's categorical dtype is handled. Add regression tests for concatenation, then remove the astype('category') workaround from the Lundeberg notebook and confirm the concatenated column remains categorical.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.