diff options
author | Frederick Muriuki Muriithi | 2022-08-09 12:44:46 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2022-08-12 13:13:26 +0300 |
commit | 37de1dd318e10e396c99cf8cda46db115afb2712 (patch) | |
tree | 79a21d2cd6560d81aff2ec590990ab35c025055a /wqflask | |
parent | 55c237db53037ee1f13ce782e224013aa12c51b9 (diff) | |
download | genenetwork2-37de1dd318e10e396c99cf8cda46db115afb2712.tar.gz |
Integrate rust correlations. Deduplicate similar code.
- Use rust correlations rather than the slower python one
- Remove code duplicated in the
`wqflask/wqflask/correlation/rust_correlation.py` module within the
`compute_correlation_rust` function.
Diffstat (limited to 'wqflask')
-rw-r--r-- | wqflask/wqflask/correlation/correlation_gn3_api.py | 52 |
1 files changed, 11 insertions, 41 deletions
diff --git a/wqflask/wqflask/correlation/correlation_gn3_api.py b/wqflask/wqflask/correlation/correlation_gn3_api.py index 05210d9b..f13dd27c 100644 --- a/wqflask/wqflask/correlation/correlation_gn3_api.py +++ b/wqflask/wqflask/correlation/correlation_gn3_api.py @@ -198,51 +198,21 @@ def compute_correlation(start_vars, method="pearson", compute_all=False): corr_type = start_vars['corr_type'] - (this_dataset, this_trait, target_dataset, - sample_data) = create_target_this_trait(start_vars) - - target_dataset_type = target_dataset.type - this_dataset_type = this_dataset.type - method = start_vars['corr_sample_method'] corr_return_results = int(start_vars.get("corr_return_results", 100)) corr_input_data = {} - if corr_type == "sample": - (this_trait_data, target_dataset_data) = fetch_sample_data( - start_vars, this_trait, this_dataset, target_dataset) - ## This import has to be inside the function to prevent circular imports - from wqflask.correlation.rust_correlation import compute_correlation_rust - rust_correlation_results = compute_correlation_rust( - start_vars, corr_type, method, corr_return_results) - correlation_results = rust_correlation_results["correlation_results"] - - elif corr_type == "tissue": - trait_symbol_dict = this_dataset.retrieve_genes("Symbol") - tissue_input = get_tissue_correlation_input( - this_trait, trait_symbol_dict) - - if tissue_input is not None: - (primary_tissue_data, target_tissue_data) = tissue_input - - corr_input_data = { - "primary_tissue": primary_tissue_data, - "target_tissues_dict": target_tissue_data - } - correlation_results = compute_tissue_correlation( - primary_tissue_dict=corr_input_data["primary_tissue"], - target_tissues_data=corr_input_data[ - "target_tissues_dict"], - corr_method=method - - ) - else: - return {"correlation_results": [], - "this_trait": this_trait.name, - "target_dataset": start_vars['corr_dataset'], - "return_results": corr_return_results} - - elif corr_type == "lit": + from wqflask.correlation.rust_correlation import compute_correlation_rust + rust_correlation_results = + return compute_correlation_rust( + start_vars, corr_type, method, corr_return_results) + correlation_results = rust_correlation_results["correlation_results"] + + if corr_type == "lit":# elif corr_type == "lit": + (this_dataset, this_trait, target_dataset, + sample_data) = create_target_this_trait(start_vars) + target_dataset_type = target_dataset.type + this_dataset_type = this_dataset.type (this_trait_geneid, geneid_dict, species) = do_lit_correlation( this_trait, this_dataset) |