about summary refs log tree commit diff
path: root/gn3/computations
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2021-11-04 08:51:50 +0300
committerBonfaceKilz2021-11-04 12:45:57 +0300
commit78c1d118ca31e2c0d4cd12afe8c8426974ee82e2 (patch)
tree112dfc81303a747f23ba7f4a17f7cfe61ee20a1e /gn3/computations
parent75d2286185addb3953f728d5fc30d2fd13ffbaf0 (diff)
downloadgenenetwork3-78c1d118ca31e2c0d4cd12afe8c8426974ee82e2.tar.gz
Create blackbox tests for some functions migrated from R
Issue:
https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi

* gn3/computations/partial_correlations.py: new stub
  functions (partial_correlation_matrix, partial_correlation_recursive)
*
  tests/unit/computations/partial_correlations_test_data/pcor_mat_blackbox_test.csv:
  blackbox sample data and results for variance-covariance matrix method
*
  tests/unit/computations/partial_correlations_test_data/pcor_rec_blackbox_test.csv:
  blackbox sample data and results for recursive method
* tests/unit/computations/test_partial_correlations.py: Tests for new function

  Provide some blackbox testing sample data for checking the operation of the
  functions migrated from R.
Diffstat (limited to 'gn3/computations')
-rw-r--r--gn3/computations/partial_correlations.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/gn3/computations/partial_correlations.py b/gn3/computations/partial_correlations.py
index fb372a9..07dc16d 100644
--- a/gn3/computations/partial_correlations.py
+++ b/gn3/computations/partial_correlations.py
@@ -257,3 +257,33 @@ def compute_partial_correlations_fast(# pylint: disable=[R0913, R0914]
             (fetched_correlations[corr[0]],) if correlation_type == "literature"
             else fetched_correlations[corr[0]][0:2])
         for idx, corr in enumerate(all_correlations))
+
+def partial_correlation_matrix(
+        xdata: Tuple[float, ...], ydata: Tuple[float, ...],
+        zdata: Tuple[float, ...], method: str = "pearsons",
+        omit_nones: bool = True) -> float:
+    """
+    Computes the partial correlation coefficient using the
+    'variance-covariance matrix' method
+
+    This is a partial migration of the
+    `web.webqtl.correlation.correlationFunction.determinPartialsByR` function in
+    GeneNetwork1, specifically the `pcor.mat` function written in the R
+    programming language.
+    """
+    return 0
+
+def partial_correlation_recursive(
+        xdata: Tuple[float, ...], ydata: Tuple[float, ...],
+        zdata: Tuple[float, ...], method: str = "pearsons",
+        omit_nones: bool = True) -> float:
+    """
+    Computes the partial correlation coefficient using the 'recursive formula'
+    method
+
+    This is a partial migration of the
+    `web.webqtl.correlation.correlationFunction.determinPartialsByR` function in
+    GeneNetwork1, specifically the `pcor.rec` function written in the R
+    programming language.
+    """
+    return 0