From 8e3628129cdb8b1663dd2d63ce6c012335d73236 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Fri, 29 Oct 2021 07:50:37 +0300 Subject: 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 --- gn3/computations/partial_correlations.py | 15 ++++++++++----- 1 file 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, -- cgit v1.2.3