dartR error - convert genlight file to vcf file

104 views
Skip to first unread message

Lyndal Hulse

unread,
Nov 13, 2022, 9:08:28 PM11/13/22
to dartR

Dear dartR Team,

 I was hoping to get some advice regarding an error message I receive trying to convert my SNP genlight file into a vcf file using dartR. 

 I am running under Windows with R version 4.2.1.  I have been reading some of the conversations on the Google Group referring to converting genlight file to vcf file, and have tried troubleshooting based on the advice provided in the Google Group.   Please see below the code I am using and the error message (in red) I receive:

 > gl2vcf(x=gl5,

+        plink_path = getwd(),

+        outfile = "gl5.vcf",

+        outpath = getwd(),

+        snp_pos = "0",

+        snp_chr = "0",

+        chr_format = "character",

+        pos_cM = "0",

+        ID_dad = "0",

+        ID_mom = "0",

+        sex_code = "unknown",

+        phen_value = "0",

+        verbose = NULL)

Starting gl2vcf

  Processing genlight object with SNP data

  Chromosome information is not present in the slot 'chromosome'. Setting '0' as the name chromosome for all the SNPs.

Starting gl2plink

  Processing genlight object with SNP data

Completed: gl2plink

Error in system(..., intern = T) : 'C:/Users/uqlhulse/OneDrive' not found

 I look forward to hearing from you and please let me know if I can provide any further information.

 Kind regards,

Lyndal

Jose Luis Mijangos

unread,
Nov 14, 2022, 1:00:17 PM11/14/22
to dartR
Hi Lyndal,

Can you try to set you working directory manually by clicking on the RStudio menu "Session" then  "Set working directory" then "Choose directory..."

Make sure that you choose the working directory where the Plink executable is.

After that, try running again the function.

Cheers ,
Luis

jamessh...@gmail.com

unread,
Nov 21, 2022, 11:14:35 PM11/21/22
to dartR
Hi DartR team,

I am also having an issue converting my gl object to VCF. I run the code below, but I hit an error when it tries to call on plink... "  'names' attribute [2] must be the same length as the vector [1]". I've saved the plink exe, ect. to my working drive. Do you know where I might have gone wrong? Thanks in advance.

> gl2vcf(gltrigs, plink_path = getwd(), outfile = "gltrigs.vcf", outpath = getwd(),snp_pos = "0",snp_chr = "0",
+        chr_format = "character",pos_cM = "0",ID_dad = "0",ID_mom = "0",sex_code = "unknown",phen_value = "0",

+        verbose = NULL)
Starting gl2vcf
  Processing genlight object with SNP data
Starting gl2plink
  Processing genlight object with SNP data
Error in names(x) <- value :
  'names' attribute [2] must be the same length as the vector [1]

Regards,
James

Jose Luis Mijangos

unread,
Nov 22, 2022, 2:15:20 AM11/22/22
to dartR

Hi James,

How did you read your data into dartR?

It might be that you don’t have information in the slot “loc.all".

What is printed when you type:

> gl$loc.all

If you don’t have information in this slot, you can create a dummy variable, as below:

> gl$loc.all <- rep("G/C",nLoc(gl))

Then try again running the function.

Cheers,
Luis

jamessh...@gmail.com

unread,
Nov 22, 2022, 4:30:21 AM11/22/22
to dartR
Hi Luis,

Thanks for the quick reply. All the loci info appears to be there. 

I read in the data with the following code...

gl <- gl.read.dart(filename="Report_DSyn22-7325_SNP_2.csv",
                   ind.metafile="syncomistes_header.csv")
save(gl, file="syncomistes.rdata")
load("syncomistes.rdata")

I then filtered and subsetted the data before trying to turn it into a vcf file.

Regards,
James

Brianna Coulter

unread,
Nov 22, 2022, 11:18:59 PM11/22/22
to dartR
Hi James,

I had this error today and having 'NULL' in gl$chromosome seemed to be my problem.

I assigned values as follows
> gl$chromosome <- as.factor("1")

This is what was done in the examples for the gl2plink help file.

Hopefully this solves your problem too!

Regards,
Brianna

James Shelley

unread,
Nov 22, 2022, 11:52:50 PM11/22/22
to da...@googlegroups.com
Thanks so much Brianna! That did the trick. 

I also found that the command doesn't accept spaces in the file path names FYI.

Thanks again to you too Luis.

Regards,
James

--
You received this message because you are subscribed to a topic in the Google Groups "dartR" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dartr/JrKiZ4eVpQg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dartr+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dartr/5785b104-71e2-4813-bd2a-6b45fdfbebb8n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages