Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Allelic Imbalance Filtering Logic for bcftools v1.16+ #141

Merged
merged 1 commit into from
Oct 22, 2024

Conversation

HolEv
Copy link
Collaborator

@HolEv HolEv commented Oct 21, 2024

Fixing issue #134

What

This update addresses an issue with the bcftools allelic imbalance filtering command introduced in versions later than v1.16. Specifically, we want to exclude (write) variants only where all heterozygous calls have an allele balance (AB) < 0.15, but keep the variant if any heterozygous call has an AB > 0.15.

The previous bcftools allelic imbalance filtering command

bcftools query --format '%CHROM\t%POS\t%REF\t%ALT\n' --exclude 'COUNT(GT="het")=0 || 
(GT="het" & ((TYPE="snp" & (FORMAT/AD[*:1] / FORMAT/AD[*:0]) > 0.15) | (TYPE="indel" & (FORMAT/AD[*:1] / FORMAT/AD[*:0]) > 0.20)))' {{input}}

only had the intended behavior until bcftools v1.16. With newer versions, bcftools filtering logic seem sot have changed from an any to all evaluation.
This results in all heterozygous variants being written to the variants to exclude file for versions > v1.16, even if a call meets the AB criterion.

The fixed bcftools command (suggested by @rdey-inistro)

bcftools query --format '%CHROM\t%POS\t%REF\t%ALT\n' --exclude 'COUNT(GT="het")=0 || COUNT(GT="het" & ((TYPE="snp" & (FORMAT/AD[*:1] / FORMAT/AD[*:0]) > 0.15) | (TYPE="indel" & (FORMAT/AD[*:1] / FORMAT/AD[*:0]) > 0.20)))>0' {{input}} 

has the intended version for either bcftools version (<=v1.16 & >v1.16).

Testing

The expected behavior of the new command was verified on the example vcf file using bcftools versions 1.12, 1.16, 1.18, 1.20.

@HolEv HolEv requested a review from bfclarke October 21, 2024 08:40
@bfclarke bfclarke merged commit 243b47a into main Oct 22, 2024
31 checks passed
@bfclarke bfclarke deleted the bug/bcftools_qc_allelic_imbalance branch October 22, 2024 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants