aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2022-02-08 08:04:39 +0300
committerBonfaceKilz2022-02-08 10:12:27 +0300
commit7cedea626c77167a2fb668044b93e40a97b67711 (patch)
tree5804c352553d98caa9fef510475303905b1b1579
parent35092e0bf2c411c6a9cb2e7b5809fca604eec9e0 (diff)
downloadgenenetwork3-7cedea626c77167a2fb668044b93e40a97b67711.tar.gz
Merge iterations to remove unnecessary computations
Do all the work in a single iteration to avoid unnecessary iterations that hamper performance.
-rw-r--r--gn3/computations/partial_correlations.py6
1 files changed, 2 insertions, 4 deletions
diff --git a/gn3/computations/partial_correlations.py b/gn3/computations/partial_correlations.py
index 9fcc54e..f1757f9 100644
--- a/gn3/computations/partial_correlations.py
+++ b/gn3/computations/partial_correlations.py
@@ -294,13 +294,11 @@ def compute_trait_info(primary_vals, control_vals, target, method):
def __remove_controls_for_target_nones(cont_targ):
return tuple(cont for cont, targ in cont_targ if targ is not None)
- conts_targs = tuple(tuple(
- zip(control, targ_vals)) for control in control_vals)
datafrm = build_data_frame(
primary,
[targ for targ in targ_vals if targ is not None],
- [__remove_controls_for_target_nones(cont_targ)
- for cont_targ in conts_targs])
+ [__remove_controls_for_target_nones(tuple(zip(control, targ_vals)))
+ for control in control_vals])
covariates = "z" if datafrm.shape[1] == 3 else [
col for col in datafrm.columns if col not in ("x", "y")]
ppc = pingouin.partial_corr(