I got vcf files from Platypus variant caller. When I try to import them into R and the VariantAnnotation format
VRanges I get the error message:
test = readVcf(path) as(object = test,Class = "VRanges") Error in end(ranges)[!is.na(meta$END)] <- meta$END[!is.na(meta$END)] : invalid subscript type 'S4'
When I run the code of the
as method line by line I see that in my case the END field in the meta variable is a
<IntegerList> meanwhile in the example vcf file of the package (
chr22.vcf.gz) is a
By comparing the example file and my vcf file I can see that the END INFO field specification is different. Instead of
Number=1 it says
I am not an expert in VCF field specification but I know they can be a mess. So this might not be a
VariantAnnotation issue but the variant caller issue.
Anyway, What should I do to be able to import those vcf files into R? I would like to avoid modifying the raw vcf files.
How to reproduce it?
Get the example
chr22.vcf.gz file in the package. (use
fl = system.file("extdata", "chr22.vcf.gz", package="VariantAnnotation") to locate where it is). Uncompress and modify the line:
##INFO=<ID=END,Number=1,Type=Integer,Description="End position of the variant described in this record">
##INFO=<ID=END,Number=.,Type=Integer,Description="End position of the variant described in this record">
Then run the code:
> from = readVcf("path/to/R/win-library/3.5/VariantAnnotation/extdata/chr22.vcf") #this is the modified file > as(object = from,Class = "VRanges") Error in end(ranges)[!is.na(meta$END)] <- meta$END[!is.na(meta$END)] : invalid subscript type 'S4'