This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Writing genepop from genind

I had to remove some loci from a genepop file and now have a genind object. However, a lot of my downstream analyses require a file path to a .gen file and won't accept an object loaded from my environment. I tried to use the genind_to_genepop() function from the package graph4lg:

genind_to_genepop(genind_obj, output = "path/to/file/converted_file.txt")

But when I try to read it in, I get the error:

Error in read.genepop("oly.no23.gen", ncode = 2L, quiet = FALSE) :
some alleles are not encoded with 2 characters Check 'ncode' argument

In my genind file, all alleles are coded with 2 characters and missing data is coded with NA. I tried substituting the NAs with 00, but am still getting the same error.

Any help would be much appreciated

Here's what the genind looks like:

/// GENIND OBJECT /////////

 // 561 individuals; 2,342 loci; 4,684 alleles; size: 11.3 Mb

 // Basic content
   @tab:  561 x 4684 matrix of allele counts
   @loc.n.all: number of alleles per locus (range: 2-2)
   @loc.fac: locus factor for the 4684 columns of @tab
   @all.names: list of allele names for each locus
   @ploidy: ploidy of each individual  (range: 2-2)
   @type:  codom
   @call: .local(x = x, i = i, j = j, loc = ..1, drop = drop)

 // Optional content
   @pop: population of each individual (group size range: 89-95)
r genepop genind graph4lg stacks

0 answers

No answers yet.

Log in to answer this question.