From 3bae3c6fd810fcf5a0c311f4bb73e7ed6793e010 Mon Sep 17 00:00:00 2001 From: Christian Michelsen Date: Sun, 2 Oct 2022 21:42:22 +0200 Subject: [PATCH] fix: Fix divide by zero error in non CT/GA mismatc --- src/metaDMG/fit/fits.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/metaDMG/fit/fits.py b/src/metaDMG/fit/fits.py index 37d5e25..9405311 100644 --- a/src/metaDMG/fit/fits.py +++ b/src/metaDMG/fit/fits.py @@ -86,7 +86,10 @@ def add_non_CT_GA_mismatches(fit_result, group_in): bases = ["AC", "AG", "AT", "CA", "CG", "GC", "GT", "TA", "TC", "TG"] out = [] for base in bases: - out.append(group[base].values / group[base[0]].values) + num = group[base].values + den = group[base[0]].values + ratio = np.divide(num, den, out=np.zeros_like(num), where=den != 0) + out.append(ratio) # out = np.concatenate(out) fit_result["non_CT_GA_damage_frequency_mean"] = np.mean(out, axis=1).mean()