<p>A couple fast alternatives:</p>
<pre><code><span class="math-container">$ bedops --chrom chr14 -n 1 &lt;(vcf2bed &lt; variants.vcf) &lt;(sort-bed repeats.bed) &gt; answer.bed
$</span> bedops --chrom chr14 -n 1 &lt;(vcf2bed &lt; variants.vcf) &lt;(rmsk2bed &lt; repeats.rmsk) &gt; answer.bed
</code></pre>
<p>Using <code>--chrom chr14</code> focuses set operations on that chromosome.</p>

CC BY-SA 4.0
2021-05-28T12:17:25.383Z
This worked for me. Thanks Alex Reynolds
John
CC BY-SA 4.0
2021-05-28T06:13:29.053Z
2021-05-28T06:13:29.053Z
Alex Reynolds
<p><a href="https://vcftools.github.io/man_latest.html" rel="nofollow noreferrer"><code>vcftools</code></a> with the <code>--exclude-bed</code> option or <a href="https://bedtools.readthedocs.io/en/latest/index.html" rel="nofollow noreferrer"><code>bedtools</code></a> with the <code>subtract</code> command should do the trick.</p>

CC BY-SA 4.0
2021-05-27T13:25:13.573Z
how about using bedtools intersect -v?
John
CC BY-SA 4.0
2021-05-27T13:47:00.023Z
probably better to use ``bcftools view -R .bedfile`` - vcftools isn't maintained any more and a fair bit slower than bcftools.
user438383
CC BY-SA 4.0
2021-05-27T13:19:59.010Z
2021-05-27T13:19:59.010Z
haci
<p>I have a 1000 genomes vcf file for chromosome 14. And I want to remove variants in repetitive regions flagged by repeatMasker. I have a bed file for those repeats. I downloaded that file from UCSC. How can I eliminate/remove those sites in vcf file using repeat masker's bed file? Insights will be appreciated.</p>

<vcf><snp><bedtools><repeatmasker><variants>
Remove repetitive region vcf file using repeatmasker bed file
# Remove repetitive region vcf file using repeatmasker bed file

(Asked by: username_0 on 2021-05-27)

I have a 1000 genomes vcf file for chromosome 14. And I want to remove variants in repetitive regions flagged by repeatMasker. I have a bed file for those repeats. I downloaded that file from UCSC. How can I eliminate/remove those sites in vcf file using repeat masker's bed file? Insights will be appreciated.

**Tags:** vcf, snp, bedtools, repeatmasker, variants

---

## 2 answers

### Answer by username_1 on 2021-05-28. Score: 2 | Accepted answer

A couple fast alternatives:
$ bedops --chrom chr14 -n 1 <(vcf2bed < variants.vcf) <(sort-bed repeats.bed) > answer.bed
$ bedops --chrom chr14 -n 1 <(vcf2bed < variants.vcf) <(rmsk2bed < repeats.rmsk) > answer.bed

Using --chrom chr14 focuses set operations on that chromosome.

> **Comments:**
> **username_0**: This worked for me. Thanks Alex Reynolds  

---

### Answer by username_2 on 2021-05-27. Score: 0

[`vcftools`](https://vcftools.github.io/man_latest.html) with the `--exclude-bed` option or [`bedtools`](https://bedtools.readthedocs.io/en/latest/index.html) with the `subtract` command should do the trick.

> **Comments:**
> **username_0**: how about using bedtools intersect -v?  
> **username_3**: probably better to use ``bcftools view -R .bedfile`` - vcftools isn't maintained any more and a fair bit slower than bcftools.  

---

