This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Readvcf In R

I am trying to run the R command readVcf in R, it shows function not found. I have already downloaded the package "VariantAnnotation". I don't know if it helps. Does anyone have any idea?

vcf bioconductor r

I found this tutorial very useful especially for reading data into R

2 answers

Have you loaded it, library('VariantAnnotation')!!

Just run these 3 command lines in R:

source("http://bioconductor.org/biocLite.R") 
biocLite("VariantAnnotation") #install the package
library("VariantAnnotation") #load the package
example("readVcf") #optional, test the function by running example codes

Hi,

I am trying to use VariantAnnotation and this is the error I am getting

library("VariantAnnotation")

f1 <-system.file("extdata","chr22.vcf.gz", package="VatiantAnnotation")
vcf<-readVcf(f1,"hg19")
Error in .io_check_exists(path(con)) : file(s) do not exist:
  ''

list.files(system.file("extdata", package="VariantAnnotation"))
[1] "chr22.vcf.gz"         "chr22.vcf.gz.tbi"     "chr7-sub.vcf.gz"
[4] "chr7-sub.vcf.gz.tbi"  "ex2.vcf"              "gl_chr1.vcf"
[7] "h1187-10k.vcf.gz"     "h1187-10k.vcf.gz.tbi" "structural.vcf"

Much appreciate help,

Thanks,
Tinu

Hi,

I had the same problem today. Basically the system.file command is for loading example data from the package. To load your own data, just do:

vcf<-readVcf("chr22.vcf.gz","hg19")

Stathis

True but if I read my own data using readVcf:

file <- readVcf("file.vcf","hg19") 

the commands

hdr <- scanVcfHeader(file)
Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function ‘scanVcfHeader’ for signature ‘"CollapsedVCF"’**

and cannot follow the pipeline:

rm(hdr)
info(hdr)
geno(hdr)

Is it not a spelling mistake in your cmd

f1 <-system.file("extdata","chr22.vcf.gz", package="VatiantAnnotation")

"VatiantAnnotation" should be "VariantAnnotation"

Log in to answer this question.