Closed PeifengJi closed 3 years ago
Hi @PeifengJi ,
thanks for the interest in Squidpy! I think there is a mismatch between the scale and the image passed to the image container. If you import anndate with sc.read_visium()
and the tif image in the imagecontaienr, the scale of the spot coordinates is the same of the image pixel. Here, it seems that the image is either the hires
or lowres
. If that's the case, the image container has a scale argument, where you can pass the scale stored in
adata.uns["spatial"][<your-library-id>]["scalefactors"]["tissue_hires_scalef"]
.
We made a tutorial to explain how these scale factors is related here: https://squidpy.readthedocs.io/en/stable/auto_tutorials/tutorial_read_spatial.html
let me know if that helps
Hi @giovp Thank you for the response! I have tried the method you provided. I have tired to use the tif image, issue is resolved. But, when I use the hires image stored in the AnnData object, unfortunately, the issue did not change. It resulted in exactly the same layout in the Napari. Below is my code:
Btw, what's your recommendation of the image resource for building the ImageContainer object, the original tif file or the image file stored in the AnnData object (hires)? Thank you!
hi @PeifengJi , sorry for late reply,
But, when I use the hires image stored in the AnnData object, unfortunately, the issue did not change. It resulted in exactly the same layout in the Napari. Below is my code:
yeah because the cooridnates in adata.obsm["spatial"]
are still in original tiff cooridnates. If they were however scaled, then the scale argument in imagecontainer would account for that. The docs should be clear
scale (float) – Scaling factor of the image with respect to the spatial coordinates saved in the accompanying anndata.AnnData.
Btw, what's your recommendation of the image resource for building the ImageContainer object, the original tif file or the image file stored in the AnnData object (hires)?
I would go with the tiff file for any type of analysis (especially segmentation, but also feature extraction). I would use hires only for visualization purposes.
Let me know if that helps!
Thank you for the response! It indeed helps.
Best regards,
PeifengJi
... Thank you for the awesome tool. It's very useful. I'm new to Squidpy and currently use it to process my 10 x Visium H&E datasets. But I have came across an issue about the ImageContainer object. Below is my procedures:
I have read the object using the images provide either by the array in the AnnData object (which was generated by scanpy.read_visium()) by img = sq.im.ImageContaine r(adata.uns[spatial_key][library_id]["images"]['hires']) or by the tiff file during experiment (very large file, about 1 Gb in size). img = sq.im.ImageContainer('~/Desktop/wt.tif')
However, when I use the interactive function with Napari: viewer = img.interactive(adata). I have found that the gene expression image was not registered with the H&E image, instead they were showed separated in different part of the panel. As shown below:
I have read the documents provided but did not found how to address this issue. So what is the right way to build the ImageContainer object using my 10 x Visium dataset and tell me how to correctly link the expression data and the H&E image. Thank you very much! Sincerely,
Peifeng Ji