aboutsummaryrefslogtreecommitdiff
path: root/gn3/computations
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2021-12-14 04:37:15 +0300
committerFrederick Muriuki Muriithi2021-12-14 04:37:15 +0300
commit1a46021a37ca23fe9893fd4ac9ac9c1d4066884b (patch)
tree3162218579654d749bdb3a8ace12122d0996eaa5 /gn3/computations
parentf81950baa398212861200dbc088b80dbdcc4fead (diff)
downloadgenenetwork3-1a46021a37ca23fe9893fd4ac9ac9c1d4066884b.tar.gz
Remove any items with less than 3 samples
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * pingouin raises an exception whenever one attempts to use it to compute the partial correlation with data that has less than 3 samples.
Diffstat (limited to 'gn3/computations')
-rw-r--r--gn3/computations/partial_correlations.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/gn3/computations/partial_correlations.py b/gn3/computations/partial_correlations.py
index 87d0201..fbff4df 100644
--- a/gn3/computations/partial_correlations.py
+++ b/gn3/computations/partial_correlations.py
@@ -306,6 +306,9 @@ def compute_partial(
prim for targ, prim in zip(targ_vals, primary_vals)
if targ is not None]
+ if len(primary) < 3:
+ return None
+
def __remove_controls_for_target_nones(cont_targ):
return tuple(cont for cont,targ in cont_targ if targ is not None)
@@ -338,8 +341,10 @@ def compute_partial(
zero_order_corr["r"][0], zero_order_corr["p-val"][0])
return tuple(
- __compute_trait_info__(target)
+ result for result in (
+ __compute_trait_info__(target)
for target in zip(target_vals, target_names))
+ if result is not None)
def partial_correlations_normal(# pylint: disable=R0913
primary_vals, control_vals, input_trait_gene_id, trait_database,