Question: add VAF or FREQ in vcf file from read depth
0
gravatar for nikimourtzi23
3 months ago by
nikimourtzi230 wrote:

Hi,

I have a vcf file with these values GT:VR:RR:DP:GQ in the format field. I would like to add the Variant Allele frequency tag (Frequency of alternate allele). I know that I can calculate it manually from the read depth information FREQ=(DP-RR)100/DP where DP: read depth and RR: reference read depth. Do you know any way to do it with commands (bcftools,vcftools or awk)?

Thanks!

next-gen • 158 views
ADD COMMENTlink modified 3 months ago by Pierre Lindenbaum128k • written 3 months ago by nikimourtzi230
0
gravatar for Pierre Lindenbaum
3 months ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum128k wrote:

(not tested) using VcfFilterJdk http://lindenb.github.io/jvarkit/VcfFilterJdk.html

$ bcftools view in.vcf.gz |\
awk '/^#CHROM/ {printf("##FORMAT=<ID=FREQ,Number=1,Type=Float,Description=\"\">\n");} {print;}' |
java -jar dist/vcffilterjdk.jar -e 'final List<Genotype> gts = new ArrayList<>();for(final Genotype gt:variant.getGenotypes()) {final GenotypeBuilder gb=new GenotypeBuilder(gt);if(gt.hasDP() && gt.hasAnyAttribute("RR")){double rr =  gt.getAttributeAsDouble("RR",0.0);gb.attribute("FREQ",((gt.getDP()-rr)*100.0)/gt.getDP());}gts.add(gb.make());}return new VariantContextBuilder(variant).genotypes(gts).make();'
ADD COMMENTlink written 3 months ago by Pierre Lindenbaum128k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1292 users visited in the last hour