[adegenet-forum] Error in spdep::lag.listw(listw, x, TRUE) : object lengths differ

Jombart, Thibaut t.jombart at imperial.ac.uk
Tue May 4 11:57:32 CEST 2010


Dear Nevil, 

The error likely comes from your data. Actually I can't even create a genind object using the current version of adegenet and the data you sent. 

The coding of genetic information is inconsistent: 
- missing values are "NA" or ""
- first locus is coded by 2 characters by allele, others by three
- other coding is used sometimes; for instance, ligne 370 reads:
202202  254-9 127127 271271
I guess 254-9 should be 254009 (?), but df2genind is less good at guessing the coding.

Please check your data, and don't hesitate to post another email if the error persists.

Best

Thibaut.




________________________________________
From: Nevil Amos [nevil.amos at gmail.com]
Sent: 04 May 2010 04:30
To: Jombart, Thibaut
Cc: adegenet-forum at lists.r-forge.r-project.org
Subject: Re:  Error in spdep::lag.listw(listw, x, TRUE) : object lengths differ

Thanks for the response, I have repeated with another set of data (
different species from the same datasource)

I am still getting the same error
There are no NA values in the coordinates

The code initially reads the data from an MS access database - cannot
append this, but I have again appended the workspace, and the R:
commands and output are copied below and the r script attached.

Type 2 and 3 connection networks also result in an error, type 4-7 run OK.

thanks

 > setwd("d:/nevs docs/rwork/test/")
 > library (adegenet)
    ==========================
     adegenet 1.2-3 is loaded
    ==========================

  - to start, type '?adegenet'
  - to browse adegenet website, type 'adegenetWeb()'
  - to post questions/comments: adegenet-forum at lists.r-forge.r-project.org

 > library (RODBC)
 > channel <- odbcConnectAccess("Linkage_fe.mdb")
 > mydata <- sqlFetch(channel, "Toadegenet")
 > n<-ncol(mydata)
 > geno=mydata[,c(7:n)]
 > Site=mydata[,c(1)]
 > BirdID=mydata[,c(2)]
 > XY=mydata[,c(5:6)]
 > 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<-XY
 > myspca<-spca(mygenind)

Attaching package: 'ade4'


         The following object(s) are masked from package:base :

          within

Loading required package: sp
Loading required package: boot

Attaching package: 'boot'


         The following object(s) are masked from package:survival :

          aml

Loading required package: Matrix
Loading required package: lattice

Attaching package: 'lattice'


         The following object(s) are masked from package:boot :

          melanoma

Loading required package: MASS
Loading required package: nlme
Loading required package: maptools
Loading required package: foreign
Loading required package: deldir
deldir 0.0-12

      Please note: The process for determining duplicated points
      has changed from that used in version 0.0-9 (and previously).

Loading required package: coda
Loading required package: spam
Package 'spam' is loaded. Spam version 0.20-3 (2010-01-13).
Type demo( spam) for some demos, help( Spam) for an overview
of this package.
Help for individual functions is optained by adding the
suffix '.spam' to the function name, e.g. 'help(chol.spam)'.

Attaching package: 'spam'


         The following object(s) are masked from package:Matrix :

          norm


         The following object(s) are masked from package:base :

          backsolve,
          forwardsolve


Attaching package: 'spdep'


         The following object(s) are masked from package:ade4 :

          mstree


Choose a connection network:
          Delaunay triangulation (type 1)
          Gabriel graph (type 2)
          Relative neighbours (type 3)
          Minimum spanning tree (type 4)
          Neighbourhood by distance (type 5)
          K nearest neighbours (type 6)
          Inverse distances (type 7)
Answer: 1

Keep this graph (y/n)? y
Error in spdep::lag.listw(listw, x, TRUE) : object lengths differ
In addition: Warning message:
In spca(mygenind) :
   NAs in data are automatically replaced (to mean allele frequency)
 >
 > myspca<-spca(mygenind)

Choose a connection network:
          Delaunay triangulation (type 1)
          Gabriel graph (type 2)
          Relative neighbours (type 3)
          Minimum spanning tree (type 4)
          Neighbourhood by distance (type 5)
          K nearest neighbours (type 6)
          Inverse distances (type 7)
Answer: 2
Error in gabrielneigh(xy) :
   number of neighbours overrun - increase nnmult


there are no On 4/05/2010 5:39 AM, Jombart, Thibaut wrote:
> Dear Nevil,
>
> thanks for joining your RData, but I can't guess what is wrong if I don't have your R command. Besides, and as you suggest, did you check if there are NAs in your spatial coordinates?
>
> Best
>
> Thibaut
>
>
>
> ________________________________________
> From: adegenet-forum-bounces at lists.r-forge.r-project.org [adegenet-forum-bounces at lists.r-forge.r-project.org] On Behalf Of Nevil Amos [nevil.amos at gmail.com]
> Sent: 03 May 2010 11:06
> To: adegenet-forum at lists.r-forge.r-project.org
> Subject: [adegenet-forum] Error in spdep::lag.listw(listw, x,   TRUE) : object lengths differ
>
> I am receiving the below error message presumably because one of my data
> fileds contians a missing value or something similar?
>
> Any indications of how to trace it back would be appreciated.  I have
> attached the workspace if that is permissible.
>
> Choose a connection network:
>            Delaunay triangulation (type 1)
>            Gabriel graph (type 2)
>            Relative neighbours (type 3)
>            Minimum spanning tree (type 4)
>            Neighbourhood by distance (type 5)
>            K nearest neighbours (type 6)
>            Inverse distances (type 7)
> Answer: 1
>
> Keep this graph (y/n)? y
> Error in spdep::lag.listw(listw, x, TRUE) : object lengths differ
>



More information about the adegenet-forum mailing list