[adegenet-forum] Question about the genind2genpop function

DAUPHIN Benjamin benjamin.dauphin at unine.ch
Thu Mar 17 16:33:55 CET 2016


Dear all,

I am working on multivariate analyses of genetic data using the adegenet package in R and I have a very basic problem when I try to convert data from a genind to a genpop object.

I can not define promptly my populations and I have an error message stipulating that the length for population factor is wrong.
"Error in `pop<-`(`*tmp*`, value = list(POP = c(1L, 1L, 1L, 1L, 1L, 1L,  : wrong length for population factor"
Yet the observation number is identical in both dataset (43) and so I don't understand this error.

I spend several hours trying to fix the problem without success despite tutorials and blogs, and ?I would appreciate a lot if someone can help me or orientate me in the use of the genind2genpop function. The problem is how can I define promptly populations in a factor that I can call in the genind2genpop function with the "pop" argument.?

My code is below and data in attached files:
packageDescription("adegenet", fields = "Version") # Check the version
[1] "2.0.1"?
# Object classes - Here use genind
allo<-read.csv(file.choose(),header=T,sep=';',na.strings = c("FALSE", "FALSEFALSE","","na"), fill=TRUE, strip.white=TRUE) # Test2.csv
head(allo)
dim(allo)
is.genind(allo)
is.data.frame(allo)
allo2 <- df2genind(allo, ploidy=2, sep=";")
allo2
is.genind(allo2)
tab(allo2)
genind2df(allo2, sep="|") # Check the conversion

# Object classes - Here use genpop
is.genpop(allo2)
Pops <- read.csv(file.choose(),header=T,sep=';',na.strings = c("FALSE", "FALSEFALSE","","na"), fill=TRUE, strip.white=TRUE) # Test2_Pops.csv
allo2pop <- genind2genpop(allo2, pop = Pops) ## Converting data from a genind to a genpop object

I know it is a very basic problem but I can go ahead in my stats and I would appreciate a lot your help!

Many thanks!
Best

Ben
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Test2.csv
Type: text/csv
Size: 3074 bytes
Desc: Test2.csv
URL: <http://lists.r-forge.r-project.org/pipermail/adegenet-forum/attachments/20160317/ff764cd3/attachment.csv>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Test2_Pops.csv
Type: text/csv
Size: 89 bytes
Desc: Test2_Pops.csv
URL: <http://lists.r-forge.r-project.org/pipermail/adegenet-forum/attachments/20160317/ff764cd3/attachment-0001.csv>


More information about the adegenet-forum mailing list