squidpy icon indicating copy to clipboard operation
squidpy copied to clipboard

Obs image layer is flipped in Napari

Open Tonyspuri opened this issue 2 years ago • 4 comments

... Hi all,

I was trying to use interactive mode with Napari. everything worked fine except when I try to plot genes or observations on top of my segmentation image, spots look to be flipped on the Y axis but couldn't find where it gets flipped. Using Squidpy from github main and Napari 0.4.17 Screenshot 2023-03-09 at 9 52 59 AM

Tonyspuri avatar Mar 09 '23 18:03 Tonyspuri

Hi @Tonyspuri , can you please provide a minimal reproducible example?

michalk8 avatar Mar 10 '23 21:03 michalk8

I was playing with Nanostring Spatial data mostly following the tutorial to read in the files, quality control etc.

Then I tried to run interactive mode, first I was setting up imagecontainer


imgs = []
for library_id in adata.uns["spatial"].keys():
    img = sq.im.ImageContainer(adata.uns["spatial"][library_id]["images"]["hires"], library_id=library_id)
    img.add_img(adata.uns["spatial"][library_id]["images"]["segmentation"], library_id=library_id, layer="segmentation")
    img["segmentation"].attrs["segmentation"] = True
    imgs.append(img)
img = sq.im.ImageContainer.concat(imgs)

and run interactive mode

viewer = img.interactive(adata, library_key='fov', library_id="1") Hires image and segmentation image overlay perfectly well but when I try to add Obs or genes layer it basically flips on the y axis.

Tonyspuri avatar Mar 13 '23 16:03 Tonyspuri

hi @Tonyspuri ,

this is because the obsm["spatial"] coordinates are flipped on the Y axis I believe. Think the best way is to flip them yourself manually. We won't support this napari implementation anymore as in few weeks we'll have a new format and napari plugin for scverse. Will try to remember to report here relevant documentation.

giovp avatar Mar 14 '23 13:03 giovp

@giovp Great, thanks a lot! I'll keep an eye out for a new format but shortterm try to flip the coordinates

Tonyspuri avatar Mar 14 '23 15:03 Tonyspuri

you can check the new spatialdate ecosystem for nanostring here: https://spatialdata.scverse.org/en/latest/tutorials/notebooks/notebooks/examples/technology_cosmx.html

giovp avatar Jul 07 '24 08:07 giovp