aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2021-12-20 07:58:39 +0300
committerFrederick Muriuki Muriithi2022-01-28 08:07:27 +0300
commit10981a8a70e9765d5600beb9eb784acd56b518aa (patch)
tree772916e8120cb99dce50df591930fe52d4414e6e /wqflask
parent9376bbb73cc4161ac33e7066dd8fd27367088106 (diff)
downloadgenenetwork2-10981a8a70e9765d5600beb9eb784acd56b518aa.tar.gz
Display data for "Publish" datasets
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * Display the correlations results for "Publish" datasets.
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/wqflask/static/new/css/partial_correlations.css10
-rw-r--r--wqflask/wqflask/static/new/javascript/partial_correlations.js65
2 files changed, 71 insertions, 4 deletions
diff --git a/wqflask/wqflask/static/new/css/partial_correlations.css b/wqflask/wqflask/static/new/css/partial_correlations.css
index ebc00302..41dd04df 100644
--- a/wqflask/wqflask/static/new/css/partial_correlations.css
+++ b/wqflask/wqflask/static/new/css/partial_correlations.css
@@ -7,6 +7,7 @@
#main-form {
grid-column-start: 1;
grid-column-end: 2;
+ text-align: left;
}
#form-display-area {
@@ -28,3 +29,12 @@
width: 20%;
grid-column-start: 2;
}
+
+td, th {
+ border: 1px solid;
+ text-align: left;
+}
+
+tr:nth-of-type(2n) {
+ background: #DDDDDD;
+}
diff --git a/wqflask/wqflask/static/new/javascript/partial_correlations.js b/wqflask/wqflask/static/new/javascript/partial_correlations.js
index b1b12ee7..e61dc250 100644
--- a/wqflask/wqflask/static/new/javascript/partial_correlations.js
+++ b/wqflask/wqflask/static/new/javascript/partial_correlations.js
@@ -59,14 +59,71 @@ function partial_corr_request_data() {
}
}
+function rho_or_r(method) {
+ if (method === "spearman") {
+ return "rho";
+ }
+ return "r";
+}
+
+function display_publish_results(primary, controls, correlations, method) {
+ table = document.getElementById("part-corr-results-publish");
+ table.setAttribute("style", "display: block;");
+ table_body = document.querySelector("#part-corr-results-publish tbody");
+ template_row = document.querySelector(
+ "#part-corr-results-publish tr.template-publish-results-row");
+ correlations.forEach(function(item, index, arr) {
+ new_row = template_row.cloneNode(true);
+ new_row.setAttribute("class", "results-row");
+ new_row.querySelector(
+ 'td[data-column-heading="Record"]').innerHTML = item["trait_name"];
+ new_row.querySelector(
+ 'td[data-column-heading="Phenotype"]').innerHTML = (
+ item["post_publication_description"]);
+ new_row.querySelector(
+ 'td[data-column-heading="Authors"]').innerHTML = item["authors"];
+ new_row.querySelector(
+ 'td[data-column-heading="Year"]').innerHTML = item["year"];
+ new_row.querySelector(
+ 'td[data-column-heading="N"]').innerHTML = item["noverlap"];
+ new_row.querySelector(
+ `td[data-column-heading="Partial ${rho_or_r(method)}"]`
+ ).innerHTML = item["partial_corr"];
+ new_row.querySelector(
+ `td[data-column-heading="p(partial ${rho_or_r(method)})"]`
+ ).innerHTML = item["partial_corr_p_value"];
+ new_row.querySelector(
+ `td[data-column-heading="${rho_or_r(method)}"]`
+ ).innerHTML = item["corr"];
+ new_row.querySelector(
+ `td[data-column-heading="p(${rho_or_r(method)})"]`
+ ).innerHTML = item["corr_p_value"];
+ new_row.querySelector(
+ `td[data-column-heading="delta ${rho_or_r(method)}"]`
+ ).innerHTML = format_number(item["delta"]);
+ table_body.appendChild(new_row);
+ });
+ table_body.removeChild(template_row);
+}
+
+function display_geno_results(primary, controls, correlations) {}
+function display_probeset_results(primary, controls, correlations) {}
+
function display_partial_corr_results(data, status, xhr) {
progress_indicator = document.getElementById(
"partial-correlations-progress-indicator").style.display = "none";
- parent = document.getElementById("part-corr-success");
- child = document.createElement("p");
- child.textContent = data;
- parent.appendChild(child);
console.log(data);
+ display_functions = {
+ "Publish": display_publish_results,
+ "Geno": display_geno_results,
+ "ProbeSet": display_probeset_results
+ }
+
+ display_functions[data["results"]["dataset_type"]](
+ data["results"]["primary_traits"],
+ data["results"]["control_traits"],
+ data["results"]["correlations"],
+ data["results"]["method"]);
}
function display_partial_corr_error(xhr, status, error) {