From 544aea3c5d19d68be476694ee1381ac8f8a77599 Mon Sep 17 00:00:00 2001 From: nmendozam Date: Thu, 12 Sep 2024 11:30:41 +0200 Subject: [PATCH] Fix zero division error --- PyHLA.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/PyHLA.py b/PyHLA.py index 0772626..a65f2db 100644 --- a/PyHLA.py +++ b/PyHLA.py @@ -1119,9 +1119,13 @@ def assocADRChiFisher(infile, digit, freq, test='chisq', model = 'allelic', adju if test == "chisq": chi2, p, dof, expected = scipy.stats.chi2_contingency(data) OR, pvalue = scipy.stats.fisher_exact(data) - se = math.sqrt(1.0/n1 + 1.0/n2 + 1.0/n3 + 1.0/n4) - l95 = math.exp(math.log(OR) - 1.96 * se) - u95 = math.exp(math.log(OR) + 1.96 * se) + try: + se = math.sqrt(1.0/n1 + 1.0/n2 + 1.0/n3 + 1.0/n4) + l95 = math.exp(math.log(OR) - 1.96 * se) + u95 = math.exp(math.log(OR) + 1.96 * se) + except ZeroDivisionError: + l95 = float('nan') + u95 = float('nan') ss = [] ss.append(n1) ss.append(n2)