This is a test version of Biostars. For the public version, visit https://www.biostars.org.
minor allele frequency (MAF) from vcf

How minor allele frequency (MAF) is calculated from the DP4 fields of vcf file? Can anyone help with a unix shell script?

snp sequencing next-gen genome

That's cool man..! Its working fine.

2 answers

It is easy to do with awk. I found an easy way as follows. for single input snv vcf file

awk '$1=="#CHROM" {print $0 "\tMAF"; next}; NF { info=$8; gsub(/.*;DP4=|;MQ=.*/, "", info); split(info, a, /,/); print $0 "\t" (a[3]+a[4])/(a[1]+a[2]+a[3]+a[4])}' inputfile.vcf > outputfile.vcf

for multiple input snv vcf files

awk '$1=="#CHROM" {print $0 "\tMAF" > FILENAME".MAF.vcf"; next}; NF { info=$8; gsub(/.*;DP4=|;MQ=.*/, "", info); split(info, a, /,/); print $0 "\t" (a[3]+a[4])/(a[1]+a[2]+a[3]+a[4]) > FILENAME".MAF.vcf"}' inputfile1.vcf inputfile2.vcf

The SNiPlay online pipeline implements VCFtools that calculates MAF from a VCF file: http://sniplay.southgreen.fr/cgi-bin/analysis_v3.cgi

Log in to answer this question.