jianhuupenn / SpaGCN

SpaGCN: Integrating gene expression, spatial location and histology to identify spatial domains and spatially variable genes by graph convolutional network
MIT License
191 stars 59 forks source link

How to choose radius for neighbouring domains? #61

Closed vladimirkovacevic closed 10 months ago

vladimirkovacevic commented 1 year ago

I got an error:

No neighbor domain found, try bigger radius or smaller ratio
File "ez_mode.py", line 49, in detect_SVGs_ez_mode
    nbr_domians=nbr_domians[0:3]
TypeError: 'NoneType' object is not subscriptable

I'm running the sample with 6000 observations. How to choose the radius for neighbouring domains?

jianhuupenn commented 1 year ago

Hi there,

Thanks for your interest in SpaGCN. The choice of radius (r) depends on the xy coordinates scale of your data. In the stpe-by-step tutorial, there is one function to search r automatically: https://github.com/jianhuupenn/SpaGCN/blob/master/tutorial/tutorial.md#6-identify-svgs

r=spg.search_radius(target_cluster=target, cell_id=adata.obs.index.tolist(), x=x_array, y=y_array, pred=adata.obs["pred"].tolist(), start=start, end=end, num_min=10, num_max=14,  max_run=100)

Based on the message, the choice of r is too small. You can try a bigger value, for example, r x 5, r x 10. It seems you are running the ez mode, so some parameters maybe difficult to change, I would recommend running the step-by-step tutorial and using a customized r value. Hope this helps.

vladimirkovacevic commented 1 year ago

Thank you guys for developing it and for the detailed response. It is a very nice and useful tool. I'll try an automatic search for optimal r.

vladimirkovacevic commented 1 year ago

@jianhuupenn maybe I missed it in the paper, but can you tell me what is the logic behind using only neighbouring clusters when calculating DE genes and not all clusters in the tissue? Also, if I put r = MAX_INT will it then include all neighbouring clusters?

vladimirkovacevic commented 1 year ago

Actually, the code I was running was using search_radius() and for some clusters, it returned 0 neighboring clusters.