Heads up:
We’re moving the GATK website, docs and forum to a new platform. Read the full story and breakdown of key changes on this blog.
If you happen to see a question you know the answer to, please do chime in and help your fellow community members. We encourage our fourm members to be more involved, jump in and help out your fellow researchers with their questions. GATK forum is a community forum and helping each other with using GATK tools and research is the cornerstone of our success as a genomics research community.We appreciate your help!

Test-drive the GATK tools and Best Practices pipelines on Terra

Check out this blog post to learn how you can get started with GATK and try out the pipelines in preconfigured workspaces (with a user-friendly interface!) without having to install anything.
We will be out of the office for a Broad Institute event from Dec 10th to Dec 11th 2019. We will be back to monitor the GATK forum on Dec 12th 2019. In the meantime we encourage you to help out other community members with their queries.
Thank you for your patience!

Count Genotypes per position in a multi-sample VCF


For a multi-sample VCF is there a module/walker availble in GATK to count the total number genotypes for every position? (i.e. give the counts each of het., alt.hom, reference or unknown)


Best Answer


  • mikawinmikawin Member

    Hi G,

    Thanks for your reply. Before I plunged and wrote a script, I wanted to make sure that I was not re-inventing the wheel!


  • estif74estif74 Saint Paul, MN, USAMember

    Hi, sorry if you may have figured this out already in a walker you wrote, but I was searching for the same thing today. It looks like if you use the walker VariantsToTable you can add -F HOM-REF -F HET -F HOM-VAR -F NO-CALL to your arguments, you can count the genotypes at every position. There's a little blurb right in the Overview section that explains this. Maybe this is a new function in 3.4, but it's quite handy so thanks GATK Development Team :-)

  • SheilaSheila Broad InstituteMember, Broadie admin

    Ah, thanks for catching that. Hopefully, Mika and others will find this helpful.


  • tommycarstensentommycarstensen United KingdomMember ✭✭✭
    edited August 2015

    @mikawin @estif74 Unfortunately bcftools cannot do this to the best of my knowledge (not in one loop anyway). If I remember correctly GT has to be the first field according to the VCF file format description, so you can just do this awk one liner, if you care about memory and being able to pipe your output and don't care about speed/parallelisation:

    zcat mikawin.vcf.gz \
    | grep -v ^# \
    | awk '{
     unknown=0; homref=0; het=0; homalt=0; for(i=10;i<=NF;i++) {
      split($i,a,":"); split(a[1],GT,"[/|]");
      if(GT[1]=="."&&GT[2]==".") {unknown++}
      else if(GT[1]==0&&GT[2]==0) {homref++}
      else if(GT[1]==GT[2]) {homalt++}
      else {het++}};
     print $1,$2,$3,$4,$5,unknown,homref,homalt,het}'
Sign In or Register to comment.