[adegenet-forum] Question about the genind2genpop function

DAUPHIN Benjamin benjamin.dauphin at unine.ch
Thu Mar 17 18:21:41 CET 2016


Dear all,

I have fix my problem.
Thanks!
Best
Ben

________________________________________
From: adegenet-forum-bounces at lists.r-forge.r-project.org <adegenet-forum-bounces at lists.r-forge.r-project.org> on behalf of DAUPHIN Benjamin <benjamin.dauphin at unine.ch>
Sent: 17 March 2016 16:33
To: adegenet-forum at lists.r-forge.r-project.org
Subject: [adegenet-forum] Question about the genind2genpop function

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


More information about the adegenet-forum mailing list