<p>Something like <a href="http://vcftools.sourceforge.net/perl_module.html#vcf-isec" rel="nofollow noreferrer">vcf-isec</a>? Quoting:</p>

<blockquote>
  <p>Creates intersections and complements of two or more VCF files. Given multiple VCF files, it can output the list of positions which are shared by at least N files, at most N files, exactly N files, etc. The first example below outputs positions shared by at least two files and the second outputs positions present in the files A but absent from files B and C. </p>
</blockquote>

CC BY-SA 4.0
2019-05-31T08:36:18.760Z
Thank you!!!  I had suspected that there would be something like that but I was having trouble finding anything. I really appreciate it
Sarah
CC BY-SA 4.0
2019-05-31T08:06:24.483Z
2019-06-03T14:59:14.647Z
2019-06-03T14:59:14.647Z
Pallie
<p>The <a href="https://bedtools.readthedocs.io/en/latest/content/tools/intersect.html" rel="nofollow noreferrer">bedtools intersect</a> command is my go-to for operations like this. From the manual:</p>

<blockquote>
  <p>By far, the most common question asked of two sets of genomic features is whether or not any of the features in the two sets “overlap” with one another. This is known as feature intersection. <code>bedtools intersect</code> allows one to screen for overlaps between two sets of genomic features. Moreover, it allows one to have fine control as to how the intersections are reported. <code>bedtools intersect</code> works with both BED/GFF/VCF and BAM files as input.</p>
</blockquote>

CC BY-SA 4.0
2019-06-03T15:01:08.687Z
2019-06-03T15:01:08.687Z
Daniel Standage
<p>You can try something like this in <code>bcftools</code>, which is a bit quicker than VCFtools, as it uses block gzipping and indexing.</p>

<pre><code># make sure both files are indexed and in bgzip format 
bcftools index vcfA.vcf.gz
bcftools index vcfB.vcf.gz

# find overlapping positions between the two files
bcftools isec -n~11 -c all vcfA.vcf.gz vcfB.vcf.gz &gt; sharedPositions.txt

# filter vcf files for the overlapping positions
bcftools view -T sharedPositions.txt vcfA.vcf.gz -Oz &gt; vcfA.sharedPositions.vcf.gz

bcftools view -T sharedPositions.txt vcfB.vcf.gz -Oz &gt; vcfB.sharedPositions.vcf.gz
</code></pre>

<p>The perhaps use something like plink2 to look at the missing rate per variant and individual for each file:</p>

<pre><code>plink2 --vcf vcfA.vcf.gz --missing --out vcfA.missingStats
</code></pre>

CC BY-SA 4.0
2019-05-31T23:01:49.547Z
2019-05-31T23:01:49.547Z
user438383
<p>I have two VCF files and I want to compare the missing rate in each of them, but I want to only look at sites that are present in both files.  How could I go about getting a list of positions that are included in both VCF files and then filtering those VCF files to only include those positions?</p>

<vcf><variant-calling><variation>
Find overlap between VCF files
# Find overlap between VCF files

(Asked by: username_0 on 2019-05-31)

I have two VCF files and I want to compare the missing rate in each of them, but I want to only look at sites that are present in both files. How could I go about getting a list of positions that are included in both VCF files and then filtering those VCF files to only include those positions?

**Tags:** vcf, variant-calling, variation

---

## 3 answers

### Answer by username_1 on 2019-05-31. Score: 2 | Accepted answer

Something like [vcf-isec](http://vcftools.sourceforge.net/perl_module.html#vcf-isec)? Quoting:

> Creates intersections and complements of two or more VCF files. Given multiple VCF files, it can output the list of positions which are shared by at least N files, at most N files, exactly N files, etc. The first example below outputs positions shared by at least two files and the second outputs positions present in the files A but absent from files B and C.

> **Comments:**
> **username_0**: Thank you!!!  I had suspected that there would be something like that but I was having trouble finding anything. I really appreciate it  

---

### Answer by username_2 on 2019-06-03. Score: 3

The [bedtools intersect](https://bedtools.readthedocs.io/en/latest/content/tools/intersect.html) command is my go-to for operations like this. From the manual:

> By far, the most common question asked of two sets of genomic features is whether or not any of the features in the two sets “overlap” with one another. This is known as feature intersection. `bedtools intersect` allows one to screen for overlaps between two sets of genomic features. Moreover, it allows one to have fine control as to how the intersections are reported. `bedtools intersect` works with both BED/GFF/VCF and BAM files as input.


---

### Answer by username_3 on 2019-05-31. Score: 2

You can try something like this in bcftools, which is a bit quicker than VCFtools, as it uses block gzipping and indexing.
# make sure both files are indexed and in bgzip format 
bcftools index vcfA.vcf.gz
bcftools index vcfB.vcf.gz

# find overlapping positions between the two files
bcftools isec -n~11 -c all vcfA.vcf.gz vcfB.vcf.gz > sharedPositions.txt

# filter vcf files for the overlapping positions
bcftools view -T sharedPositions.txt vcfA.vcf.gz -Oz > vcfA.sharedPositions.vcf.gz

bcftools view -T sharedPositions.txt vcfB.vcf.gz -Oz > vcfB.sharedPositions.vcf.gz

The perhaps use something like plink2 to look at the missing rate per variant and individual for each file:
plink2 --vcf vcfA.vcf.gz --missing --out vcfA.missingStats


---

