Read VEP output from command line in R
2
0
Entering edit mode
8 months ago
yussab ▴ 50

Dear Biostars Community,

I can't find a way to read my annotated VCF file with VEP from command line, with R. I tried with vcfR and ensemblVEP, but I can't find the right way to deal with the VEP.vcf file.

vep ensembl R Bash • 529 views
0
Entering edit mode
8 months ago

This is not pure R solution but it may be ok. Assuming the VEP annotation is the INFO tag CSQ and it uses | as separator (the default):

bcftools query -f '%CHROM|%POS|%ID|%REF|%ALT|%QUAL|%FILTER|%INFO/CSQ\n' vep.vcf > vep.txt


Now vep.txt is a | separated table with columns CHROM, POS, etc. The meaning of the VEP columns is in the VCF header you should be able to extract it with e.g.

bcftools view -h vep.vcf | grep '##INFO=<ID=CSQ,'


To read it in R you can use read.table('vep.txt', sep= '|', ...)

0
Entering edit mode

Thank you dariober, however this didn't function. I can't understand why I found an higher number of "|" in my file than expected by "INFO-ID=CSQ"... Who is this possible?? Make me really confused

0
Entering edit mode
8 months ago
prasundutta87 ▴ 580

In addition to the above answer, I would like to add that bcftools has a VEP-specific plugin which can also be used. More information can be found in: https://samtools.github.io/bcftools/howtos/plugin.split-vep.html

And of course, the resulted output file can be then easily imported in R.