thibautjombart / adegenet

adegenet: a R package for the multivariate analysis of genetic markers
166 stars 64 forks source link

Inconsistant results with adegenet::spca and adespatial::multispati #355

Open arthurdegrandpre opened 1 year ago

arthurdegrandpre commented 1 year ago

Hello,

I have been looking into solutions for spatial multivariate analysis and tried both spca and multispati, but their results are vastly different. Isn't spca basically a wrapper to multispati? Maybe I'm mistaken in their use and/or call synthax.

Following is a reproducible example. Merci! Arthur

` library(ade4) library(adespatial) library(adegraphics) library(adegenet) library(sp) library(spdep)

data("mafragh")

analysis with multispati

mxy = as.matrix(mafragh$xy) nb = chooseCN(coordinates(mxy), type = 1, plot.nb = FALSE) lw = nb2listw(nb, style = 'W', zero.policy = TRUE) pca = dudi.pca(mafragh$env, scale=T, center=T, scannf=F, nf=2) ms = multispati(pca, lw, scannf=F)

ms_loadings = ms$c1[,1]^2

analysis with spca

spca = spca(mafragh$flo, xy=mafragh$xy, ask=F, type=1, scannf=F, scale=T, center=T, nfposi=2, nfnega=0) spca_loadings = spca$c1[,1]^2

comparison

loadingplot(ms_loadings) loadingplot(spca_loadings) ms spca `