bcftools icon indicating copy to clipboard operation
bcftools copied to clipboard

bcftools view to subset VCF by region file in BED format gives only header without warning or error

Open yifangt opened this issue 7 months ago • 1 comments

I am trying to subtract some SNPs with a region file in BED format. My command line is:

bcftools view -R true_snps_list.bed Allsamples_joint.vcf.gz -Oz -o Allsamples_joint_truth.vcf.gz

The vcf.gz is correct tested with other bcftools options like query/view, and the chromosomes names are checked to be consistent between the two files, and nothing seems wrong. The region file is in BED format with minimum 3 columns(confirmed Tab-delimited):

chr1 243262 243263
chr1 246355 246356
chr1 246510 246511
chr1 247668 247669
chr1 247669 247670
......

Related to this post, but my command line does not give any result except the header. BTW my bcftools version is 1.21.

What did I miss for my purpose with the command line? Thanks!

Struggled for a while, it turned out the option for targeted regions should be with the option --targets-file

bcftools view --targets-file true_snps_list.bed Allsamples_joint.vcf.gz -Oz -o Allsamples_joint_truth.vcf.gz

Left here and hope this may be useful.

yifangt avatar Jun 19 '25 17:06 yifangt

We need a small test case to reproduce the problem. The command itself looks ok

pd3 avatar Jun 22 '25 07:06 pd3