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

Can't save transformation result #558

Closed
Ithinky opened this issue May 6, 2024 · 6 comments
Closed

Can't save transformation result #558

Ithinky opened this issue May 6, 2024 · 6 comments

Comments

@Ithinky
Copy link

Ithinky commented May 6, 2024

Hi,
Thanks for your great work in Spatial omics filed!
I used SpatialData to integrate two images and following the tutorial "Use landmark annotations to align multiple -omics layers". Everything went well, but when I wanted to save the result by save_transformations( ) , the information returned like this
image
. And the recommend function write_transformations( ) can't be used.
My SpatialData objects are here:
image
image

By the way, after alignment, where can I get the alignment relationship between pixel spots in two image, like spot1 in image1 is aligned to spot3 in image2?

I would appreciate it if you could help me!

@Ithinky Ithinky changed the title Can't save transformation reslut Can't save transformation result May 6, 2024
@LucaMarconato
Copy link
Member

Hi, thanks for reaching out! I would suggest using the code from this pull request (it will be merged soon, probably this week): #501

Here you can explicitly call write_element(), which will make sure that the annotations are saved to disk.

Regarding the second questions, we don't have yet explicit code for what you asked but you can easily implement it:

  • a super easy implementation (slow, but probably ok for Visium) is to call the query APIs for each Visium circle on the aligned coordinate system and see which circles are present in each of the two datasets
  • a better implementation (still easy to implement) is to first call sdata.subset() to create a SpatialData object (or more than one) containing only the shapes, then call sdata.transform_to_coordinate_system() to transform the data in the aligned coordinate system, and then use sjoin directly from geopandas to see which aligned shapes overlap. This is much faster than calling query as a single call will operate on all the Visium circles.

@Ithinky
Copy link
Author

Ithinky commented May 6, 2024

Thanks for your fast reply! I will try it.

@Ithinky
Copy link
Author

Ithinky commented May 8, 2024

How can I call write_element( ), I can't import it from spatialdata_io or spatialdata. Thank you again!
image

@melonora
Copy link
Collaborator

it is not an import. If you have a spatialdata object you can call it as a method of the spatialdata object directly, no import required. So for example my spatialdata object is called sdata and I have an element called registration_landmarks that I just added in memory to the object, the way to write it do disk is:

sdata.write_element("registration_landmarks")

Let us know if you have any issues!

@melonora
Copy link
Collaborator

btw just so you know the PR as @LucaMarconato stated is not merged yet, so if you would like to try you have to either clone the repo, checkout the PR using the github cli and perform an editable install, or have a bit of patience:)

@melonora
Copy link
Collaborator

@Ithinky getting back to you, we are cutting the release that includes the method in the following days. I will close this issue now.

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

3 participants