about summary refs log tree commit diff
path: root/gn3
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2021-10-26 09:17:52 +0300
committerBonfaceKilz2021-11-04 12:45:57 +0300
commitd6e392c2488421ae04b4ffd5de26be40ed86a9b3 (patch)
tree268cb6b58030ec773040b4906c407b6571edfab5 /gn3
parent42dee16ec8a7d7620367dd31481999bfca9313db (diff)
downloadgenenetwork3-d6e392c2488421ae04b4ffd5de26be40ed86a9b3.tar.gz
Complete `correlations_of_all_tissue_traits`
Issue:
https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi

* Complete the implementation of the `correlations_of_all_tissue_traits`
  function by providing a call to a non-implemented function.
Diffstat (limited to 'gn3')
-rw-r--r--gn3/db/correlations.py22
1 files changed, 18 insertions, 4 deletions
diff --git a/gn3/db/correlations.py b/gn3/db/correlations.py
index cae8080..f43b8a5 100644
--- a/gn3/db/correlations.py
+++ b/gn3/db/correlations.py
@@ -265,7 +265,6 @@ def fetch_tissue_probeset_xref_info(
         results or tuple(),
         (tuple(), {}, {}, {}, {}, {}, {}))
 
-def correlations_of_all_tissue_traits() -> Tuple[dict, dict]:
 def fetch_gene_symbol_tissue_value_dict_for_trait(
         gene_name_list: Tuple[str, ...], probeset_freeze_id: int,
         conn: Any) -> dict:
@@ -282,12 +281,25 @@ def fetch_gene_symbol_tissue_value_dict_for_trait(
         return fetch_gene_symbol_tissue_value_dict(xref_info[0], xref_info[2], conn)
     return {}
 
+def correlations_of_all_tissue_traits(
+        trait_symbol: str, probeset_freeze_id: int,
+        method: str, conn: Any) -> Tuple[dict, dict]:
+    """
+    Computes and returns the correlation of all tissue traits.
+
     This is a migration of the
-    `web.webqtl.correlation.CorrelationPage.calculateCorrOfAllTissueTrait`
+    `web.webqtl.correlation.correlationFunction.calculateCorrOfAllTissueTrait`
     function in GeneNetwork1.
     """
-    raise Exception("Unimplemented!!!")
-    return ({}, {})
+    primary_trait_symbol_value_dict = fetch_gene_symbol_tissue_value_dict_for_trait(
+        (trait_symbol,), probeset_freeze_id, conn)
+    primary_trait_value = primary_trait_symbol_value_dict.vlaues()[0]
+    symbol_value_dict = fetch_gene_symbol_tissue_value_dict_for_trait(
+        tuple(), probeset_freeze_id, conn)
+    if method == "1":
+        return batch_computed_tissue_correlation(
+            primaryTraitValue,SymbolValueDict,method='spearman')
+    return batch_computed_tissue_correlation(primaryTraitValue,SymbolValueDict)
 
 def build_temporary_tissue_correlations_table(
         trait_symbol: str, probeset_freeze_id: int, method: str,
@@ -298,6 +310,8 @@ def build_temporary_tissue_correlations_table(
     This is a migration of the
     `web.webqtl.correlation.CorrelationPage.getTempTissueCorrTable` function in
     GeneNetwork1."""
+    symbol_corr_dict, symbol_p_value_dict = correlations_of_all_tissue_traits(
+        trait_symbol, probeset_freeze_id, method, conn)
     raise Exception("Unimplemented!!!")
     return ""