Answers.Body: <p>I'll expand slightly on the previous answer. First print off the positions for the exome file and then use bcftools view to filter the variants from the whole genome file. You could also index the whole_genome.vcf file to make the filtering faster.</p>
  <pre><code>bcftools query \
      -f'%CHROM\t%POS\n' \
      exome.vcf &gt; exome_variants.txt
  
  bcftools view \
      -T exome_variants.txt \
      whole_genome.vcf &gt; whole_genome.exome_positions.vcf
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-11-16T11:18:46.983Z
Answers.LastActivityDate: 2020-11-16T11:18:46.983Z
Answers.UserDisplayName: user438383
Answers.Body: <p><a href="https://samtools.github.io/bcftools/bcftools.html#view" rel="nofollow noreferrer">bcftools</a> would be my choice, I'm sure bedtools could do the trick, too.
  Something along this</p>
  <pre><code>bcftools view --regions-file
  </code></pre>
  <p>or  --targets, --regions-file might require a tabix index.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-11-16T09:53:35.747Z
Answers.LastActivityDate: 2020-11-16T09:53:35.747Z
Answers.UserDisplayName: Carambakaracho
Body: <p>I would like to compare mutational signatures<sup>1</sup> in patients from different studies, however some studies are based on exome seq (i.e. ~20,000 coding variants) and some are from whole genome seq (i.e. ~22,000 coding variants) - is there a way to 'downsample' WGS data to better reflect WES data and effectively 'ignore' the coordinates of those ~2000 coding variants in the VCF files?</p>
  <blockquote>
  <p><sup>1</sup>Alexandrov, L.B., Kim, J., Haradhvala, N.J., Huang, M.N.,
  Ng, A.W.T., Wu, Y., Boot, A., Covington, K.R., Gordenin, D.A.,
  Bergstrom, E.N. and Islam, S.A., 2020. The repertoire of mutational
  signatures in human cancer. Nature, 578(7793), pp.94-101.</p>
  </blockquote>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-11-16T06:04:04.427Z
Comments.Text: Apparently this is trivial - according to a colleague you can take the WES bed file coordinates and remove any SNVs in the WGS file that fall outside those regions - but he didn't know of any software that does this in a more sophisticated manner.
Comments.UserDisplayName: jared_mamrot
Tags: <genome><ngs><vcf><software-recommendation><exome>
Title: How can I subset WGS data to the level of WES variants?
ThreadText: # How can I subset WGS data to the level of WES variants?
  
  (Asked by: username_0 on 2020-11-15)
  
  I would like to compare mutational signatures1 in patients from different studies, however some studies are based on exome seq (i.e. ~20,000 coding variants) and some are from whole genome seq (i.e. ~22,000 coding variants) - is there a way to 'downsample' WGS data to better reflect WES data and effectively 'ignore' the coordinates of those ~2000 coding variants in the VCF files?
  
  > 1Alexandrov, L.B., Kim, J., Haradhvala, N.J., Huang, M.N.,
  > Ng, A.W.T., Wu, Y., Boot, A., Covington, K.R., Gordenin, D.A.,
  > Bergstrom, E.N. and Islam, S.A., 2020. The repertoire of mutational
  > signatures in human cancer. Nature, 578(7793), pp.94-101.
  
  **Tags:** genome, ngs, vcf, software-recommendation, exome
  
  > **Comments:**
  > **username_0**: Apparently this is trivial - according to a colleague you can take the WES bed file coordinates and remove any SNVs in the WGS file that fall outside those regions - but he didn't know of any software that does this in a more sophisticated manner.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2020-11-16. Score: 3 | Accepted answer
  
  [bcftools](https://samtools.github.io/bcftools/bcftools.html#view) would be my choice, I'm sure bedtools could do the trick, too.
  Something along this
  
  ```
  bcftools view --regions-file
  
  ```
  
  or --targets, --regions-file might require a tabix index.
  
  
  ---
  
  ### Answer by username_1 on 2020-11-16. Score: 2
  
  I'll expand slightly on the previous answer. First print off the positions for the exome file and then use bcftools view to filter the variants from the whole genome file. You could also index the whole\_genome.vcf file to make the filtering faster.
  
  ```
  bcftools query \
      -f'%CHROM\t%POS\n' \
      exome.vcf > exome_variants.txt
  
  bcftools view \
      -T exome_variants.txt \
      whole_genome.vcf > whole_genome.exome_positions.vcf
  
  ```
  
  
  ---
  
  