Exporting a genlight object to Dart format file

250 views
Skip to first unread message

Nga Vu

unread,
Feb 22, 2021, 12:48:28 AM2/22/21
to dartR

Dear everyone,

 I'm getting stuck to export a genlight object to Dart format file.

I used dart2genlight to import Dartseq data into R and converted it to a genlight object (gl <-gl.read.dart)

 Then, I used gl.sim.ind and gl.sim.offspring to simulate new individuals and offsprings.

I want to export a genlight object with new individuals to Dart data. Could you please guide me on how to convert genlight2dart? The output files will be used to convert to Cervus 3.0.7 input files

Many thanks. I really appreciate your help

Jose Luis Mijangos

unread,
Feb 22, 2021, 6:33:22 PM2/22/21
to dartR
Hello,

Cervus accepts files in genepop format. Please find attached a function to convert from genelight to genepop.

Because google groups doesn't allow to send executable files, the attached file has a ".txt" extension. To use this function please save it to your working directory and change the extension of the file to ".R". Then in the command line of R type:

> source(“gl2genepop.R”)

> gl2genepop(your_data.gl, outpath = getwd())

The above command will save the file with the name genepop.txt in your working directory.

Please let us know whether it worked for you.

Regards,
Luis
gl2genepop.txt

Nga Vu

unread,
Feb 22, 2021, 8:56:38 PM2/22/21
to dartR
Dear Luis,

Thankssssssss :)
I am working on this and will let you know soon.

Kind regards,
Nga

Nga Vu

unread,
Feb 23, 2021, 5:27:17 AM2/23/21
to dartR
Dear Luis,

I can't get the genepop file.

I used my Dart data (22 individuals, 50 SNPs) to simulate 100 individuals (50 father - gl.father and 50 mother - gl. mother).
> glsim_Sire <- gl.sim.ind(gl_X, n=50, popname="X_Sire")
> glsim_Dam <- gl.sim.ind(gl_X, n=50, popname="X_Dam")

Then, I simulated offsprings: 
> gloffspring <- gl.sim.offspring(glsim_Sire, glsim_Dam, noffpermother, sexratio = 0.5)

Then, convert a genlight object to genepop
> X_genepop <- gl2genepop(gloffspring, outpath = getwd())
> X_genepop
# NULL

I also imported my Dart data (22 individuals, 50 SNPs) into R as 2 genelight objectives (gl_Sire = 11 individuals and gl_Dam = 11 individuals)
Then, I simulated offsprings: 
> gloffspring <- gl.sim.offspring(gl_Sire, gl_Dam, noffpermother, sexratio = 0.5)

Then, convert a genlight object to genepop
> X_genepop <- gl2genepop(gloffspring, outpath = getwd())
> X_genepop
# NULL

They both gave a NULL genepop. The genepop.txt has only SNP id and 1 row data:
SNPs from gloffspring written in Genepop format
SNP_1
.........
SNP_50
Pop
,  002002 001002 001001 002002 001002 001002 001001 002002 001002 001001 002002 001002 001001 002002 001002 001001 001002 001001 001001 001001 001001 001002

Anyway, I find another method to simulated offsprings. They are all working now.

Many thanks
Kind regards
Nga
Reply all
Reply to author
Forward
0 new messages