From 790ac1366c8846537b35028796109ed5c5d76a1f Mon Sep 17 00:00:00 2001 From: LLehner Date: Mon, 7 Aug 2023 23:51:11 +0200 Subject: [PATCH] Fix radius --- src/spatialdata_io/_constants/_constants.py | 1 + src/spatialdata_io/readers/stereoseq.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/spatialdata_io/_constants/_constants.py b/src/spatialdata_io/_constants/_constants.py index f9c76fe7..c750d6d8 100644 --- a/src/spatialdata_io/_constants/_constants.py +++ b/src/spatialdata_io/_constants/_constants.py @@ -171,6 +171,7 @@ class StereoseqKeys(ModeEnum): EXPRESSION = "expression" EXON = "exon" # cells + CELL_AREA = "area" CELL_ID = "id" GENECOUNT = "geneCount" DNBCOUNT = "dnbCount" diff --git a/src/spatialdata_io/readers/stereoseq.py b/src/spatialdata_io/readers/stereoseq.py index b0584a03..1d096344 100644 --- a/src/spatialdata_io/readers/stereoseq.py +++ b/src/spatialdata_io/readers/stereoseq.py @@ -201,9 +201,11 @@ def stereoseq( region_key=StereoseqKeys.REGION_KEY, instance_key=StereoseqKeys.INSTANCE_KEY, ) + + radii = np.sqrt(adata.obs[StereoseqKeys.CELL_AREA].to_numpy() / np.pi) shapes = { StereoseqKeys.REGION_KEY: ShapesModel.parse( - adata.obsm[StereoseqKeys.SPATIAL_KEY], geometry=0, radius=1, index=adata.obs[StereoseqKeys.INSTANCE_KEY] + adata.obsm[StereoseqKeys.SPATIAL_KEY], geometry=0, radius=radii, index=adata.obs[StereoseqKeys.INSTANCE_KEY] ) } sdata = SpatialData(images=images, labels=labels, table=table, points=points, shapes=shapes)