Thanks a lot but the genome I am using is not the human genome.
Hi, I want to calculate B allele frequency from a vcf file. I found that vcftools can be used to estimate allele frequency of REF allele and ALT allele. I wonder if vcftools could also estimate B allele frequency. Are there other tools that we could use for calculation BAF from vcf file?
Thanks
2 answers
There is a same question being answered:It seems that if you have a vcf file and AD in your GT field, it is an easy calculation. Calculate the b allele frequency from a VCF file .
A paper describing an R package that can do that : https://www.sciencedirect.com/science/article/pii/S1525157817301666
If you are using R, you can take a look at the CopyNumberPlots Bioconductor package. Its focused on generating plots of BAF, LRR and copy-number segments from SNP-array and NGS, but it has a handy function to compute the BAF from a VCF where it will autodetect the presence of AD, GT and other formats for the allele depth. Just bear in mind that you need to set mirror.baf to false, since it will flip half of the allele frequencies to mimic the effect of the B-allele definition in Illumina arrays.
Using
loadSNPDataFromVCF(vcf.file = "Your.vcf", genome="hg19", mirror.baf = FALSE)
you'll get a GRanges with the position and identifiers of your variants and their B-allele frequency ready to use.
It should work with other genomes too. And I'm pretty sure it should be possible for it to work with unknown and custom genomes too.
Apologies for resurrecting this post, but any idea what that functions "regions" paramater takes? Would it be a GRanges object? The documentation doesnt specify.
Log in to answer this question.
B allele frequency, like from a illumina genotyping array?
Not from Illumina genotyping array but from vcf file generated from NGS data.