samtools / bcftools

This is the official development repository for BCFtools. See installation instructions and other documentation here http://samtools.github.io/bcftools/howtos/install.html
http://samtools.github.io/bcftools/
Other
633 stars 241 forks source link

Bcftools view -i sMIN(FORMAT/DP)>=3 error #2214

Closed Evansd36 closed 1 week ago

Evansd36 commented 1 week ago

I am trying to filter a vcf (made with GATK genotypeGVCFs) so samples with a depth below 3 for a given site are filtered out. I do not want to filter out the entire site, just the samples that don't make the cut. I see that expressions of 'MIN(FMT/DP)>=3' act on a site by site basis and there is the option to use SMPL_MIN or sMIN to act on a sample by sample basis. However, when I run the following command

bcftools view -i 'sMIN(FORMAT/DP)>=3' 120_lines_IM767ref_chr11_genic_snps_renamed.vcf.gz --output-type z -o 120_lines_IM767ref_chr11_genic_snps_renamed_depthfiltered_infoDP.vcf.gz

I get the following error

[filter.c:2491 filters_init1] Error: the tag "sMIN" is not defined in the VCF header

My assumption is that I need to modify my header to include this tag but I am not confident how best to do this. I know I can use the reheader commands to edit and insert a new header but how should I actually define this tag? Is there some specific way I need to define it so bcftools can operate on a sample by sample basis instead of a site by site basis?

The last thing is that unfortunately I only have access to bcftools 1.10 right now. Would finding a way to get a newer version fix my problem? Thanks for the help!

pd3 commented 1 week ago

The sMIN() expression is a bcftools function, not a VCF tag, so the only solution is to upgrade the program - 1.10 is really old, we are at 1.20 now!

It can be compiled from source as described here https://samtools.github.io/bcftools/howtos/install.html. Alternatively, there is an unofficial docker image with the latest version I built available here https://hub.docker.com/r/pdanecek/tools/tags.

Evansd36 commented 1 week ago

The docker image is what I needed, updated run doesn't throw the error. Thanks!