diff options
author | Alexander Kabui | 2021-04-16 02:37:25 +0300 |
---|---|---|
committer | Alexander Kabui | 2021-04-16 02:37:25 +0300 |
commit | 6c14eccb7a10cc598d4fa7ee4036cb44bddd9627 (patch) | |
tree | ea60c5a67453edfbf50e049d8874036fff037043 /gn3/computations | |
parent | f3f68f8eb92c7ec9c42bc20bc8e94c435cc745e2 (diff) | |
download | genenetwork3-6c14eccb7a10cc598d4fa7ee4036cb44bddd9627.tar.gz |
benchmark normal function for sample r
Diffstat (limited to 'gn3/computations')
-rw-r--r-- | gn3/computations/correlations.py | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/gn3/computations/correlations.py b/gn3/computations/correlations.py index fb62b56..90b6c8c 100644 --- a/gn3/computations/correlations.py +++ b/gn3/computations/correlations.py @@ -128,7 +128,7 @@ def compute_all_sample_correlation(this_trait, corr_results = [] processed_values = [] for target_trait in target_dataset: - # trait_id = target_trait.get("trait_id") + # trait_name = target_trait.get("trait_id") target_trait_data = target_trait["trait_sample_data"] # this_vals, target_vals = filter_shared_sample_keys( # this_trait_samples, target_trait_data) @@ -152,6 +152,43 @@ def compute_all_sample_correlation(this_trait, return corr_results + def benchmark_compute_all_sample(this_trait, + target_datasets, + corr_method="pearson") ->List: + """Temp function to benchmark with compute_all_sample_r + """ + + this_trait_samples = this_trait["trait_sample_data"] + + corr_results = [] + + for target_trait in target_dataset: + trait_id = target_trait.get("trait_id") + target_trait_data = target_trait["trait_sample_data"] + this_vals, target_vals = filter_shared_sample_keys( + this_trait_samples, target_trait_data) + + sample_correlation = compute_sample_r_correlation( + corr_method=corr_method, + trait_vals=this_vals, + target_samples_vals=target_vals) + + if sample_correlation is not None: + (corr_coeffient, p_value, num_overlap) = sample_correlation + + else: + continue + + corr_result = { + "corr_coeffient": corr_coeffient, + "p_value": p_value, + "num_overlap": num_overlap + } + + corr_results.append({trait_id: corr_result}) + + return corr_results + def tissue_lit_corr_for_probe_type(corr_type: str, top_corr_results): """Function that does either lit_corr_for_trait_list or tissue_corr _for_trait |