From aea641e0a6fbd0ea68241efffb7c280222491238 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 20 Dec 2021 07:58:39 +0300 Subject: 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. --- .../static/new/css/partial_correlations.css | 10 ++++ .../static/new/javascript/partial_correlations.js | 65 ++++++++++++++++++++-- 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) { -- cgit v1.2.3