SpaGCN icon indicating copy to clipboard operation
SpaGCN copied to clipboard

spg.calculate_adj_matrix is making all Nan with our own FFPE histology image

Open galib36 opened this issue 2 years ago • 1 comments

Hello, Thank you for making SpaGCN available to community. When I am trying SpaGCN with my own FFPE histology images on a 10X Visum data, the spg.calculate_adj_matrix is producing all Nan for the Adjacency matrix. I run the following command

adj=spg.calculate_adj_matrix(x=x_pixel,y=y_pixel, x_pixel=x_pixel, y_pixel=y_pixel, image=img, beta=b, alpha=s, histology=True)

But the adj matrix is all zero. Can you please help me to solve this?

Thank you.

galib36 avatar Apr 28 '22 08:04 galib36

Thank you for your interest in SpaGCN. I would recommend you double-check if you are using the correct image, which matches the pixel_x and pixel_y coordinates. If the coordinates do not match, you will get "nan" for the colour values, and the adj becomes "nan".

I have helped other people solve the same problem on GitHub: https://github.com/jianhuupenn/SpaGCN/issues/7#issuecomment-962761985

jianhuupenn avatar Apr 28 '22 15:04 jianhuupenn

Hello, Thank you for making SpaGCN available to community. When I am trying SpaGCN with my own FFPE histology images on a 10X Visum data, the spg.calculate_adj_matrix is producing all Nan for the Adjacency matrix. I run the following command

adj=spg.calculate_adj_matrix(x=x_pixel,y=y_pixel, x_pixel=x_pixel, y_pixel=y_pixel, image=img, beta=b, alpha=s, histology=True)

But the adj matrix is all zero. Can you please help me to solve this?

Thank you.

I had the same problem but I think I find out the reason why 10X Visum data coordinates do not match the image, there is a file called 'scalefactors_json.json' in the 'spatial' folder, which can adjust the coordinates to match the image, and you can use it to adjust the coordinates to fit the image

makabakayu avatar Jul 13 '23 13:07 makabakayu

Hello, Thank you for making SpaGCN available to community. When I am trying SpaGCN with my own FFPE histology images on a 10X Visum data, the spg.calculate_adj_matrix is producing all Nan for the Adjacency matrix. I run the following command

adj=spg.calculate_adj_matrix(x=x_pixel,y=y_pixel, x_pixel=x_pixel, y_pixel=y_pixel, image=img, beta=b, alpha=s, histology=True)

But the adj matrix is all zero. Can you please help me to solve this? Thank you.

I had the same problem but I think I find out the reason why 10X Visum data coordinates do not match the image, there is a file called 'scalefactors_json.json' in the 'spatial' folder, which can adjust the coordinates to match the image, and you can use it to adjust the coordinates to fit the image

But how do you convert the spaceranger output image to match the pixels in Squidpy? I have to load the original image file to resolve this issue.

Kennyluo4 avatar Jul 14 '23 14:07 Kennyluo4

Hello, Thank you for making SpaGCN available to community. When I am trying SpaGCN with my own FFPE histology images on a 10X Visum data, the spg.calculate_adj_matrix is producing all Nan for the Adjacency matrix. I run the following command

adj=spg.calculate_adj_matrix(x=x_pixel,y=y_pixel, x_pixel=x_pixel, y_pixel=y_pixel, image=img, beta=b, alpha=s, histology=True)

But the adj matrix is all zero. Can you please help me to solve this? Thank you.

I had the same problem but I think I find out the reason why 10X Visum data coordinates do not match the image, there is a file called 'scalefactors_json.json' in the 'spatial' folder, which can adjust the coordinates to match the image, and you can use it to adjust the coordinates to fit the image

But how do you convert the spaceranger output image to match the pixels in Squidpy? I have to load the original image file to resolve this issue.

I mainly use R analysis, and here I use scanpy to load the data, so I don't know Squidpy very well

makabakayu avatar Jul 18 '23 07:07 makabakayu

@galib36 @Kennyluo4 did you ever solve this issue? I am trying to run spagcn with histology image tissue_hires_image.png but I'm also getting nans. I'm not sure how to use the scalefactors_json.json file

uthsavc avatar Dec 07 '23 20:12 uthsavc

@galib36 @Kennyluo4 did you ever solve this issue? I am trying to run spagcn with histology image tissue_hires_image.png but I'm also getting nans. I'm not sure how to use the scalefactors_json.json file

Long story short, the error was raised because the coordinates do not match the HE image provided. For details, pls refer to #7

jianhuupenn avatar Dec 07 '23 21:12 jianhuupenn

Thanks for the reference @jianhuupenn ! I figured out the issue is my HE image is not the full .tif image, so you had to scale the coordinates down by a scaling factor. I put my code to do this in #85 if it is helpful.

uthsavc avatar Dec 08 '23 01:12 uthsavc