gustaveroussy / sopa

Technology-invariant pipeline for spatial omics analysis (Xenium / Visium HD / MERSCOPE / CosMx / PhenoCycler / MACSima / ...) that scales to millions of cells
https://gustaveroussy.github.io/sopa/
BSD 3-Clause "New" or "Revised" License
129 stars 15 forks source link

Crop Feature for API users #102

Closed marsdenl closed 2 months ago

marsdenl commented 2 months ago

Hey there,

Thanks again for creating such a useful platform. I might have missed this (and apologies if I have) but I was wondering whether there was also a feature to carry out a crop in the python API workflow. I can only find it in the command line version. Thanks!

quentinblampey commented 2 months ago

Hello @marsdenl, You can use sopa.utils.polygon_crop.polygon_selection (the usage is not mentioned in the tutorials, indeed)

It's easier to use it with a normal Python script. In that case, you can simply run:

from sopa.utils.polygon_crop import polygon_selection

polygon_selection(sdata)

If using a cluster, you'll need to use the other arguments (intermediate_image, intermediate_polygon) If using a jupyter notebook, run %matplotlib tk before (else, it will not be open in an interactive window, and it will say that "vertices" is not existing)

I hope that helps! I may update the docs in the future with a more detailed explanation

marsdenl commented 2 months ago

Hey Quentin,

Brilliant! I should've spotted it my bad. Thank you for the directions of use, it helps a lot. I'll give that a go.

Et merci encore pour SOPA. Franchement c'est un outil vraiment top, tu geres.

Merci

Luc