diff options
author | Frederick Muriuki Muriithi | 2021-10-29 07:50:37 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2021-10-29 07:50:37 +0300 |
commit | 1b5e448ccecdfa146942bbb3d5b22bbbccd492c9 (patch) | |
tree | c83e33324f29d093804450b7a3e753711fc0e9c0 /gn3/computations | |
parent | eeb0d6d7ee1b65f1cbe9c32a9f9ee9237189a113 (diff) | |
download | genenetwork3-1b5e448ccecdfa146942bbb3d5b22bbbccd492c9.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.py | 15 |
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, |