Answers.Body: <p>You can use <code>bedtools intersect</code> but first use <code>bcftools norm</code>.  <a href="http://www.htslib.org/doc/bcftools.html#norm" rel="nofollow noreferrer">bcftools norm</a> will left-align and normalize indels to get both vcf files consistent with each other.  This should resolve the matching if they are truly matching variants.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-07T10:13:57.517Z
Answers.Text: This could resolve some of the cases if the input files are not normalized. However, there could be indels that are normalized and 1 bp away from each other (*i.e.* close but not touching each other). In my understanding, the OP wants to consider these cases as genuine matches.
Answers.UserDisplayName: dariober
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-07T14:19:32.217Z
Answers.Text: I will let the OP clarify but it seemed to me that these were matching variants just with alignment artifacts.  If that is true then they should normalize out.
Answers.UserDisplayName: Bioathlete
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-07T02:20:20.810Z
Answers.LastActivityDate: 2018-01-07T02:20:20.810Z
Answers.UserDisplayName: Bioathlete
Answers.Body: <p>You could use <code>bedtools closest</code> with <code>-d</code> option (<em>-d: In addition to the closest feature in B, report its distance to A as an extra column.</em>). Indels that have no match in file A would be those where the closest indel in file B is more than <em>x</em> bases away.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-07T14:20:46.583Z
Answers.Text: You have to be careful here that you are not matching a snp with an indel or vise versa.
Answers.UserDisplayName: Bioathlete
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-07T10:08:44.440Z
Answers.LastActivityDate: 2018-01-07T10:08:44.440Z
Answers.UserDisplayName: dariober
Body: <p>I am using <code>bedtools</code> to test whether a set of variant calls produced by a new method is missing any variants from a set of known validated variants.</p>
  
  <pre><code>bedtools intersect -v -a newcalls.vcf -b goldstandard.vcf
  </code></pre>
  
  <p>It's working as intended for SNV calls, but it occasionally misses indels due to a single base pair discrepancy. It's usually an alignment artifact that doesn't affect the interpretation of the variant.</p>
  
  <p>My first thought was to make a BED file with intervals that extend a few bp beyond each variant call, and comparing <em>this</em> BED file to the known variants. However, I was wondering whether approximate matching is possible with <code>bedtools intersect</code>?</p>
  
Tags: <vcf><bedtools>
Title: Approximate matches with bedtools intersect
ThreadText: # Approximate matches with bedtools intersect
  
  (Asked by: username_0 on 2018-01-06)
  
  I am using `bedtools` to test whether a set of variant calls produced by a new method is missing any variants from a set of known validated variants.
  
  ```
  bedtools intersect -v -a newcalls.vcf -b goldstandard.vcf
  
  ```
  
  It's working as intended for SNV calls, but it occasionally misses indels due to a single base pair discrepancy. It's usually an alignment artifact that doesn't affect the interpretation of the variant.
  
  My first thought was to make a BED file with intervals that extend a few bp beyond each variant call, and comparing *this* BED file to the known variants. However, I was wondering whether approximate matching is possible with `bedtools intersect`?
  
  **Tags:** vcf, bedtools
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2018-01-07. Score: 2
  
  You can use `bedtools intersect` but first use `bcftools norm`. [bcftools norm](http://www.htslib.org/doc/bcftools.html#norm) will left-align and normalize indels to get both vcf files consistent with each other. This should resolve the matching if they are truly matching variants.
  
  > **Comments:**
  > **username_2**: This could resolve some of the cases if the input files are not normalized. However, there could be indels that are normalized and 1 bp away from each other (*i.e.* close but not touching each other). In my understanding, the OP wants to consider these cases as genuine matches.  
  > **username_1**: I will let the OP clarify but it seemed to me that these were matching variants just with alignment artifacts.  If that is true then they should normalize out.  
  
  ---
  
  ### Answer by username_2 on 2018-01-07. Score: -1
  
  You could use `bedtools closest` with `-d` option (*-d: In addition to the closest feature in B, report its distance to A as an extra column.*). Indels that have no match in file A would be those where the closest indel in file B is more than *x* bases away.
  
  > **Comments:**
  > **username_1**: You have to be careful here that you are not matching a snp with an indel or vise versa.  
  
  ---
  
  