<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>

CC BY-SA 4.0
2020-11-16T11:18:46.983Z
2020-11-16T11:18:46.983Z
user438383
<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>

CC BY-SA 4.0
2020-11-16T09:53:35.747Z
2020-11-16T09:53:35.747Z
Carambakaracho
<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>

CC BY-SA 4.0
2020-11-16T06:04:04.427Z
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.
jared_mamrot
<genome><ngs><vcf><software-recommendation><exome>
How can I subset WGS data to the level of WES variants?
# 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 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


---

