How minor allele frequency (MAF) is calculated from the DP4 fields of vcf file? Can anyone help with a unix shell script?
How minor allele frequency (MAF) is calculated from the DP4 fields of vcf file? Can anyone help with a unix shell script?
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
Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Obtain MAF from VCF
Its a problematic situation.
Testing the leveling comment.
That's cool man..! Its working fine.