error on extracting a snp from vcf file using bcftools
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!
• 2,445 views
•
link
1 answer
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
• 0 views
•
link
Log in to answer this question.
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:
Note that you can also extract the header with grep by using:
Note: if your VCF is indeed uncompressed, then this will also work:
Deleted.
That will select only the variant in chr1, but I think the question refers to all events.
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).
Any error? maybe try to use other position if you did not already, make sure you copy it from your vcf file.