How to read a .vcf file in R

353 views
Skip to first unread message

mara...@gmail.com

unread,
Nov 7, 2017, 3:57:58 PM11/7/17
to dDocent User Help Forum
Hi, dDocent team! Please, could someone tell me how to read a vcf file in R to calculate basic population genetics statistics? I have tried several options without success.
In advance thanks,
M.

Sophie D

unread,
Nov 7, 2017, 4:37:49 PM11/7/17
to ddo...@googlegroups.com
Hi,

you could try with this package: vcfR (10.1111/1755-0998.12549). I personally I have no experience yet with it as I just discovered this package this week! What packages did you try so far?

Greetings,

Sophie

--

Sophie Delerue-Ricard, PhD student in Marine Molecular Evolutionary Ecology, Belgium

Leuven University & Institute for Agricultural and Fisheries Research




--
You received this message because you are subscribed to the Google Groups "dDocent User Help Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ddocent+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

mara...@gmail.com

unread,
Nov 8, 2017, 8:44:17 AM11/8/17
to dDocent User Help Forum
Hi Sophie,

Yes, I have tested with this R package, but have the problem that vcfR package does not recognize my .vcf files, I have tried to read my file and also other files from the examples folder of vcftools and I get this error:

> myvcf<-read.vcfR(annotate-test.vcf)
Error in path.expand(file) : object 'annotate' not found

> myvcf<-read.vcfR(popaus03.vcf, nrows= 2056, skip=0, convertNA=TRUE, verbose=TRUE)
Error in path.expand(file) : object 'popaus03.vcf' not found.

Some idea?

Thanks,
M.
> To unsubscribe from this group and stop receiving emails from it, send an email to ddocent+u...@googlegroups.com.

Joel Anderson

unread,
Nov 8, 2017, 9:13:16 AM11/8/17
to dDocent User Help Forum
You might try the linux version of the software PGDSpider http://www.cmpg.unibe.ch/software/PGDSpider/
This can read a .vcf file and convert it to several formats that are more useable for traditional popgen programs.  I'm sure one of those formats (Genepop, for instance) could be read into R.

rsp...@gmail.com

unread,
Oct 23, 2018, 7:48:46 PM10/23/18
to dDocent User Help Forum
On Tuesday, November 7, 2017 at 2:57:58 PM UTC-6, mara...@gmail.com wrote:

I'm sure the original questioner has found a solution by now!! But for those who may come along later, there's vcf2genind if the plan is to use adegenet.

PGDSpider does work well as Joel mentioned.

Reply all
Reply to author
Forward
0 new messages