adegenet
adegenet copied to clipboard
"." not recognised as a missing character when creating genlight object
Hiya,
I'm using read.vcf (pegas) to read a multisample VCF (ms) into R and then creating a genlight object:
ms<-read.vcf("multisample.vcf") ms.genlight.<-new("genlight" , ms , ploidy=1 , NA.char=" . ")
As read.vcf replaces missing data with a dot, I'm trying to get this recognised when I convert to genlight, however I never seem to be successful and the dots are counted as real data when I make my genlight object.
I've tried escaping before the dot as well (NA.char="\.") but this also fails.
Can you advise on how to fix this issue? If not - are there any other methods you recommend for importing and converting a multisample VCF?
Thanks, Suzy
Hi @suzyhh,
You may want to try vcfR. It has an explicit vcf2genlight conversion function (https://knausb.github.io/vcfR_documentation/export_genlight_snpclone.html)
vcf <- read.vcfR(vcf_file, verbose = FALSE)
x <- vcfR2genlight(vcf)