diff options
author | Muriithi Frederick Muriuki | 2021-08-16 17:41:49 +0300 |
---|---|---|
committer | Muriithi Frederick Muriuki | 2021-08-16 17:41:49 +0300 |
commit | 89d4dbcc074765f07616fa5058ca7df1a5036d05 (patch) | |
tree | 2580896397b6a9bb203a7be3b9ee7c931605b5b7 /gn3/computations/correlations.py | |
parent | 36044483d365a907a9da6ad8a7b3f0dfb0a918e2 (diff) | |
parent | 70ed53f03f3d74877d5bc71e49e3a1e65af8b15f (diff) | |
download | genenetwork3-89d4dbcc074765f07616fa5058ca7df1a5036d05.tar.gz |
Merge branch 'main' into heatmap_generation
Diffstat (limited to 'gn3/computations/correlations.py')
-rw-r--r-- | gn3/computations/correlations.py | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/gn3/computations/correlations.py b/gn3/computations/correlations.py index 56f483c..1fd3213 100644 --- a/gn3/computations/correlations.py +++ b/gn3/computations/correlations.py @@ -124,11 +124,12 @@ def filter_shared_sample_keys(this_samplelist, return (this_vals, target_vals) -def compute_all_sample_correlation(this_trait, - target_dataset, - corr_method="pearson") -> List: +def speed_compute_all_sample_correlation(this_trait, + target_dataset, + corr_method="pearson") -> List: """Given a trait data sample-list and target__datasets compute all sample correlation + this functions uses multiprocessing if not use the normal fun """ # xtodo fix trait_name currently returning single one @@ -160,9 +161,9 @@ def compute_all_sample_correlation(this_trait, key=lambda trait_name: -abs(list(trait_name.values())[0]["corr_coefficient"])) -def benchmark_compute_all_sample(this_trait, - target_dataset, - corr_method="pearson") -> List: +def compute_all_sample_correlation(this_trait, + target_dataset, + corr_method="pearson") -> List: """Temp function to benchmark with compute_all_sample_r alternative to compute_all_sample_r where we use multiprocessing @@ -174,6 +175,7 @@ def benchmark_compute_all_sample(this_trait, 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( trait_name=trait_name, corr_method=corr_method, @@ -190,7 +192,9 @@ def benchmark_compute_all_sample(this_trait, "num_overlap": num_overlap } corr_results.append({trait_name: corr_result}) - return corr_results + return sorted( + corr_results, + key=lambda trait_name: -abs(list(trait_name.values())[0]["corr_coefficient"])) def tissue_correlation_for_trait( @@ -336,7 +340,7 @@ def compute_all_lit_correlation(conn, trait_lists: List, return sorted_lit_results -def compute_all_tissue_correlation(primary_tissue_dict: dict, +def compute_tissue_correlation(primary_tissue_dict: dict, target_tissues_data: dict, corr_method: str): """Function acts as an abstraction for tissue_correlation_for_trait\ @@ -382,9 +386,9 @@ def process_trait_symbol_dict(trait_symbol_dict, symbol_tissue_vals_dict) -> Lis return traits_tissue_vals -def compute_tissue_correlation(primary_tissue_dict: dict, - target_tissues_data: dict, - corr_method: str): +def speed_compute_tissue_correlation(primary_tissue_dict: dict, + target_tissues_data: dict, + corr_method: str): """Experimental function that uses multiprocessing for computing tissue correlation |