diff options
author | Frederick Muriuki Muriithi | 2022-01-03 13:15:29 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2022-01-10 08:27:09 +0300 |
commit | ff463fd79c76be344fe8d01e17202db010a5018d (patch) | |
tree | 58a246e6bc67e58af5e3fa5126efac347416a472 /gn3/computations | |
parent | d40fe8eabe0f7a21eaca1947a4b6bc0c1a1e1546 (diff) | |
download | genenetwork3-ff463fd79c76be344fe8d01e17202db010a5018d.tar.gz |
Remove all pairs with 'None' as the value
* Remove all key-value pairs whose value is None.
Diffstat (limited to 'gn3/computations')
-rw-r--r-- | gn3/computations/partial_correlations.py | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/gn3/computations/partial_correlations.py b/gn3/computations/partial_correlations.py index 13def5e..a298ff7 100644 --- a/gn3/computations/partial_correlations.py +++ b/gn3/computations/partial_correlations.py @@ -540,6 +540,8 @@ def trait_for_output(trait): pair just to indicate it does not exist. """ def __nan_to_none__(val): + if val is None: + return None if math.isnan(val) or numpy.isnan(val): return None return val @@ -581,14 +583,7 @@ def trait_for_output(trait): "tissue_corr": __nan_to_none__(trait.get("tissue_corr")), "tissue_p_value": __nan_to_none__(trait.get("tissue_p_value")) } - return { - key: val - for key, val in trait.items() - if ( - val is not None - or key in ( - "partial_corr_p_value", "corr", "corr_p_value", "rank_order", - "delta", "l_corr", "tissue_corr", "tissue_p_value"))} + return {key: val for key, val in trait.items() if val is not None} def partial_correlations_entry(# pylint: disable=[R0913, R0914, R0911] conn: Any, primary_trait_name: str, |