VCF: removing all FORMAT but FORMAT/GT
2
0
Entering edit mode
2.7 years ago

how do i grep the vcf, so that i only need the GT information

Input:

chr1    67947   rs1202587463    A       AT      .       PASS    -       GT:GQ:DP:AD:MIN_DP:PGT:PID:PL:SB        0/0:22:21:.:11:.:.:.:.  0/0:24:21:.:9:.:.:.:.   0/0:2
chr1    69928   .       T       TAC     .       PASS    -       GT:GQ:DP:AD:MIN_DP:PGT:PID:PL:SB        0/0:21:22:.:8:.:.:.:.   0/0:35:34:.:21:.:.:.:.  0/0:30:18:.:1

I want the output as

chr1    67947   rs1202587463    A       AT      .       PASS    -       GT        0/0  0/0   0/0
chr1    69928   .       T       TAC     .       PASS    -       GT       0/0  0/0

I tried using sed -e 's/:.:.:.:.:.:.:.:.//g' ani.vcf but everything after GT gets eliminated

chr1    67947   rs1202587463    A       AT      .       PASS    -       GT
chr1    69928   .       T       TAC     .       PASS    -       GT
vcf grep • 1.5k views
ADD COMMENT
0
Entering edit mode

usually I don't grep VCF if avoidable by using bcftools bcftools query my.vcf -f '[\t%GT]\n

ADD REPLY
5
Entering edit mode
2.7 years ago
bcftools annotate -x '^FORMAT/GT' in.vcf
ADD COMMENT
0
Entering edit mode

Thank you so much. It works ! :)

ADD REPLY
0
Entering edit mode

A small educational note: if an answer was helpful, you should upvote it; if the answer resolved your question, you should mark it as accepted. You can accept more than one answer if they work. This will help future users that might find this post find the right answer.

upvote_bookmark_accept

ADD REPLY
2
Entering edit mode
2.7 years ago

Instead of regular expressions I would recommend you to use one of the many tools that allow you to filter VCF files and format the output to your needs

for example, to remove INFO tags use

bcftools annotate -x INFO/VDB,INFO/FS,INFO/SGB 
ADD COMMENT
1
Entering edit mode

oh Pierre Lindenbaum solution is even better,

I forgot the exact format to use it and tested it out, hence the later answer that was not even as good as the original

ADD REPLY

Login before adding your answer.

Traffic: 3707 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6