MarioniLab / miloR

R package implementation of Milo for testing for differential abundance in KNN graphs
https://bioconductor.org/packages/release/bioc/html/miloR.html
GNU General Public License v3.0
346 stars 22 forks source link

SpatialFDR all NaN #229

Closed brianpenghe closed 2 years ago

brianpenghe commented 2 years ago

I was following the this manual and finished generating DA_results with these codes:

%%R -i design_df -o DA_results
## Define neighbourhoods
milo@.k=20
milo <- makeNhoods(milo, prop = 0.1, k = 20, d=100, refined = TRUE)

## Count cells in neighbourhoods
milo <- countCells(milo, meta.data = data.frame(colData(milo)), sample="batch")

## Calculate distances between cells in neighbourhoods
## for spatial FDR correction
milo <- calcNhoodDistance(milo, d=100)

## Test for differential abundance
DA_results <- test

Nhoods(milo, design = ~ chemistry + stage_group, design.df = design_df)

However, the DA_results have only NaN values in the SpatialFDR.

image

Any ideas?

MikeDMorgan commented 2 years ago

@brianpenghe - can you check for Na values in the FDR and PValue columns of the output - this might happen when there is are Na p-value. The other issue might be that the high d used to compute distances is causing very small values for the spatial FDR correction. It is very strange to have so many dimensions and yet such a small k. The ability to assign true pairs of nearest neighbours from noise with d=100 is going to be way less sensitive than if you used a smaller value for d.

Could you also try running this with makeNhoods(milo, prop = 0.1, k = 20, d=100, refined = TRUE, refinement_scheme="grahph") and testNhoods(milo, design = ~ chemistry + stage_group, design.df = design_df, fdr.weighting="graph-overlap"). This uses Alice's work on graph-only approaches and so you don't need to run calcNhoodDistances at all.