diff options
author | Frederick Muriuki Muriithi | 2021-12-20 11:49:22 +0300 |
---|---|---|
committer | zsloan | 2022-01-29 00:42:44 -0600 |
commit | 53985f5ac92d31f38748d101c9bb1574b11e5f73 (patch) | |
tree | b4bee585a0eb9551f35b4462bc3ad800fe5cca2d | |
parent | aea641e0a6fbd0ea68241efffb7c280222491238 (diff) | |
download | genenetwork2-53985f5ac92d31f38748d101c9bb1574b11e5f73.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"]); |