You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Legend coloring doesn't match with plot in render_shapes #104
I define some categorical annotations: "categorical": ["a", "a", "b", "c", "d"],, but when I plot them the a category is colored only once, while the d is colored twice.
import numpy as np
import pandas as pd
from anndata import AnnData
from numpy.random import default_rng
from spatialdata import SpatialData
import spatialdata_plot
from spatialdata.models import TableModel
from spatialdata.datasets import blobs
RNG = default_rng(42)
adata_circles = AnnData(
RNG.normal(size=(5, 3)),
var=pd.DataFrame(index=["gene_h", "gene_k", "gene_l"]),
obs=pd.DataFrame(
{
"categorical": ["a", "a", "b", "c", "d"],
"region": "blobs_circles",
"instance_id": np.arange(5),
}
),
)
sdata = blobs()
adata_circles.obs["categorical"] = adata_circles.obs["categorical"].astype("category")
adata_circles.obs["region"] = adata_circles.obs["region"].astype("category")
adata_circles = TableModel.parse(adata_circles, region="blobs_circles", region_key="region", instance_key="instance_id")
sdata_circles = SpatialData(shapes={"blobs_circles": sdata["blobs_circles"]}, table=adata_circles)
# let's add two numerical columns to the GeoDataFrame
sdata_circles["blobs_circles"]["feature_m"] = RNG.normal(size=(5))
sdata_circles["blobs_circles"]["feature_n"] = RNG.normal(size=(5))
print(sdata_circles.table.obs.categorical)
# sdata_circles.pl.render_shapes(color="categorical").pl.show(title="categorical")
Activity
LucaMarconato commentedon Jun 20, 2023
I also noticed that in the new aggregation notebook.
I define some categorical annotations:
"categorical": ["a", "a", "b", "c", "d"],, but when I plot them theacategory is colored only once, while thedis colored twice.