aboutsummaryrefslogtreecommitdiff
path: root/tests/unit/computations
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2021-11-18 10:58:34 +0300
committerFrederick Muriuki Muriithi2021-11-18 10:58:34 +0300
commit21fbbfd599c841f082d88ddfc5f4cb362e1eb869 (patch)
tree11ba5b9b8758391c0df78745148f33d22c15bed0 /tests/unit/computations
parent29fc003070b45f61e7ab1048a818201b5beb9298 (diff)
downloadgenenetwork3-21fbbfd599c841f082d88ddfc5f4cb362e1eb869.tar.gz
Replace code migrated from R with pingouin functions
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * Replace the code that was in the process of being migrated from R in GeneNetwork1 with calls to pingouin functions that achieve the same thing. Since the functions in this case are computing correlations and partial correlations, rather than having home-rolled functions to do that, this commit makes use of the tried and tested pingouin functions. This avoids complicating our code with edge-case checks, and leverages the performance optimisations done in pingouin.
Diffstat (limited to 'tests/unit/computations')
-rw-r--r--tests/unit/computations/test_partial_correlations.py41
1 files changed, 1 insertions, 40 deletions
diff --git a/tests/unit/computations/test_partial_correlations.py b/tests/unit/computations/test_partial_correlations.py
index 39e6e8e..138155d 100644
--- a/tests/unit/computations/test_partial_correlations.py
+++ b/tests/unit/computations/test_partial_correlations.py
@@ -16,9 +16,7 @@ from gn3.computations.partial_correlations import (
dictify_by_samples,
tissue_correlation,
find_identical_traits,
- partial_correlation_matrix,
- good_dataset_samples_indexes,
- partial_correlation_recursive)
+ good_dataset_samples_indexes)
sampleslist = ["B6cC3-1", "BXD1", "BXD12", "BXD16", "BXD19", "BXD2"]
control_traits = (
@@ -397,40 +395,3 @@ class TestPartialCorrelations(TestCase):
with self.subTest(xdata=xdata, ydata=ydata, zdata=zdata):
self.assertTrue(
build_data_frame(xdata, ydata, zdata).equals(expected))
-
- def test_partial_correlation_matrix(self):
- """
- Test that `partial_correlation_matrix` computes the appropriate
- correlation value.
- """
- for sample in parse_test_data_csv(
- ("tests/unit/computations/partial_correlations_test_data/"
- "pcor_mat_blackbox_test.csv")):
- with self.subTest(
- xdata=sample["x"], ydata=sample["y"], zdata=sample["z"],
- method=sample["method"], omit_nones=sample["rm"]):
- self.assertEqual(
- partial_correlation_matrix(
- sample["x"], sample["y"], sample["z"],
- method=sample["method"], omit_nones=sample["rm"]),
- sample["result"])
-
- def test_partial_correlation_recursive(self):
- """
- Test that `partial_correlation_recursive` computes the appropriate
- correlation value.
- """
- for sample in parse_test_data(
- ("tests/unit/computations/partial_correlations_test_data/"
- "pcor_rec_blackbox_test.txt"),
- parse_for_rec):
- with self.subTest(
- xdata=sample["x"], ydata=sample["y"], zdata=sample["z"],
- method=sample["method"], omit_nones=sample["rm"]):
- self.assertEqual(
- round(
- partial_correlation_recursive(
- sample["x"], sample["y"], sample["z"],
- method=sample["method"], omit_nones=sample["rm"]),
- ROUND_TO),
- round(sample["result"], ROUND_TO))