This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to retrieve the genes associated to a VCF file?

Hi all

I've been starting to work with VCF (Variant Call Format) files recently, and I am not very familiar with them. The task that I have to solve right now is to retrieve all the genes associated to each VCF file. How can I do it?

To read the VCF files, I used the vcR R function:

library("vcfR")
fileName <- "CODE.gatk.snp.indel.vcf"
vcf <- read.vcfR(fileName)
print(head(vcf))
print(colnames(vcf))

Other than that, I don't know how to proceed. Can someone suggest me how to move forward?

Should I convert this file to a bed file and then intersect it through bedtools intersect with the human genome reference file?

Something else?

vcf genes r

4 answers

It looks like you are looking for the gene annotation of your variants. It might be possible to do that in R, but that's probably not optimal. More suitable would be tools like SnpEff, VEP and Annovar, but those are not R based.

Thanks Wouter for your reply. Sure, I can use other tools. Can you provide me the instructions for the tools you mentioned?

Those tools are well)documented, so you should be able to find instructions online. Let us know if you get stuck.

If you want to know what genes are affected by the variants in the VCF file what you should do is annotate the VCF. There are many tools for that and wouldn't recommend doing that with your own code.

For example

and many others

Does you vcf file contain SNPs IDs in the form or rs numbers (ex: rs876643) and position? If so you should use the GenomicRanges package from Bioconductor to map the position of the SNPs to the location of the genes and retrieve the gene names.

Does you vcf file contain SNPs IDs in the form or rs numbers (ex: re876643) and position? If so you should use the GenomicRanges package from Bioconductor to map the position of the SNPs to the location of the genes and retrieve the gene names.

Log in to answer this question.