Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Legend (categorical obs column) for scatterplot widget not consistent #339

Open
LucaMarconato opened this issue Jan 5, 2025 · 1 comment

Comments

@LucaMarconato
Copy link
Member

LucaMarconato commented Jan 5, 2025

Originally discovered here: #328 (comment).

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

@LucaMarconato
Copy link
Member Author

  • we should add tests for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant