diff options
author | Alexander Kabui | 2021-05-13 08:25:42 +0300 |
---|---|---|
committer | BonfaceKilz | 2021-05-13 12:03:46 +0300 |
commit | 75b4e74dede48c59e07d8f15d2db4b5d6289c064 (patch) | |
tree | e1c1229ebdfc849d9c12b162c1949149b529a67e | |
parent | 413425b8ed3c69947b49ca366b210d69d2173805 (diff) | |
download | genenetwork2-75b4e74dede48c59e07d8f15d2db4b5d6289c064.tar.gz |
integrate comute corr for top results in ui
-rw-r--r-- | wqflask/wqflask/correlation/correlation_gn3_api.py | 68 | ||||
-rw-r--r-- | wqflask/wqflask/templates/test_correlation_page.html | 5 |
2 files changed, 54 insertions, 19 deletions
diff --git a/wqflask/wqflask/correlation/correlation_gn3_api.py b/wqflask/wqflask/correlation/correlation_gn3_api.py index e5638b5a..dec84728 100644 --- a/wqflask/wqflask/correlation/correlation_gn3_api.py +++ b/wqflask/wqflask/correlation/correlation_gn3_api.py @@ -137,16 +137,19 @@ def compute_correlation(start_vars, method="pearson"): (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) = fetch_sample_data( + (this_trait_data, target_dataset_data) = fetch_sample_data( start_vars, this_trait, this_dataset, target_dataset) correlation_results = compute_all_sample_correlation(corr_method=method, this_trait=this_trait_data, - target_dataset=target_dataset) + target_dataset=target_dataset_data) elif corr_type == "tissue": trait_symbol_dict = this_dataset.retrieve_genes("Symbol") @@ -175,31 +178,62 @@ def compute_correlation(start_vars, method="pearson"): conn=conn, trait_lists=list(geneid_dict.items()), species=species, gene_id=this_trait_geneid) - # correlation_results = correlation_results[0:corr_return_results] - # if corr_type != "tissue" and this_dataset.type == "ProbeSet" and target_dataset.type == "ProbeSet": - # pass - # # tissue_result = tissue_for_trait_lists( - # # correlation_results, this_dataset, this_trait) + correlation_results = correlation_results[0:corr_return_results] - # # correlation_results = merge_correlation_results( - # # correlation_results, tissue_result) + compute_all = True + + correlation_results = compute_corr_for_top_results(correlation_results, + this_trait, + this_dataset, + target_dataset, + corr_type) + + # if corr_type != "tissue" and this_dataset_type == "ProbeSet" and target_dataset_type == "ProbeSet": + + # tissue_result = tissue_for_trait_lists( + # correlation_results, this_dataset, this_trait) + + # if corr_type != "lit" and this_dataset_type == "ProbeSet" and target_dataset_type == "ProbeSet": + # lit_result = lit_for_trait_list( + # correlation_results, this_dataset, this_trait) - # if corr_type != "lit" and this_dataset.type == "ProbeSet" and target_dataset.type == "ProbeSet": - # pass - # # lit is very slow - # # lit_result = lit_for_trait_list(correlation_results, this_dataset, this_trait) - # # correlation_results = merge_correlation_results(correlation_results,lit_result) # if corr_type != "sample": - # # do sample correlation # pass - correlation_results = correlation_results[0:corr_return_results] + correlation_data = {"correlation_results": correlation_results, "this_trait": this_trait.name, - "target_dataset": start_vars['corr_dataset']} + "target_dataset": start_vars['corr_dataset'], + "return_results": corr_return_results} return correlation_data +def compute_corr_for_top_results(correlation_results, + this_trait, + this_dataset, + target_dataset, + corr_type): + if corr_type != "tissue" and this_dataset.type == "ProbeSet" and target_dataset.type == "ProbeSet": + + tissue_result = tissue_for_trait_lists( + correlation_results, this_dataset, this_trait) + + correlation_results = merge_correlation_results( + correlation_results, tissue_result) + + if corr_type != "lit" and this_dataset.type == "ProbeSet" and target_dataset.type == "ProbeSet": + lit_result = lit_for_trait_list( + correlation_results, this_dataset, this_trait) + + correlation_results = merge_correlation_results( + correlation_results, lit_result) + + if corr_type != "sample": + pass + + return correlation_results + + def do_lit_correlation(this_trait, this_dataset): """function for fetching lit inputs""" geneid_dict = this_dataset.retrieve_genes("GeneId") diff --git a/wqflask/wqflask/templates/test_correlation_page.html b/wqflask/wqflask/templates/test_correlation_page.html index 186de4b7..0809b65e 100644 --- a/wqflask/wqflask/templates/test_correlation_page.html +++ b/wqflask/wqflask/templates/test_correlation_page.html @@ -42,7 +42,7 @@ {% block content %} <div class="correlation-title"> - <h3>Correlation Results for <span>{{target_dataset}}</span> against <span><a href="">{{this_trait}}</a></span> for the top <span>all</span> Results</h3> + <h3>Correlation Results for <span>{{target_dataset}}</span> against <span><a href="">{{this_trait}}</a></span> for the top <span>{{return_results}}</span> Results</h3> </div> <div class="header-toggle-vis"> <h4 style="font-weight: bolder;padding: 5px 3px;">Toggle Columns</h4> @@ -137,7 +137,8 @@ console.log(correlationResults) { "targets":2, "render":(data,type,row)=>{ - let urlLink = "/show_trait?trait_id=1453207_at&dataset=HC_M2_0606_P" + // should use a dynamic dataset name + let urlLink = `/show_trait?trait_id=${data}&dataset=HC_M2_0606_P` let traitLink = `<a href=${urlLink}>${data}</a>` return traitLink }, |