diff options
author | Frederick Muriuki Muriithi | 2021-12-20 11:49:22 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2022-01-28 08:07:27 +0300 |
commit | fdd7a9c2eb8233aef9bb0fc99dcf4341e31ba116 (patch) | |
tree | df284c22a02a976eb562a16abb335f94233f624a | |
parent | 10981a8a70e9765d5600beb9eb784acd56b518aa (diff) | |
download | genenetwork2-fdd7a9c2eb8233aef9bb0fc99dcf4341e31ba116.tar.gz |
Format numbers for display
Issue:
https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi
* Format the numbers for display, to reduce the number of columns
needed for display.
-rw-r--r-- | wqflask/wqflask/static/new/javascript/partial_correlations.js | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/wqflask/wqflask/static/new/javascript/partial_correlations.js b/wqflask/wqflask/static/new/javascript/partial_correlations.js index e61dc250..fdba247f 100644 --- a/wqflask/wqflask/static/new/javascript/partial_correlations.js +++ b/wqflask/wqflask/static/new/javascript/partial_correlations.js @@ -66,6 +66,16 @@ function rho_or_r(method) { return "r"; } +function format_number(num) { + if(num === null) { + return NaN; + } + if(Math.abs(num) <= 1.04e-4) { + return num.toExponential(2); + } + return num.toFixed(5); +} + function display_publish_results(primary, controls, correlations, method) { table = document.getElementById("part-corr-results-publish"); table.setAttribute("style", "display: block;"); @@ -88,16 +98,16 @@ function display_publish_results(primary, controls, correlations, method) { 'td[data-column-heading="N"]').innerHTML = item["noverlap"]; new_row.querySelector( `td[data-column-heading="Partial ${rho_or_r(method)}"]` - ).innerHTML = item["partial_corr"]; + ).innerHTML = format_number(item["partial_corr"]); new_row.querySelector( `td[data-column-heading="p(partial ${rho_or_r(method)})"]` - ).innerHTML = item["partial_corr_p_value"]; + ).innerHTML = format_number(item["partial_corr_p_value"]); new_row.querySelector( `td[data-column-heading="${rho_or_r(method)}"]` - ).innerHTML = item["corr"]; + ).innerHTML = format_number(item["corr"]); new_row.querySelector( `td[data-column-heading="p(${rho_or_r(method)})"]` - ).innerHTML = item["corr_p_value"]; + ).innerHTML = format_number(item["corr_p_value"]); new_row.querySelector( `td[data-column-heading="delta ${rho_or_r(method)}"]` ).innerHTML = format_number(item["delta"]); |