[adegenet-forum] plot.spca:\screeplot.spca Error in FUN(newX[, i], ...) : object lengths differ

Nevil Amos nevil.amos at gmail.com
Wed May 19 17:37:43 CEST 2010


I am getting the following error for some of my data, I cannot trace the 
inconsistency in the two data-sets, I have attached  a workspace 
containing two datasets ( mydata1 and mydata2) used to construct genind 
objects, then spca and plot the spca and below is the code to do this 
automatically (plots output to pdf, but error occurs when plotting to 
screen too, one works OK and the other does not  the  error results in a 
failure to produce the screeplot.  I have a large number of datasets to 
examine and many are showing this error, any indication of where to look 
to correct the error would be appreciated.

If I na.omit(mydata) I get the following additonal warning:

In addition: Warning messages:
1: Chernobyl! trL>n 729.34
2: Chernobyl! trL>n 729.34
3: In sqrt(sum.squares/one.delta) : NaNs produced

Nevil Amos


#Formats data to genind
mydata <- mydata[order(mydata$Site_Name) , ]
n<-ncol(mydata)
geno=mydata[,c(9:n)]
Site=factor(mydata[,c(3)])
BirdID=mydata[,c(2)]
XY=mydata[,c(7:8)]
mygenind<-df2genind(geno, sep="/",  
ind.names=BirdID,ncode=3,pop=Site,loc.names=NULL,   missing="NA", 
ploidy=2, type=c("codom"))
mygenind at other$xy<-(jitter(as.matrix(XY),fac=2))

mydata1 <- mydata1[order(mydata1$Site_Name) , ]
n<-ncol(mydata1)
geno=mydata1[,c(9:n)]
Site=factor(mydata1[,c(3)])
BirdID=mydata1[,c(2)]
XY=mydata1[,c(7:8)]
mygenind1<-df2genind(geno, sep="/",  
ind.names=BirdID,ncode=3,pop=Site,loc.names=NULL,   missing="NA", 
ploidy=2, type=c("codom"))
mygenind1 at other$xy<-(jitter(as.matrix(XY),fac=2))

#gets list of genind objects from list of all objects
objno<-(grep(pattern="genind",ls()))
genindlist<-(ls()[objno])
rm(objno)
#runs spca on all and keeps pc1 and pc(last)
pdf("spca_plots.pdf",12,8)
for(i in genindlist){
     x<-spca(get(i),type=1,scannf=F,nfposi=1,nfnega=1,ask=F)
     nam=paste(i,"SPCA", sep="")
     assign(nam,x)
     rm(x)
     rm(nam)

}
#produces pdf containing plots for initial examination
rm(genindlist)
slist<-ls()[(grep(pattern="SPCA$",ls()))]
for (s in slist){
     #print (s)
     plot.spca(get(s))
     }
dev.off()
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: test_script.r
URL: <http://lists.r-forge.r-project.org/pipermail/adegenet-forum/attachments/20100520/f5e446e3/attachment.asc>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: eg.RData
Type: application/octet-stream
Size: 8455 bytes
Desc: not available
URL: <http://lists.r-forge.r-project.org/pipermail/adegenet-forum/attachments/20100520/f5e446e3/attachment.obj>


More information about the adegenet-forum mailing list