Skip to content

Commit

Permalink
added log computation to odds ratio confidence intervals (#311)
Browse files Browse the repository at this point in the history
  • Loading branch information
hyi authored Apr 10, 2024
1 parent f4a7c03 commit 8e246a7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions icees_api/features/sql.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""SQL access functions."""
from collections import defaultdict
from collections import defaultdict, namedtuple
from functools import wraps
from hashlib import md5
from itertools import product, chain
Expand Down Expand Up @@ -28,6 +28,7 @@
logger = logging.getLogger(__name__)

eps = np.finfo(float).eps
ConfidenceInterval = namedtuple('ConfidenceInterval', ['low', 'high'])


def get_digest(*args):
Expand Down Expand Up @@ -647,7 +648,11 @@ def select_feature_matrix(
fisher_exact_odds_ratio, fisher_exact_p = fisher_exact(feature_matrix, alternative='two-sided')
or_result = contingency.odds_ratio(feature_matrix, kind='sample')
log_odds_ratio = np.log(or_result.statistic)
log_odds_ratio_conf_interval_95 = or_result.confidence_interval(confidence_level=0.95)
odds_ratio_conf_interval_95 = or_result.confidence_interval(confidence_level=0.95)
# Calculate the log of the lower and upper bounds of the confidence interval
log_lb = np.log(odds_ratio_conf_interval_95[0])
log_ub = np.log(odds_ratio_conf_interval_95[1])
log_odds_ratio_conf_interval_95 = ConfidenceInterval(low=log_lb, high=log_ub)
else:
fisher_exact_odds_ratio = fisher_exact_p = log_odds_ratio = log_odds_ratio_conf_interval_95 = None

Expand Down

0 comments on commit 8e246a7

Please sign in to comment.