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
committerFrederick Muriuki Muriithi2021-11-04 08:51:50 +0300
commit32e6d788ac5b6fa8daf4c26b2ad7bca32d71d828 (patch)
tree74428074fe871a99d1bf9d4ed8584ea5d84bff9a /gn3/computations
parenta191f67f8702729e80d1de2f66e28555e6e649dc (diff)
downloadgenenetwork3-32e6d788ac5b6fa8daf4c26b2ad7bca32d71d828.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