Answers.Body: <p>bcftools has a plugin called <a href="https://samtools.github.io/bcftools/howtos/plugin.fill-tags.html" rel="nofollow noreferrer">fill-tags</a> which should do the job for you easily, without having to mess around with lots of complicated bash scripting.</p>
  
  <p>You could do something along the lines of this, presuming you have a .vcf file with all the IBS individuals in it:</p>
  
  <pre><code>bcftools +fill-tags in.vcf.gz -Oz -o out.vcf.gz
  </code></pre>
  
  <p>This will give each position in the .vcf file new INFO tags, one of which will be allele-frequency. </p>
  
  <p>You can then pull off the frequency for a particular variant (CHR:POS) by:</p>
  
  <pre><code>bcftools query -t CHR:POS -f'%CHROM\t%POS\t%AF\n' out.vcf.gz
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-07-02T09:34:54.767Z
Answers.Text: I will check it out. Thanks
Answers.UserDisplayName: 719016
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-07-02T00:57:28.837Z
Answers.LastActivityDate: 2019-07-02T00:57:28.837Z
Answers.UserDisplayName: user438383
Body: <p>What's the recommended way to create population-level Allele Frequency variant entries from a set of individuals (vcfs?) in the 1000 genomes (or similar) project?</p>
  
  <p>For example, given the IBS individuals in the 1000 Genomes project:</p>
  
  <p><a href="http://www.internationalgenome.org/data-portal/population/IBS" rel="nofollow noreferrer">http://www.internationalgenome.org/data-portal/population/IBS</a></p>
  
  <p>I would like to create an IBS <code>.vcf.gz</code> that contains an IBS population-level AF entry for each of the variants present.</p>
  
  <p>Any ideas on how to achieve this?</p>
  
  <p>EDIT: this is related to my earlier question on how to create the most complete file for population allele frequencies, here:
  <a href="https://bioinformatics.stackexchange.com/questions/8838/what-is-the-most-complete-vcf-file-of-population-allele-frequencies-that-can-be">what is the most complete vcf file of population allele frequencies that can be built/downloaded from public datasets?</a></p>
  
  <p>I have seen that there is an Allele Frequency Calculator tool in EnsEMBL, which is at least available with GRCh37:</p>
  
  <p><a href="http://www.internationalgenome.org/allele-frequency-calculator-documentation" rel="nofollow noreferrer">http://www.internationalgenome.org/allele-frequency-calculator-documentation</a></p>
  
  <p><a href="http://grch37.ensembl.org/Homo_sapiens/Tools/AlleleFrequency?db=core" rel="nofollow noreferrer">http://grch37.ensembl.org/Homo_sapiens/Tools/AlleleFrequency?db=core</a></p>
  
  <p>There are also instructions on how to do this genome-wide using vcftools:</p>
  
  <pre><code>vcf-subset -c ~/1000g/IBS.samples.list ~/1000g/ALL.chr1.phase3_shapeit2_mvncall_integrated_v5a.20130502.genotypes.vcf.gz | fill-an-ac | bgzip -c &gt; ~/1000g/IBS.chr1.20130502.vcf.gz
  </code></pre>
  
  <p>This seems to be generating correct files, and the AF can be calculated with a tool that combines <code>AC</code> and <code>AN</code> values, such as it is described here:</p>
  
  <p><a href="https://www.biostars.org/p/123468/" rel="nofollow noreferrer">https://www.biostars.org/p/123468/</a></p>
  
  <p>Any other ideas / warnings / pitfalls of the approach?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-06-25T07:52:26.213Z
Comments.Text: Are you looking to get this genome-wide? Or are you only interested in particular regions/variants?
Comments.UserDisplayName: Emily_Ensembl
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-06-25T13:22:28.877Z
Comments.Text: Hi @Emily_Ensembl looking to do this genome-wide for as many populations as possible. I see there are 25-30 available in EnsEMBL from the 1000 genomes project.
Comments.UserDisplayName: 719016
Tags: <vcf><genomics><allele-frequency>
Title: creating population AF from set of individuals in 1000 genomes population?
ThreadText: # creating population AF from set of individuals in 1000 genomes population?
  
  (Asked by: username_0 on 2019-06-25)
  
  What's the recommended way to create population-level Allele Frequency variant entries from a set of individuals (vcfs?) in the 1000 genomes (or similar) project?
  
  For example, given the IBS individuals in the 1000 Genomes project:
  
  <http://www.internationalgenome.org/data-portal/population/IBS>
  
  I would like to create an IBS `.vcf.gz` that contains an IBS population-level AF entry for each of the variants present.
  
  Any ideas on how to achieve this?
  
  EDIT: this is related to my earlier question on how to create the most complete file for population allele frequencies, here:
  [what is the most complete vcf file of population allele frequencies that can be built/downloaded from public datasets?](https://bioinformatics.stackexchange.com/questions/8838/what-is-the-most-complete-vcf-file-of-population-allele-frequencies-that-can-be)
  
  I have seen that there is an Allele Frequency Calculator tool in EnsEMBL, which is at least available with GRCh37:
  
  <http://www.internationalgenome.org/allele-frequency-calculator-documentation>
  
  <http://grch37.ensembl.org/Homo_sapiens/Tools/AlleleFrequency?db=core>
  
  There are also instructions on how to do this genome-wide using vcftools:
  
  ```
  vcf-subset -c ~/1000g/IBS.samples.list ~/1000g/ALL.chr1.phase3_shapeit2_mvncall_integrated_v5a.20130502.genotypes.vcf.gz | fill-an-ac | bgzip -c > ~/1000g/IBS.chr1.20130502.vcf.gz
  
  ```
  
  This seems to be generating correct files, and the AF can be calculated with a tool that combines `AC` and `AN` values, such as it is described here:
  
  <https://www.biostars.org/p/123468/>
  
  Any other ideas / warnings / pitfalls of the approach?
  
  **Tags:** vcf, genomics, allele-frequency
  
  > **Comments:**
  > **username_1**: Are you looking to get this genome-wide? Or are you only interested in particular regions/variants?  
  > **username_0**: Hi @username_1 looking to do this genome-wide for as many populations as possible. I see there are 25-30 available in EnsEMBL from the 1000 genomes project.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2019-07-02. Score: 1 | Accepted answer
  
  bcftools has a plugin called [fill-tags](https://samtools.github.io/bcftools/howtos/plugin.fill-tags.html) which should do the job for you easily, without having to mess around with lots of complicated bash scripting.
  
  You could do something along the lines of this, presuming you have a .vcf file with all the IBS individuals in it:
  
  ```
  bcftools +fill-tags in.vcf.gz -Oz -o out.vcf.gz
  
  ```
  
  This will give each position in the .vcf file new INFO tags, one of which will be allele-frequency.
  
  You can then pull off the frequency for a particular variant (CHR:POS) by:
  
  ```
  bcftools query -t CHR:POS -f'%CHROM\t%POS\t%AF\n' out.vcf.gz
  
  ```
  
  > **Comments:**
  > **username_0**: I will check it out. Thanks  
  
  ---
  
  