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

Loading Pre-Annotated Regions for Visium Analysis #41

Open
abadgerw opened this issue Nov 24, 2024 · 1 comment
Open

Loading Pre-Annotated Regions for Visium Analysis #41

abadgerw opened this issue Nov 24, 2024 · 1 comment

Comments

@abadgerw
Copy link

I have pre-annotated regions in QuPath and exported them as geoJSON files. Can these be loaded directly or converted in some way so that I may perform spatially-aware DE of my Visium data?

@lambdamoses
Copy link
Collaborator

Yes, I also do that. You can use sf::st_read() to read GeoJSON file as a sf data frame, make sure to set crs = NA; CRS is the different ways to project the globe onto a 2D map, which is irrelevant to histological space. The catch though is if the QuPath annotations have the same unit as the Visium coordinates. If you did the annotations with the full resolution image and the Visium coordinates are also in full res pixels, then they should match. If you have terra >= 1.17.83, then the image will appear flipped compared to QuPath so y would increase going up just as in the geometries so the geometries should match the images as well. Here's some pseudocode, say you saved your annotations in annotations.geojson:

library(sf)
g <- st_read("annotations.geojson", crs = NA)
annotGeometry(sfe, "annotations") <- g # suppose you have one sample

If you have multiple samples in the SFE object, you should add a column named "sample_id" specifying which geometry belongs to which sample.

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

2 participants