Skip to content

Commit

Permalink
make CLR robust against observations with O11=O21=0
Browse files Browse the repository at this point in the history
  • Loading branch information
ausgerechnet committed Aug 30, 2022
1 parent ffdd443 commit 2e3ce92
Show file tree
Hide file tree
Showing 4 changed files with 2,153 additions and 0 deletions.
3 changes: 3 additions & 0 deletions association_measures/measures.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,9 @@ def get_poisson_ci_boundary(alpha, O11, R1, O21, R2):
:param int R2:
"""

if O11 == O21 == 0:
return 0

if (O11 / R1) >= (O21 / R2):
lower = beta.ppf(alpha, O11, O21 + 1)
boundary = max(np.log2((R2 / R1) * lower / (1 - lower)), 0)
Expand Down
10 changes: 10 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ def zero_dataframe():
return df


@pytest.fixture(scope='function')
def zero_dataframe_sig():
""" Sample DataFrame with lots of zeros in freq. signature notation """

df = pd.read_csv("tests/data/df-zeros-sig.tsv", index_col=0,
sep="\t", quoting=3, keep_default_na=False)

return df


@pytest.fixture(scope='function')
def ucs_dataframe():
""" Sample DataFrame with real data and calculations from UCS.
Expand Down
Loading

0 comments on commit 2e3ce92

Please sign in to comment.