about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2022-01-05 09:03:46 +0300
committerFrederick Muriuki Muriithi2022-01-28 08:07:27 +0300
commit43a7e2b160c726c7641f8226931000bf69802bdc (patch)
tree3876ce0edbb940509916ef0667c749db08095add
parente7eb1b8b3bad8834e7bfdcc92a777147a5a97079 (diff)
downloadgenenetwork2-43a7e2b160c726c7641f8226931000bf69802bdc.tar.gz
Fix bug: rho/r not set appropriately partial-correlations
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.
-rw-r--r--wqflask/wqflask/static/new/javascript/partial_correlations.js23
1 files changed, 23 insertions, 0 deletions
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,