Skip to content

Commit

Permalink
Merge pull request #41 from TRON-Bioinformatics/fix-cn-less-one
Browse files Browse the repository at this point in the history
Fix CN less one
  • Loading branch information
priesgo authored Oct 7, 2022
2 parents 36eb7b2 + 9b5ccc7 commit 6163281
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install setuptools wheel
pip install virtualenv tox==3.23.0 tox-wheel==0.6.0 tox-gh-actions
pip install virtualenv tox==3.26.0 tox-wheel==1.0.0 tox-gh-actions
- name: Build, install and run unit tests
run: |
tox
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3 :: Only',
"License :: OSI Approved :: MIT License",
"Operating System :: Unix"
Expand Down
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
[tox]
envlist = {py37, py38, py39}
envlist = {py37, py38, py39, py310}

[gh-actions]
python =
3.7: py37
3.8: py38
3.9: py39
3.10: py310

[testenv]
wheel = true
Expand Down
2 changes: 1 addition & 1 deletion vafator/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION='2.0.3'
VERSION='2.1.0'
2 changes: 1 addition & 1 deletion vafator/power.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def calculate_expected_vaf(self, sample: str, variant: Optional[Variant]) -> flo
In a scenario with purity = 1, tumor CN = 2 and normal CN = 2 => expected VAF = 0.5
"""
purity = self.purities.get(sample, DEFAULT_PURITY)
tumor_ploidy = self.tumor_ploidies.get(sample, default_ploidy_manager).get_ploidy(variant=variant)
tumor_ploidy = max(1, self.tumor_ploidies.get(sample, default_ploidy_manager).get_ploidy(variant=variant))
corrected_tumor_ploidy = purity * tumor_ploidy + ((1 - purity) * self.normal_ploidy)
expected_vaf = purity / corrected_tumor_ploidy
return expected_vaf
Expand Down
2 changes: 1 addition & 1 deletion vafator/tests/test_annotator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from unittest import TestCase
from cyvcf2 import VCF

from ploidies import PloidyManager
from vafator.ploidies import PloidyManager
from vafator.annotator import Annotator
import vafator.tests.utils as test_utils
import time
Expand Down
2 changes: 1 addition & 1 deletion vafator/tests/test_pileups.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pkg_resources
import pysam

from tests.utils import VafatorVariant
from vafator.tests.utils import VafatorVariant
from vafator.pileups import get_variant_pileup, get_metrics


Expand Down
2 changes: 1 addition & 1 deletion vafator/tests/test_ploidy_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pkg_resources

from tests.utils import VafatorVariant
from vafator.tests.utils import VafatorVariant
from vafator.ploidies import PloidyManager, default_ploidy_manager


Expand Down
13 changes: 8 additions & 5 deletions vafator/tests/test_power_calculator.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
from unittest import TestCase

import numpy as np
import pkg_resources

from ploidies import PloidyManager
from power import PowerCalculator
from tests.utils import VafatorVariant
from vafator.ploidies import PloidyManager
from vafator.power import PowerCalculator
from vafator.tests.utils import VafatorVariant


class PowerCalculatorTest(TestCase):
Expand All @@ -26,6 +24,11 @@ def test_power_calculator(self):
self.assertAlmostEqual(power.calculate_power(dp=10, ac=10, sample='tumor', variant=None), 1.0)
self.assertAlmostEqual(power.calculate_power(dp=10, ac=11, sample='tumor', variant=None), 1.0)

def test_eaf_copy_number_below_one(self):
power = PowerCalculator(
tumor_ploidies={'tumor': PloidyManager(genome_wide_ploidy=0.5)}, purities={'tumor': 0.9})
self.assertLessEqual(power.calculate_expected_vaf(sample='tumor', variant=None), 1.0)

def test_varying_purity(self):
power1 = PowerCalculator(
tumor_ploidies={'tumor': PloidyManager(genome_wide_ploidy=2.5)}, purities={'tumor': 0.8})
Expand Down
1 change: 0 additions & 1 deletion vafator/tests/test_rank_sum_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from unittest import TestCase

from vafator.rank_sum_test import calculate_rank_sum_test


Expand Down

0 comments on commit 6163281

Please sign in to comment.