Skip to content

vafator v3.0.0

Latest

Choose a tag to compare

@ozlemmuslu ozlemmuslu released this 10 Apr 13:15
d67f9b5

vafator 3.0.0

Performance

~13x runtime improvement over v2 on a 292K variant VCF (SEQC2 WES WES_EA_1, 5.5 hours → 23 minutes with 4 cores).

  • Streaming pileup iterator — replaced per-variant bam.pileup() calls with a single pileup iterator per chromosome per BAM. This eliminates the dominant source of overhead (repeated pysam pileup object construction and destruction) and reduces runtime ~4.4x on its own.

  • Power calculation caching — _calculate_k and calculate_expected_vaf results are now cached per depth value and per (sample, chrom, pos) respectively, avoiding redundant scipy.stats.binom calls across variants with identical coverage.

  • Rank sum test early exit — calculate_rank_sum_test now returns nan immediately when either distribution is empty, skipping unnecessary scipy.stats.ranksums calls.

  • Chromosome-level parallelization — added --num-processes flag to distribute chromosomes across worker processes using ProcessPoolExecutor. Each worker opens its own BAM readers independently, avoiding shared state issues.

Python upgrade

  • Python upgraded to 3.11

  • pysam pinned to ==0.21.0 — versions 0.22+ have a regression where query_qualities returns incorrect values.

Breaking changes

  • --include-ambiguous-bases renamed to --exclude-ambiguous-bases — ambiguous bases (N and all IUPAC codes) are now included in depth of coverage by default. To restore the old behaviour of excluding them, pass --exclude-ambiguous-bases. This flag is inverted from the previous version.

  • Zero-coverage variants — _bq, _mq, _pos annotations for variants with zero coverage previously reported nan; they now report 0.0. This affects a small number of variants (9/292,009 in the tested VCF).

Additional features

  • Random seed added to multiallelic filter

  • CRAM support added

Code quality

  • VafatorVariant replaced by VariantRecord — the test utility class VafatorVariant (from vafator.tests.utils) is now a thin factory function returning a VariantRecord.

  • Async VCF writing removed — the @background / asyncio / time.sleep(2) writing pattern was causing missing variants in the output. Replaced with synchronous batch writing.

  • Type hints and docstrings added throughout annotator.py, pileups.py, and pileup_utils.py.