[adegenet-forum] sPCA variable number of eigenvalues

Phil Morin (NOAA Federal) phillip.morin at noaa.gov
Fri Apr 24 22:29:11 CEST 2020


Hi,

I've been using sPCA over the past couple of years, and run into an 
error that appears to be due to different numbers of eigenvalues 
generated by the spca function. When I run it repeatedly, many times I 
get the following error when I try to generate the screeplot:

Error in data.frame(eig = eig, var = varspa, moran = moran/varspa) : 
arguments imply differing number of rows: 40, 34

each time I run it, the number of eigenvalues changes (e.g., 40 in this 
case). spca functions such as screeplot and plot will not function if 
the number of eigen values doesn't match the number of samples minus one 
(n-1).

I am using jitter to randomly shift the lat/lon coordinates each time, 
as some of the samples have the same coordinates.

The command lines are:

obj.s<-obj
obj.s$other$xy<-jitter(obj$other$xy, factor = 0.5)
mySpca <- spca(obj.s, ask=T, type=1, scannf=F, nfposi = 4, nfnega = 0, 
scale=T) # method used by LL

where obj is a genind object with the lat/lon positions in obj$other$xy.

Can anyone tell me why the number of eigenvalues changes, and how to fix 
this problem? For some datasets, the function fails (generates too many 
eigenvalues) most of the time. If I continue to re-run it, and change 
the jitter factor, I can usually get it to run properly eventually 
(after many replicates).

Phil

-- 
--
Phillip A. Morin, Ph.D.
Southwest Fisheries Science Center
8901 La Jolla Shores Dr.
La Jolla, CA 92037, USA
Phone: 858-546-7165
Fax: 858-546-7003
phillip.morin at noaa.gov
http://swfsc.noaa.gov/mmtd-mmgenetics

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/adegenet-forum/attachments/20200424/9c4b433b/attachment.html>


More information about the adegenet-forum mailing list