scverse / scverse/napari-spatialdata

Legend (categorical obs column) for scatterplot widget not consistent

Open
#339 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
90
Forks
25
Avg merge
22m
Merged PRs (30d)
1

Description

Originally discovered here: https://github.com/scverse/napari-spatialdata/issues/328#issuecomment-2464885435.

To reproduce:

import numpy as np
import scanpy as sc

from spatialdata.datasets import blobs

np.random.seed(10)

sdata = blobs(length=1000, n_channels=3)

sc.pp.pca(
    sdata["table"],
    copy=False,
)

sc.pp.neighbors(
    sdata["table"],
    copy=False,
)
sc.tl.umap(
    sdata["table"],
    copy=False,
)

sdata["table"].obs["new_category"] = np.random.randint(0, 15, size=len(sdata["table"].obs))
sdata["table"].obs["new_category"] = sdata["table"].obs["new_category"].astype("category")

sc.pl.umap(sdata.tables["table"], color=["new_category"], show=True)


from napari_spatialdata import Interactive

Interactive(sdata)

Finally, open the scatterplot widget and make the UMAP as below (you need to open the labels layer first, since it is the one annotated by the table.

This is what is given (the two plots should have the same colors, but they don't).

Image
Image

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

Run the provided Python reproduction with spatialdata.datasets.blobs and the napari-spatialdata Interactive entry point, then open the scatterplot widget for the categorical obs column. Compare its legend and colors with the sc.pl.umap output. Done means both plots use the same categorical colors and legend mapping.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.