Skip to content

get_extent switches x and y #335

@Sonja-Stockhaus

Description

@Sonja-Stockhaus

Hey @timtreis , @LucaMarconato ,

So in the branch feature/get_extent there is the new get_extent function which should be outsourced from spatialdata-plot.
I just compared it to the _get_extent function from spatialdata-plot and it looks like both compute the same numbers but the spatialdata output has the x and y coordinates switched which seems to be a bug. I added code to hopefully reproduce the issue.

Would be cool if you could have a look at it :)

import spatialdata as sd
import spatialdata_plot

# This example doesn't really work with blobs (bc it has identical x and y extents), so I used the example data from https://s3.embl.de/spatialdata/spatialdata-sandbox/visium_associated_xenium_io.zip
visium_sdata = sd.read_zarr("visium_associated_xenium_io.zarr")

print("Old function (from spatialdata-plot):")
print(spatialdata_plot.pl.utils._get_extent(visium_sdata))
# output format is [xmin, xmax, ymin, ymax], so for "global" I get xmax = 19505

image

print("New function (from spatialdata):")
print(sd._core.data_extent.get_extent(visium_sdata, coordinate_system="global"))
# This would imply ymax = 19505

image

print("Ground truth:")
print(visium_sdata.images)
# (c: 3, y: 21571, x: 19505) would mean the spatialdata output is incorrect because x and y are swapped

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🚨Something isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions