error on extracting a snp from vcf file using bcftools
1
0
Entering edit mode
4 months ago
evafinegan • 0

Hello,

I am trying to extract a SNP based on POS column from a multisample vcf file.
I need the entire line with all the calls for all samples for the respective SNP.
I used:

bcftools view --include POS==41766 input.vcf -o SNP_41766

But the output file shows vcf header only.
Thank you for any help!

snp • 512 views
ADD COMMENT
0
Entering edit mode

Hi, it should work as you are running it. Are you sure that there is a record at this position? What if you simply grep the line:

bcftools view input.vcf | grep -P "\t41766\t"

Note that you can also extract the header with grep by using:

bcftools view input.vcf | grep -P "\t41766\t|^#"


Note: if your VCF is indeed uncompressed, then this will also work:

grep -P "\t41766\t" input.vcf
grep -P "\t41766\t|^#" input.vcf
ADD REPLY
0
Entering edit mode

Deleted.

ADD REPLY
0
Entering edit mode

That will select only the variant in chr1, but I think the question refers to all events.

ADD REPLY
0
Entering edit mode

Hello everyone! Thank you for your suggestions! I tried most of the suggestions but it is weird that I am still getting the header only (not the desired SNP row).

ADD REPLY
0
Entering edit mode

Any error? maybe try to use other position if you did not already, make sure you copy it from your vcf file.

ADD REPLY
0
Entering edit mode
4 months ago
Medhat 9.0k

To use bcftools, I would write it in this the way:
bcftools view --include 'POS=41766' input.vcf -o SNP_41766

This also will work, but I prefer the previous one:
bcftools view --include POS=41766 input.vcf -o SNP_41766

ADD COMMENT

Login before adding your answer.

Traffic: 2096 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