From 3c0f842e72a3fc72ff8a51f9c54643db20dcd292 Mon Sep 17 00:00:00 2001 From: Michael Lazear Date: Mon, 25 Sep 2023 16:55:23 -0700 Subject: [PATCH] fix: handle non-normal floats in expected ratio --- proteobench/modules/dda_quant/datapoint.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/proteobench/modules/dda_quant/datapoint.py b/proteobench/modules/dda_quant/datapoint.py index 9da869bf..850c658f 100644 --- a/proteobench/modules/dda_quant/datapoint.py +++ b/proteobench/modules/dda_quant/datapoint.py @@ -1,4 +1,5 @@ import json +import numpy as np from dataclasses import asdict, dataclass from datetime import datetime @@ -44,7 +45,7 @@ def calculate_plot_data(self, df): nr_missing_0 = 0 for spec in species: f = len(df[df[spec] == True]) - sum_s = (df[df[spec] == True]["1|2_expected_ratio_diff"]).sum() + sum_s = np.nan_to_num(df[df[spec] == True]["1|2_expected_ratio_diff"], nan=0, neginf=-1000, posinf=1000).sum() ratio = sum_s / f prop_ratio = (f / len(df)) * ratio prop_ratios.append(prop_ratio)