From 47c15cdbd8d54afca05bf939dec8d7d461cff5a5 Mon Sep 17 00:00:00 2001
From: zsloan
Date: Fri, 18 Dec 2020 14:30:13 -0600
Subject: Added function that fetches sample data and converts it to JSON to
show_trait.js
---
.../wqflask/static/new/javascript/show_trait.js | 23 ++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/wqflask/wqflask/static/new/javascript/show_trait.js b/wqflask/wqflask/static/new/javascript/show_trait.js
index 98f90f7d..b71a9dd8 100644
--- a/wqflask/wqflask/static/new/javascript/show_trait.js
+++ b/wqflask/wqflask/static/new/javascript/show_trait.js
@@ -427,6 +427,25 @@ process_id = function() {
}
return processed;
};
+
+fetch_sample_values = function() {
+ // This is meant to fetch all sample values using DataTables API, since they can't all be submitted with the form when using Scroller (and this should also be faster)
+ sample_val_dict = {};
+
+ table = 'samples_primary';
+ if ($('#' + table).length){
+ table_api = $('#' + table).DataTable();
+ val_nodes = table_api.column(3).nodes().to$();
+ for (_j = 0; _j < val_nodes.length; _j++){
+ sample_name = val_nodes[_j].childNodes[0].name.split(":")[1]
+ sample_val = val_nodes[_j].childNodes[0].value
+ sample_val_dict[sample_name] = sample_val
+ }
+ }
+
+ return sample_val_dict;
+}
+
edit_data_change = function() {
var already_seen, checkbox, name, real_dict, real_value, real_variance, row, rows, sample_sets, table, tables, _i, _j, _len, _len1;
already_seen = {};
@@ -525,7 +544,7 @@ on_corr_method_change = function() {
$('select[name=corr_type]').change(on_corr_method_change);
submit_special = function(url) {
- get_table_contents_for_form_submit("trait_data_form");
+ $("input[name=sample_vals]").val(JSON.stringify(fetch_sample_values()))
$("#trait_data_form").attr("action", url);
$("#trait_data_form").submit();
};
@@ -549,7 +568,7 @@ get_table_contents_for_form_submit = function(form_id) {
});
}
-var corr_input_list = ['corr_type', 'primary_samples', 'trait_id', 'dataset', 'group', 'tool_used', 'form_url', 'corr_sample_method', 'corr_samples_group', 'corr_dataset', 'min_expr',
+var corr_input_list = ['sample_vals', 'corr_type', 'primary_samples', 'trait_id', 'dataset', 'group', 'tool_used', 'form_url', 'corr_sample_method', 'corr_samples_group', 'corr_dataset', 'min_expr',
'corr_return_results', 'loc_chr', 'min_loc_mb', 'max_loc_mb', 'p_range_lower', 'p_range_upper']
$(".corr_compute").on("click", (function(_this) {
--
cgit v1.2.3
From 66b8f70f162f2d6356c6e9af5066c5b90335f7c2 Mon Sep 17 00:00:00 2001
From: zsloan
Date: Fri, 18 Dec 2020 14:33:04 -0600
Subject: Changed views.py to accept sample data for loading page and mapping
as JSON instead of having separate form parameters for each sample + removed
some commented out code/logging
---
wqflask/wqflask/views.py | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py
index 25563e86..c136711e 100644
--- a/wqflask/wqflask/views.py
+++ b/wqflask/wqflask/views.py
@@ -621,12 +621,13 @@ def loading_page():
wanted = initial_start_vars['wanted_inputs'].split(",")
start_vars = {}
for key, value in list(initial_start_vars.items()):
- if key in wanted or key.startswith(('value:')):
+ if key in wanted:
start_vars[key] = value
if 'n_samples' in start_vars:
n_samples = int(start_vars['n_samples'])
else:
+ sample_vals_dict = json.loads(start_vars['sample_vals'])
if 'group' in start_vars:
dataset = create_dataset(start_vars['dataset'], group_name = start_vars['group'])
else:
@@ -642,8 +643,7 @@ def loading_page():
samples = genofile_samples
for sample in samples:
- value = start_vars.get('value:' + sample)
- if value != "x":
+ if sample_vals_dict[sample] != "x":
n_samples += 1
start_vars['n_samples'] = n_samples
@@ -660,7 +660,6 @@ def loading_page():
@app.route("/run_mapping", methods=('POST',))
def mapping_results_page():
initial_start_vars = request.form
- #logger.debug("Mapping called with initial_start_vars:", initial_start_vars.items())
logger.info(request.url)
temp_uuid = initial_start_vars['temp_uuid']
wanted = (
@@ -670,6 +669,7 @@ def mapping_results_page():
'species',
'samples',
'vals',
+ 'sample_vals',
'first_run',
'output_files',
'geno_db_exists',
@@ -723,13 +723,11 @@ def mapping_results_page():
)
start_vars = {}
for key, value in list(initial_start_vars.items()):
- if key in wanted or key.startswith(('value:')):
+ if key in wanted:
start_vars[key] = value
- #logger.debug("Mapping called with start_vars:", start_vars)
version = "v3"
key = "mapping_results:{}:".format(version) + json.dumps(start_vars, sort_keys=True)
- #logger.info("key is:", pf(key))
with Bench("Loading cache"):
result = None # Just for testing
#result = Redis.get(key)
@@ -775,10 +773,6 @@ def mapping_results_page():
rendered_template = render_template("pair_scan_results.html", **result)
else:
gn1_template_vars = display_mapping_results.DisplayMappingResults(result).__dict__
- #pickled_result = pickle.dumps(result, pickle.HIGHEST_PROTOCOL)
- #logger.info("pickled result length:", len(pickled_result))
- #Redis.set(key, pickled_result)
- #Redis.expire(key, 1*60)
with Bench("Rendering template"):
#if (gn1_template_vars['mapping_method'] == "gemma") or (gn1_template_vars['mapping_method'] == "plink"):
--
cgit v1.2.3
From 20314199985aa21a00a47f3c7b053ec49bc8b60d Mon Sep 17 00:00:00 2001
From: zsloan
Date: Fri, 18 Dec 2020 14:33:44 -0600
Subject: Added sample_vals input element that is meant to contain JSON for all
sample values (pulled from the sample table using DataTables API in
show_trait.js)
---
wqflask/wqflask/templates/show_trait.html | 1 +
1 file changed, 1 insertion(+)
diff --git a/wqflask/wqflask/templates/show_trait.html b/wqflask/wqflask/templates/show_trait.html
index c881eb76..77fc9342 100644
--- a/wqflask/wqflask/templates/show_trait.html
+++ b/wqflask/wqflask/templates/show_trait.html
@@ -35,6 +35,7 @@
+
--
cgit v1.2.3
From 969a421efc0bd4529607fdc14332acd897d8e106 Mon Sep 17 00:00:00 2001
From: zsloan
Date: Fri, 18 Dec 2020 14:34:21 -0600
Subject: Added sample_vals to the list of mapping inputs that determines what
is included in start_vars when trait page parameters are passed to the
mapping loading page
---
wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js b/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js
index 34582f21..3ae52975 100644
--- a/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js
+++ b/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js
@@ -141,7 +141,7 @@ $('input[name=display_all]').change((function(_this) {
})(this));
//ZS: This is a list of inputs to be passed to the loading page, since not all inputs on the trait page are relevant to mapping
-var mapping_input_list = ['temp_uuid', 'trait_id', 'dataset', 'tool_used', 'form_url', 'method', 'transform', 'trimmed_markers', 'selected_chr', 'chromosomes', 'mapping_scale',
+var mapping_input_list = ['temp_uuid', 'trait_id', 'dataset', 'tool_used', 'form_url', 'method', 'transform', 'trimmed_markers', 'selected_chr', 'chromosomes', 'mapping_scale', 'sample_vals',
'score_type', 'suggestive', 'significant', 'num_perm', 'permCheck', 'perm_output', 'perm_strata', 'categorical_vars', 'num_bootstrap', 'bootCheck', 'bootstrap_results',
'LRSCheck', 'covariates', 'maf', 'use_loco', 'manhattan_plot', 'control_marker', 'control_marker_db', 'do_control', 'genofile',
'pair_scan', 'startMb', 'endMb', 'graphWidth', 'lrsMax', 'additiveCheck', 'showSNP', 'showGenes', 'viewLegend', 'haplotypeAnalystCheck',
--
cgit v1.2.3
From 95d1887bba6b93ea310c226cb82e9cb64f75cc67 Mon Sep 17 00:00:00 2001
From: zsloan
Date: Fri, 18 Dec 2020 14:35:09 -0600
Subject: Changed mapping_results.html to have a single sample_vals input
instead of separate ones for every sample + added sample_vals to the list of
inputs sent to the loading page
---
wqflask/wqflask/templates/mapping_results.html | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/wqflask/wqflask/templates/mapping_results.html b/wqflask/wqflask/templates/mapping_results.html
index 1a76ef7a..2fb37832 100644
--- a/wqflask/wqflask/templates/mapping_results.html
+++ b/wqflask/wqflask/templates/mapping_results.html
@@ -31,10 +31,7 @@
{% endif %}
-
- {% for sample in samples %}
-
- {% endfor %}
+
@@ -450,7 +447,7 @@
});
- var mapping_input_list = ['temp_uuid', 'trait_id', 'dataset', 'tool_used', 'form_url', 'method', 'transform', 'trimmed_markers', 'selected_chr', 'chromosomes', 'mapping_scale',
+ var mapping_input_list = ['temp_uuid', 'trait_id', 'dataset', 'tool_used', 'form_url', 'method', 'transform', 'trimmed_markers', 'selected_chr', 'chromosomes', 'mapping_scale', 'sample_vals',
'score_type', 'suggestive', 'significant', 'num_perm', 'permCheck', 'perm_output', 'perm_strata', 'categorical_vars', 'num_bootstrap', 'bootCheck', 'bootstrap_results',
'LRSCheck', 'covariates', 'maf', 'use_loco', 'manhattan_plot', 'color_scheme', 'manhattan_single_color', 'control_marker', 'control_marker_db', 'do_control', 'genofile',
'pair_scan', 'startMb', 'endMb', 'graphWidth', 'lrsMax', 'additiveCheck', 'showSNP', 'showGenes', 'viewLegend', 'haplotypeAnalystCheck',
--
cgit v1.2.3
From 7544d03a6d819d70779deb79d38b7465a648c1ff Mon Sep 17 00:00:00 2001
From: zsloan
Date: Fri, 18 Dec 2020 14:36:53 -0600
Subject: Changed run_mapping.py to get sample names and values from JSON
instead of a bunch of separate input parameters
---
wqflask/wqflask/marker_regression/run_mapping.py | 64 ++++++------------------
1 file changed, 15 insertions(+), 49 deletions(-)
diff --git a/wqflask/wqflask/marker_regression/run_mapping.py b/wqflask/wqflask/marker_regression/run_mapping.py
index 891fcc66..a1f87b61 100644
--- a/wqflask/wqflask/marker_regression/run_mapping.py
+++ b/wqflask/wqflask/marker_regression/run_mapping.py
@@ -71,56 +71,22 @@ class RunMapping(object):
all_samples_ordered = self.dataset.group.all_samples_ordered()
self.vals = []
- if 'samples' in start_vars:
- self.samples = start_vars['samples'].split(",")
- if (len(genofile_samplelist) != 0):
- for sample in genofile_samplelist:
- if sample in self.samples:
- value = start_vars.get('value:' + sample)
- if value:
- self.vals.append(value)
- else:
- self.vals.append("x")
- else:
- for sample in self.samples:
- value = start_vars.get('value:' + sample)
- if value:
- self.vals.append(value)
+ self.samples = []
+ self.sample_vals = start_vars['sample_vals']
+ sample_val_dict = json.loads(self.sample_vals)
+ samples = sample_val_dict.keys()
+ if (len(genofile_samplelist) != 0):
+ for sample in genofile_samplelist:
+ self.samples.append(sample)
+ if sample in samples:
+ self.vals.append(sample_val_dict[sample])
+ else:
+ self.vals.append("x")
else:
- self.samples = []
- if (len(genofile_samplelist) != 0):
- for sample in genofile_samplelist:
- if sample in self.dataset.group.samplelist:
- in_trait_data = False
- for item in self.this_trait.data:
- if self.this_trait.data[item].name == sample:
- value = start_vars['value:' + self.this_trait.data[item].name]
- self.samples.append(self.this_trait.data[item].name)
- self.vals.append(value)
- in_trait_data = True
- break
- if not in_trait_data:
- value = start_vars.get('value:' + sample)
- if value:
- self.samples.append(sample)
- self.vals.append(value)
- else:
- self.vals.append("x")
- else:
- for sample in self.dataset.group.samplelist: # sample is actually the name of an individual
- in_trait_data = False
- for item in self.this_trait.data:
- if self.this_trait.data[item].name == sample:
- value = start_vars['value:' + self.this_trait.data[item].name]
- self.samples.append(self.this_trait.data[item].name)
- self.vals.append(value)
- in_trait_data = True
- break
- if not in_trait_data:
- value = start_vars.get('value:' + sample)
- if value:
- self.samples.append(sample)
- self.vals.append(value)
+ for sample in self.dataset.group.samplelist:
+ if sample in samples:
+ self.vals.append(sample_val_dict[sample])
+ self.samples.append(sample)
if 'n_samples' in start_vars:
self.n_samples = start_vars['n_samples']
--
cgit v1.2.3
From 6d493f7ef57322f226dd310497e4dc7518440cfd Mon Sep 17 00:00:00 2001
From: zsloan
Date: Fri, 18 Dec 2020 14:38:09 -0600
Subject: Changed display_mapping_results.py to get sample names and values
from the JSON sample_vals parameter
---
.../marker_regression/display_mapping_results.py | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/wqflask/wqflask/marker_regression/display_mapping_results.py b/wqflask/wqflask/marker_regression/display_mapping_results.py
index 08c2d750..9f1b050d 100644
--- a/wqflask/wqflask/marker_regression/display_mapping_results.py
+++ b/wqflask/wqflask/marker_regression/display_mapping_results.py
@@ -270,8 +270,9 @@ class DisplayMappingResults(object):
# Needing for form submission when doing single chr
# mapping or remapping after changing options
- self.samples = start_vars['samples']
- self.vals = start_vars['vals']
+ self.sample_vals = start_vars['sample_vals']
+ self.sample_vals_dict = json.loads(self.sample_vals)
+
self.transform = start_vars['transform']
self.mapping_method = start_vars['mapping_method']
self.mapping_results_path = start_vars['mapping_results_path']
@@ -492,11 +493,10 @@ class DisplayMappingResults(object):
## count the amount of individuals to be plotted, and increase self.graphHeight
if self.haplotypeAnalystChecked and self.selectedChr > -1:
thisTrait = self.this_trait
- _strains, _vals, _vars, _aliases = thisTrait.export_informative()
smd=[]
- for ii, _val in enumerate(self.vals):
- if _val != "x":
- temp = GeneralObject(name=self.samples[ii], value=float(_val))
+ for sample in self.sample_vals_dict.keys():
+ if self.sample_vals_dict[sample] != "x":
+ temp = GeneralObject(name=sample, value=float(self.sample_vals_dict[sample]))
smd.append(temp)
else:
continue
@@ -1464,12 +1464,11 @@ class DisplayMappingResults(object):
yPaddingTop = yTopOffset
thisTrait = self.this_trait
- _strains, _vals, _vars, _aliases = thisTrait.export_informative()
smd=[]
- for ii, _val in enumerate(self.vals):
- if _val != "x":
- temp = GeneralObject(name=self.samples[ii], value=float(_val))
+ for sample in self.sample_vals_dict.keys():
+ if self.sample_vals_dict[sample] != "x":
+ temp = GeneralObject(name=sample, value=float(self.sample_vals_dict[sample]))
smd.append(temp)
else:
continue
--
cgit v1.2.3
From 41efd6840f2e1c052dbb77affd6f09fc2e2bcd05 Mon Sep 17 00:00:00 2001
From: zsloan
Date: Fri, 18 Dec 2020 14:39:31 -0600
Subject: Changed show_corr_results.py to get sample names/values from the JSON
sample_vals parameter
---
wqflask/wqflask/correlation/show_corr_results.py | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/wqflask/wqflask/correlation/show_corr_results.py b/wqflask/wqflask/correlation/show_corr_results.py
index 7d3b9b9f..be983c87 100644
--- a/wqflask/wqflask/correlation/show_corr_results.py
+++ b/wqflask/wqflask/correlation/show_corr_results.py
@@ -87,8 +87,6 @@ class CorrelationResults(object):
else:
helper_functions.get_species_dataset_trait(self, start_vars)
- #self.dataset.group.read_genotype_file()
-
corr_samples_group = start_vars['corr_samples_group']
self.sample_data = {}
@@ -454,13 +452,13 @@ class CorrelationResults(object):
if not excluded_samples:
excluded_samples = ()
+ sample_val_dict = json.loads(start_vars['sample_vals'])
for sample in sample_names:
if sample not in excluded_samples:
- # print("Looking for",sample,"in",start_vars)
- value = start_vars.get('value:' + sample)
- if value:
- if not value.strip().lower() == 'x':
- self.sample_data[str(sample)] = float(value)
+ value = sample_val_dict[sample]
+ if not value.strip().lower() == 'x':
+ self.sample_data[str(sample)] = float(value)
+
def do_bicor(this_trait_vals, target_trait_vals):
r_library = ro.r["library"] # Map the library function
--
cgit v1.2.3