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

Do transformations affect Points? #384

Open
BaldanMatt opened this issue Nov 7, 2024 · 0 comments
Open

Do transformations affect Points? #384

BaldanMatt opened this issue Nov 7, 2024 · 0 comments

Comments

@BaldanMatt
Copy link

BaldanMatt commented Nov 7, 2024

I'm working with MERSCOPE data.
The spatial data that i load right from the MERSCOPE OUTPUT Structure is of something like this:
SpatialData object, with associated Zarr store: /home/dati/embryo-mouse/merscope/E15_5/region_0/data.zarr
├── Images
│ └── 'E15_5_region_0_z3': DataTree[cyx] (5, 86330, 59935), (5, 43165, 29967), (5, 21582, 14983), (5, 10791, 7491), (5, 5395, 3745)
├── Points
│ └── 'E15_5_region_0_transcripts': DataFrame with shape: (, 9) (2D points)
├── Shapes
│ └── 'E15_5_region_0_polygons': GeoDataFrame shape: (219525, 9) (2D shapes)
└── Tables
└── 'table': AnnData (219525, 296)
with coordinate systems:
▸ 'global', with elements:
E15_5_region_0_z3 (Images), E15_5_region_0_transcripts (Points), E15_5_region_0_polygons (Shapes)}}

These are the statistics about the Transcripts positions:
x y Unnamed: 0 fov ... cell_id global_z
count 3.930295e+07 3.930295e+07 3.930295e+07 3.930295e+07 ... 3.930295e+07 3.930295e+07
mean 3.519436e+03 4.071058e+03 8.585455e+02 5.536964e+02 ... 1.020035e+18 2.394110e+00
std 1.312390e+03 2.182720e+03 1.228028e+03 2.576797e+02 ... 9.342115e+17 1.932452e+00
min -1.308858e+01 -8.926300e+01 0.000000e+00 0.000000e+00 ... -1.000000e+00 0.000000e+00
25% 2.625811e+03 1.975680e+03 1.880000e+02 3.630000e+02 ... -1.000000e+00 1.000000e+00
50% 3.546634e+03 4.508889e+03 4.030000e+02 5.620000e+02 ... 1.875644e+18 2.000000e+00
75% 4.522057e+03 5.843982e+03 9.400000e+02 7.680000e+02 ... 1.875644e+18 4.000000e+00
max 6.434043e+03 9.206351e+03 1.203000e+04 1.028000e+03 ... 1.875644e+18 6.000000e+00

I want to render the points in overlay of the images and if my RAM permist also in overlay of the shapes. The combination of all three will probably be done using a spatial query to limit the things to display.

The micron_to_mosaic_pixel_transform.csv is:
[[ 9.25941849 0. 242.53416443]
[ 0. 9.25940895 940.61523438]
[ 0. 0. 1. ]]

Which is clearly already applied to images and shapes but is not applied to the points, because if i try to render before handling the transformation i get something like this:
Image

While if i set a transformation to the images that is the inverse of the scale and translation matrix above I get the desired result.
set_transformation(image_layer, transformation.inverse(), to_coordinate_system="mosaic")
Image

However, the points are a lot. And I wanted to display them in the larger scale. Because the size of a rendered point does not go below one pixel.

Therefore, I thought to do the opposite and apply the transformation to the points... however, it seems that Scale, Translation, Affine and such only affect the coordinate system, not the actual x and y coordinates of the points.

Like, If i Translation([500, ], axes=("x", )) I do not get what i expected, to have my points translated of 500 pixels to the right. ANd the same does not happen for other transformations. Do the transformaitons work differently for points?

I accept suggestions to improve the resolution of the second image, particularly if i want to look better at the points. I will ultimately select regions of the image to display accurately.

Best,

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