Commit a763c9a0 authored by Blaise Li's avatar Blaise Li
Browse files

Catch stats numeric error.

parent b13207c0
......@@ -456,7 +456,17 @@ def size_factor_correlations(counts_data, summaries, normalizer):
# by_norm = counts_data / size_factors
def compute_pearsonr_with_size_factor(row):
return pearsonr(row, size_factors)[0]
return pearsonr(row, size_factors)[0]
except ValueError as err:
if str(err) == "array must not contain infs or NaNs":
msg = (
f"Cannot compute Pearson correlation with size factors "
f"when normalizing using {normaliser}")
return np.nan
# return by_norm.apply(compute_pearsonr_with_size_factor, axis=1)
return (counts_data / size_factors).apply(compute_pearsonr_with_size_factor, axis=1)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment