From 43a7e2b160c726c7641f8226931000bf69802bdc Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Wed, 5 Jan 2022 09:03:46 +0300 Subject: Fix bug: rho/r not set appropriately Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * The column heading, and the "data-column-heading" values depend on the correlation method. The initial idea had been to set these values up from the server. With the use of Javascript, however, the system defaults to using `r`, which is a bug when the method is any of the Spearman's methods. --- .../static/new/javascript/partial_correlations.js | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'wqflask') diff --git a/wqflask/wqflask/static/new/javascript/partial_correlations.js b/wqflask/wqflask/static/new/javascript/partial_correlations.js index 1a06c48f..b3a89c5e 100644 --- a/wqflask/wqflask/static/new/javascript/partial_correlations.js +++ b/wqflask/wqflask/static/new/javascript/partial_correlations.js @@ -211,10 +211,33 @@ function display_probeset_results(primary, controls, correlations, method) { /*table_body.removeChild(template_row);*/ } +function replace_r_with_rho(method) { + /* Mostly utility: Replace `r` with `rho` in the appropriate places */ + pattern = /\br\b/; + if(method == "spearman") { + results_div = document.getElementById("partial-correlation-results"); + headers = results_div.getElementsByTagName("th"); + for(let header of headers) { + header.innerHTML = header.innerHTML.replace(pattern, "rho"); + } + + cells = results_div.getElementsByTagName("td"); + for(let cell of cells) { + cell.setAttribute( + "data-column-heading", + cell.getAttribute( + "data-column-heading").replace(pattern, "rho")); + } + } +} + function display_partial_corr_results(data, status, xhr) { progress_indicator = document.getElementById( "partial-correlations-progress-indicator").style.display = "none"; console.log(data); + + replace_r_with_rho(data["results"]["method"]); + display_functions = { "Publish": display_publish_results, "Geno": display_geno_results, -- cgit v1.2.3