aboutsummaryrefslogtreecommitdiff
path: root/gn3/computations
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2021-10-29 07:50:37 +0300
committerBonfaceKilz2021-11-04 12:45:57 +0300
commit8e3628129cdb8b1663dd2d63ce6c012335d73236 (patch)
treeb0d849a3d74b44c77cde4e52ac3da14752fd8150 /gn3/computations
parentebd8bbbccd282d67ada11a524eee21f14ff71b1c (diff)
downloadgenenetwork3-8e3628129cdb8b1663dd2d63ce6c012335d73236.tar.gz
Complete implementation of `batch_computed_tissue_correlation`
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * Complete the implementation of the `batch_computed_tissue_correlation` function
Diffstat (limited to 'gn3/computations')
-rw-r--r--gn3/computations/partial_correlations.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/gn3/computations/partial_correlations.py b/gn3/computations/partial_correlations.py
index 4ba2ba4..d095185 100644
--- a/gn3/computations/partial_correlations.py
+++ b/gn3/computations/partial_correlations.py
@@ -151,12 +151,17 @@ def tissue_correlation(
return method_fns[method](primary_trait_values, target_trait_values)
def batch_computed_tissue_correlation(
- trait_value: str, symbol_value_dict: dict,
- method: str = "pearson") -> Tuple[dict, dict]:
+ primary_trait_values: Tuple[float, ...], target_traits_dict: dict,
+ method: str) -> Tuple[dict, dict]:
+ """
+ This is a migration of the
+ `web.webqtl.correlation.correlationFunction.batchCalTissueCorr` function in
+ GeneNetwork1
"""
- `web.webqtl.correlation.correlationFunction.batchCalTissueCorr`"""
- raise Exception("Not implemented!")
- return ({}, {})
+ def __corr__(acc, target):
+ corr = tissue_correlation(primary_trait_values, target[1], method)
+ return ({**acc[0], target[0]: corr[0]}, {**acc[0], target[1]: corr[1]})
+ return reduce(__corr__, target_traits_dict.items(), ({}, {}))
def correlations_of_all_tissue_traits(
primary_trait_symbol_value_dict: dict, symbol_value_dict: dict,