Issue occurs in certain case
- points elements contain 3D coordinates {x, y, z}
- query a 2D-cut with {y, x}
- element is transformed
Toy example
import spatialdata as sd
import spatialdata_plot
import numpy as np
from spatialdata.models import PointsModel
from spatialdata.transformations import set_transformation, Scale
from spatialdata.datasets import blobs
df = blobs()["blobs_points"].compute()[["x", "y", "genes"]].copy()
df["z"] = np.random.default_rng(0).uniform(
0, 10, len(df)
) # add 3D, as real readers emit
pts3d = PointsModel.parse(df, feature_key="genes") # create
set_transformation(pts3d, Scale([0.5, 2.0], axes=("x", "y")), "global") # non-Identity
sdata_3d = sd.SpatialData(points={"transcripts": pts3d})
X0, X1, Y0, Y1 = 60, 240, 20, 160
for qaxes, mn, mx in [
(["x", "y"], [X0, Y0], [X1, Y1]),
(["y", "x"], [Y0, X0], [Y1, X1]),
]:
r = sdata_3d.query.bounding_box(
axes=qaxes,
min_coordinate=mn,
max_coordinate=mx,
target_coordinate_system="global",
)
n = len(r["transcripts"]) if "transcripts" in r.points else "element dropped"
print(f"axes={str(qaxes):14s} -> {n}")
r.pl.render_points("transcripts", color="genes", size=3).pl.show(
colorbar=False, legend_loc=None, title="All transcripts"
)
Output:
axes=['x', 'y'] -> 25
axes=['y', 'x'] -> 16
Issue occurs in certain case
Toy example
Output:
axes=['x', 'y'] -> 25
axes=['y', 'x'] -> 16