This is a test version of Biostars. For the public version, visit https://www.biostars.org.
bcftools select sites with multiple combinations of FILTER column

Hello

I would like to keep the rows that have the combinations of these expressions

bcftools query -i "%FILTER='PASS' | %FILTER='haplotype' | %FILTER='germline' | %FILTER='clustered_events'" -f '%CHROM\t%POS\t%REF\t%ALT[\t%AF]\n' invcf > outvcf

ie. `germline;clustered_events` ------> should be kept
but `germline;some_other_filter_not_listed` -------> should be eliminated

Is there a way to do this with bcftools?

bcftools

1 answer

exclude/include:

 bcftools view -e 'FILTER ~ "FILTER1"'  -O u in.vcf |  bcftools view -i 'FILTER ~ "FILTER2"'     > out.vcf

sorry, this is not very clear...

use a first bcftools to exclude variants having filter FILTER1 and pipe into another bcftools to only include variants having FILTER2

so what should I put in filter1? some_other_filter_not_listed?

Log in to answer this question.