adeverse / adespatial

Multivariate Multiscale Spatial Analysis
http://adeverse.github.io/adespatial/
32 stars 7 forks source link

local.rtest issue in adespatial, works with adegenet #16

Closed leapautrel closed 3 years ago

leapautrel commented 3 years ago

Hello, While I was following this sPCA tutorial, I found that the multivariate tests to detect local structuring (local.rtest) does not seem to work properly in the adespatial package. However, it works fine in the adegenet package.

library(adegenet) ; library(adespatial)
data(spcaIllus)
obj <- spcaIllus$dat4
mySpca <- spca(obj,type=1,scannf=FALSE,plot.nb=FALSE,nfposi=1,nfnega=0)

myGtest <- adegenet::global.rtest(obj$tab,mySpca$lw,nperm=99) ; myGtest # Works just fine
myGtest <- adespatial::global.rtest(obj$tab,mySpca$lw,nperm=99) ; myGtest # Works just fine

myLtest <- adegenet::local.rtest(X = obj$tab, listw = mySpca$lw, nperm = 99) ; myLtest # Works just fine
myLtest <- adespatial::local.rtest(X = obj$tab, listw = mySpca$lw, nperm = 99) ; myLtest # Observation: NA -> not working

I tried to understand why, and the only difference between adegenet:::local.rtest and adespatial:::local.rtest is the call to the orthobasis.listw function.

The issue could be problematic since using local.rtest without precision on the package calls the adespatial::local.rtest which doesn't work properly.

sdray commented 3 years ago

Hi ! Thanks a lot, it was a bug that I corrected in 523ea4005405dfe3c5ed1d82a49721634e325cd3

You can install from github to use the new version of adespatial