filtering by POS in bcftools
2
2
Entering edit mode
5.8 years ago
4galaxy77 2.9k

Hi,

I have a vcf file which I would like to filter by a list of SNP positions, which are present in a positions.txt file.

 bcftools filter -i 'POS=@positions.txt' input.vcf.bgz > output.vcf

However, this says:

Error: could not parse the expression. Note that the "@file_name" syntax can be currently used with ID column only.

Is there another simple way filter by POS in bcftools?

Thanks.

software error bcftools • 11k views
ADD COMMENT
1
Entering edit mode

https://samtools.github.io/bcftools/bcftools.html

file names (this is currently supported only to filter by the ID column)

.

Is there another simple way filter by POS in bcftools?

do you just want option --regions-file or --targets-file ?

ADD REPLY
0
Entering edit mode

sorry im not sure the difference. I tried reading the manual, but I didn't follow..

I have a txt file of positions:

1324324
4325435
etc

and within the vcf file, SNPs with those positions. I would like to create a new vcf file, which is a subset of the first, only containing those SNPs and their corresponding information.

Thanks.

ADD REPLY
1
Entering edit mode

position alone is insufficient to locate a feature, you would need the chromosomal coordinate as well. You can use what Pierre Lindenbaum said or you may also use bedtools intersect to isolate regions, sometimes there can be differences on how tools operate when the variation is an interval. With bedtools the documentation is more explicit.

ADD REPLY
1
Entering edit mode
5.8 years ago
4galaxy77 2.9k

Yeah, I figured.

Actually found the answer here, so you can close the thread

Best way to query VCF for specific variants

thanks.

ADD COMMENT
1
Entering edit mode
22 months ago

Actually the best way is

bcftools view -R regions.tsv my.vcf

Where regions.tsv looks like

chr1    123
chr1    567
ADD COMMENT

Login before adding your answer.

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