-
Notifications
You must be signed in to change notification settings - Fork 34
Open
Labels
Description
Describe the bug
The spatial_autocorr() function in rapids-singlecell returns unbounded Moran’s I values, including inf, which is inconsistent with the expected behavior and the reference implementation in squidpy. This behavior occurs for certain samples and breaks downstream interpretation of spatial autocorrelation.
Steps/Code to reproduce bug
# Using squidpy 1.6.5
# Moran's I from squidpy.gr.spatial_autocorr()
Sample: block3, Moran's I min: -0.0014, max: 0.8894
Sample: block7, Moran's I min: -0.0015, max: 0.8727
Sample: block2, Moran's I min: -0.0014, max: 0.8937
Sample: block9, Moran's I min: -0.0013, max: 0.8706
# Using rapids-singlecell 0.12.7
# Moran's I from rapids_singlecell.gr.spatial_autocorr()
Sample: block3, Moran's I min: -0.0014, max: 0.8903
Sample: block7, Moran's I min: -6.80e-06, max: inf
Sample: block2, Moran's I min: -6.43e-17, max: inf
Sample: block9, Moran's I min: -4.17e-32, max: inf
When I look at individual features (for the same sample), it seems to break for features with (very) small I and might indicate some computational instability
Rapids
Gene | I | pval_norm | var_norm | pval_norm_fdr_bh |
---|---|---|---|---|
ASIC1 | inf | 0.0 | 3.2141281e-06 | 0.0 |
CD40LG | inf | 0.0 | 3.2141281e-06 | 0.0 |
GAL | inf | 0.0 | 3.2141281e-06 | 0.0 |
Squidpy
Gene | I | pval_norm | var_norm | pval_norm_fdr_bh |
---|---|---|---|---|
ASIC1 | 0.0465674 | 0.0 | 3.2141273e-06 | 0.0 |
CD40LG | 0.0117390 | 2.8169134e-11 | 3.2141273e-06 | 3.8116098e-11 |
GAL | 0.0154400 | 0.0 | 3.2141273e-06 | 0.0 |
Expected behavior
Moran’s I values should:
- Be finite (no inf or NaN)
- Fall within the bounded range ([-1, 1])
Be consistent with established implementations like squidpy
Environment details
- Environment location: Bare-metal
- Linux Distro/Architecture: Ubuntu 22.04 amd64
- GPU Model/Driver: A100 and driver 560.35.03
- CUDA: 12.6
- Squidpy Version: '1.6.5'
- Rapids Version: '0.12.7'