<p>Here is another way to achieve your goal using the <code>fuc vcf_vep</code> <a href="https://sbslee-fuc.readthedocs.io/en/latest/cli.html#vcf-vep" rel="nofollow noreferrer">command</a> I wrote:</p>
<pre><code>$ fuc vcf_vep in.vcf 'SIFT.str.contains(&quot;deleterious&quot;) and PolyPhen.str.contains(&quot;damaging&quot;)' &gt; out.vcf
</code></pre>
<p>For getting help:</p>
<pre><code>$ fuc vcf_vep -h
usage: fuc vcf_vep [-h] [--opposite] [--as_zero] vcf expr

This command will filter a VCF file annotated by Ensemble VEP. It essentially wraps the `pandas.DataFrame.query` method. For details on query expression, please visit the method's documentation page (https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.query.html#pandas-dataframe-query).

examples:
  <span class="math-container">$ fuc vcf_vep in.vcf 'SYMBOL == "TP53"' &gt; out.vcf
  $</span> fuc vcf_vep in.vcf 'SYMBOL != &quot;TP53&quot;' &gt; out.vcf
  <span class="math-container">$ fuc vcf_vep in.vcf 'SYMBOL == "TP53"' --opposite &gt; out.vcf
  $</span> fuc vcf_vep in.vcf 'Consequence in [&quot;splice_donor_variant&quot;, &quot;stop_gained&quot;]' &gt; out.vcf
  <span class="math-container">$ fuc vcf_vep in.vcf '(SYMBOL == "TP53") and (Consequence.str.contains("stop_gained"))' &gt; out.vcf
  $</span> fuc vcf_vep in.vcf 'gnomAD_AF &lt; 0.001' &gt; out.vcf
  $ fuc vcf_vep in.vcf 'gnomAD_AF &lt; 0.001' --as_zero &gt; out.vcf

positional arguments:
  vcf         Ensemble VEP-annotated VCF file
  expr        query expression to evaluate

optional arguments:
  -h, --help  show this help message and exit
  --opposite  use this flag to return records that don’t meet the said criteria
  --as_zero   use this flag to treat missing values as zero instead of NaN
</code></pre>
<p>You can also do above with Python:</p>
<pre><code>from fuc import pyvcf, pyvep
vf = pyvcf.VcfFrame.from_file('in.vcf')
expr = 'SIFT.str.contains(&quot;deleterious&quot;) and PolyPhen.str.contains(&quot;damaging&quot;)'
filtered_vf = pyvep.filter_query(vf, expr)
filtered_vf.to_file('out.vcf')
</code></pre>

CC BY-SA 4.0
2021-06-12T12:18:46.790Z
2021-06-12T12:24:08.290Z
2021-06-12T12:24:08.290Z
Seung-been Steven Lee
<p>If you are working under a Linux environment, then you may easily use a piped grep search. For example:</p>

<pre><code>grep deleterious file.vcf |grep damaging &gt;filtered_file.vcf
</code></pre>

CC BY-SA 4.0
2021-06-07T16:26:24.127Z
The grep output will not be a properly formed VCF.
Ram RS
CC BY-SA 4.0
2020-05-12T13:26:43.013Z
2020-05-12T13:26:43.013Z
thomas duge de bernonville
<p>I think what you're trying to do could be achieved by adding parenthesis to the conditions and by specifying the format of the input file by using the flag <code>--format vcf</code>, as specified in the <a href="https://www.ensembl.org/info/docs/tools/vep/script/vep_filter.html" rel="nofollow noreferrer">documentation</a>.
The final command should look like this:</p>
<pre class="lang-bash prettyprint-override"><code>filter_vep -i &quot;$input&quot; --format vcf --filter &quot;(SIFT = deleterious) and (PolyPhen match damaging)&quot; -o &quot;$output&quot;
</code></pre>

CC BY-SA 4.0
2021-06-07T14:00:14.003Z
2021-06-07T14:00:14.003Z
Rosaria Tornisiello
<p>I am filtering a VEP annotated vcf, trying to maintain just those variants classified as deleterious by <code>SIFT</code>and as damaging (probably or possibly included) by <code>PolyPhen</code>.</p>

<p>I am using:</p>

<pre><code>filter_vep -i "$input" -o "$output" -filter "SIFT = deleterious and PolyPhen match damaging"
</code></pre>

<p>and I also tried:</p>

<pre><code>filter_vep -i "$input" -o "$output" -filter "SIFT match deleterious and PolyPhen match damaging"
</code></pre>

<p>The output contains just variants with some value in these two fields, but some of the variants are classified as tolerated by <code>SIFT</code> and as benign by <code>PolyPhen</code>, so do you know why the filter is not working?</p>

<p>As an example: this two variants shouldn't exist in my filtered VCF, because the first one is classified as benign by PolyPhen and the second is classified as benign by both fields:</p>

<pre><code>    CHROM  POS  REF  ALT  FILTER  INFO
    1       1934441 .       G       T       .       PASS    deleterious(0.01)|benign(0.138)
    1       207085100       .       G       A       .       PASS   tolerated(0.16)|benign(0.037)
</code></pre>

<p>As an example of a variant that has pass properly those filters:</p>

<pre><code>    CHROM  POS  REF  ALT  FILTER  INFO
    2       3938449 .       T       A       .       PASS    deleterious(0.01)|probably damaging(0.67)
</code></pre>

<p>Those are 3 variants among those that I have in my filtered VCF, but I should be getting just those variants which are classified as deleterious and damaging by both SIFT and PolyPhen, as the third variant I've shown.</p>

<sequence-annotation><variant-calling>
Filtering VEP annotation file
# Filtering VEP annotation file

(Asked by: username_0 on 2020-05-01)

I am filtering a VEP annotated vcf, trying to maintain just those variants classified as deleterious by SIFTand as damaging (probably or possibly included) by PolyPhen.
I am using:
filter_vep -i "$input" -o "$output" -filter "SIFT = deleterious and PolyPhen match damaging"

and I also tried:
filter_vep -i "$input" -o "$output" -filter "SIFT match deleterious and PolyPhen match damaging"

The output contains just variants with some value in these two fields, but some of the variants are classified as tolerated by SIFT and as benign by PolyPhen, so do you know why the filter is not working?
As an example: this two variants shouldn't exist in my filtered VCF, because the first one is classified as benign by PolyPhen and the second is classified as benign by both fields:
    CHROM  POS  REF  ALT  FILTER  INFO
    1       1934441 .       G       T       .       PASS    deleterious(0.01)|benign(0.138)
    1       207085100       .       G       A       .       PASS   tolerated(0.16)|benign(0.037)

As an example of a variant that has pass properly those filters:
    CHROM  POS  REF  ALT  FILTER  INFO
    2       3938449 .       T       A       .       PASS    deleterious(0.01)|probably damaging(0.67)

Those are 3 variants among those that I have in my filtered VCF, but I should be getting just those variants which are classified as deleterious and damaging by both SIFT and PolyPhen, as the third variant I've shown.

**Tags:** sequence-annotation, variant-calling

---

## 3 answers

### Answer by username_4 on 2021-06-07. Score: 4 | Accepted answer

I think what you're trying to do could be achieved by adding parenthesis to the conditions and by specifying the format of the input file by using the flag --format vcf, as specified in the documentation.
The final command should look like this:
filter_vep -i "$input" --format vcf --filter "(SIFT = deleterious) and (PolyPhen match damaging)" -o "$output"


---

### Answer by username_1 on 2021-06-12. Score: 2

Here is another way to achieve your goal using the fuc vcf_vep command I wrote:
$ fuc vcf_vep in.vcf 'SIFT.str.contains("deleterious") and PolyPhen.str.contains("damaging")' > out.vcf

For getting help:
$ fuc vcf_vep -h
usage: fuc vcf_vep [-h] [--opposite] [--as_zero] vcf expr

This command will filter a VCF file annotated by Ensemble VEP. It essentially wraps the `pandas.DataFrame.query` method. For details on query expression, please visit the method's documentation page (https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.query.html#pandas-dataframe-query).

examples:
  $ fuc vcf_vep in.vcf 'SYMBOL == "TP53"' > out.vcf
  $ fuc vcf_vep in.vcf 'SYMBOL != "TP53"' > out.vcf
  $ fuc vcf_vep in.vcf 'SYMBOL == "TP53"' --opposite > out.vcf
  $ fuc vcf_vep in.vcf 'Consequence in ["splice_donor_variant", "stop_gained"]' > out.vcf
  $ fuc vcf_vep in.vcf '(SYMBOL == "TP53") and (Consequence.str.contains("stop_gained"))' > out.vcf
  $ fuc vcf_vep in.vcf 'gnomAD_AF < 0.001' > out.vcf
  $ fuc vcf_vep in.vcf 'gnomAD_AF < 0.001' --as_zero > out.vcf

positional arguments:
  vcf         Ensemble VEP-annotated VCF file
  expr        query expression to evaluate

optional arguments:
  -h, --help  show this help message and exit
  --opposite  use this flag to return records that don’t meet the said criteria
  --as_zero   use this flag to treat missing values as zero instead of NaN

You can also do above with Python:
from fuc import pyvcf, pyvep
vf = pyvcf.VcfFrame.from_file('in.vcf')
expr = 'SIFT.str.contains("deleterious") and PolyPhen.str.contains("damaging")'
filtered_vf = pyvep.filter_query(vf, expr)
filtered_vf.to_file('out.vcf')


---

### Answer by username_2 on 2020-05-12. Score: -1

If you are working under a Linux environment, then you may easily use a piped grep search. For example:
grep deleterious file.vcf |grep damaging >filtered_file.vcf

> **Comments:**
> **username_3**: The grep output will not be a properly formed VCF.  

---

