I have a vcf file with PL values and I would like to convert it into GP (genotype probabilities) values.
I am using package VariantAnnotation in R, but I have difficulties with saving of output vcf file with GP values (or other format – beagle is which I need for other analyses).
Please could you advice which command I have to use to save vcf file with GP values.
I have found example for convert to posterior probabilities, but I can’t figure out how to save it.
## Read a vcf file with a "PL" field.
vcfFile <- system.file("extdata", "hapmap_exome_chr22.vcf.gz",
package="VariantAnnotation")
vcf <- readVcf(vcfFile, "hg19")
## extract genotype likelihoods as a matrix of lists
pl <- geno(vcf)$PL
class(pl)
mode(pl)
## convert to posterior probabilities
gp <- PLtoGP(pl)
I think any limitations would come from R and your computer's RAM rather than the VariantAnnotation package in particular. If your file is large, you might want to iterate rather than reading the entire file at once. From the man page for readVCF:
Another option for handling large files is to iterate through the data in chunks by setting the
yieldSize parameter in a VcfFile object. Iteration can be through all data fields or a subset
defined by a ScanVcfParam. See example below, ‘Iterating through VCF with yieldSize‘.
Is there a limit for the number of SNPs in vcf file? When I am trying to readVcf file, Rstudio is falling down. Thanks.
I think any limitations would come from R and your computer's RAM rather than the VariantAnnotation package in particular. If your file is large, you might want to iterate rather than reading the entire file at once. From the man page for
readVCF
: