-1
$\begingroup$

How do I remove rows in a VCF file on 1kGenome column, where Match=EXACT using bash ?

$\endgroup$
1
  • 2
    $\begingroup$ Please edit your question to include a couple of relevant lines from your .vcf. $\endgroup$
    – user438383
    Mar 24, 2021 at 17:06

2 Answers 2

2
$\begingroup$

You can filter records in Python for example using pyvcf.VcfFrame.filter_flagany() method I wrote:

>>> from fuc import pyvcf
>>> data = {
...     'CHROM': ['chr1', 'chr1', 'chr1', 'chr1'],
...     'POS': [100, 101, 102, 103],
...     'ID': ['.', '.', '.', '.'],
...     'REF': ['G', 'T', 'A', 'C'],
...     'ALT': ['A', 'C', 'T', 'A'],
...     'QUAL': ['.', '.', '.', '.'],
...     'FILTER': ['.', '.', '.', '.'],
...     'INFO': ['DB', 'DB;H2;Match=EXACT', 'DB;H2;Match=EXACT', '.'],
...     'FORMAT': ['GT', 'GT', 'GT', 'GT'],
...     'Steven': ['0/0', '0/1', '0/1', '0/0'],
... }
>>> vf = pyvcf.VcfFrame.from_dict([], data)
>>> # vf = pyvcf.VcfFrame.from_file('your_vcf.vcf')
>>> vf.df
  CHROM  POS ID REF ALT QUAL FILTER               INFO FORMAT Steven
0  chr1  100  .   G   A    .      .                 DB     GT    0/0
1  chr1  101  .   T   C    .      .  DB;H2;Match=EXACT     GT    0/1
2  chr1  102  .   A   T    .      .  DB;H2;Match=EXACT     GT    0/1
3  chr1  103  .   C   A    .      .                  .     GT    0/0
>>> vf.filter_flagany(['Match=EXACT'], opposite=True).df
  CHROM  POS ID REF ALT QUAL FILTER INFO FORMAT Steven
0  chr1  100  .   G   A    .      .   DB     GT    0/0
1  chr1  103  .   C   A    .      .    .     GT    0/0
>>> # vf.to_file('filtered.vcf')
$\endgroup$
1
$\begingroup$

Hard to say without seeing VCF rows, but generally speaking with text files you can use grep, if I understand the question:

grep -vw "Match=EXACT" file.vcf > filtered.vcf
$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.