aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzsloan2021-08-23 14:34:12 -0500
committerGitHub2021-08-23 14:34:12 -0500
commit895f9c0d1070ad9f5facd34e6307e3c60b31c226 (patch)
tree12e2a233cb4474e35f96aef53e32b3252bab75c6
parent4dafd017ec1fc0cd1e78487560ed15d705a44b98 (diff)
parent629aab0ef51c2c6f7d4f479e51a7168d9aa14d41 (diff)
downloadgenenetwork2-895f9c0d1070ad9f5facd34e6307e3c60b31c226.tar.gz
Merge pull request #599 from zsloan/bug/fix_mapping_recompute_issue
Bug/fix mapping recompute issue
-rw-r--r--wqflask/utility/Plot.py4
-rw-r--r--wqflask/wqflask/marker_regression/run_mapping.py12
-rw-r--r--wqflask/wqflask/show_trait/show_trait.py2
-rw-r--r--wqflask/wqflask/templates/mapping_results.html7
-rw-r--r--wqflask/wqflask/views.py1
5 files changed, 15 insertions, 11 deletions
diff --git a/wqflask/utility/Plot.py b/wqflask/utility/Plot.py
index 9b2c6735..d4256a46 100644
--- a/wqflask/utility/Plot.py
+++ b/wqflask/utility/Plot.py
@@ -139,7 +139,7 @@ def plotBar(canvas, data, barColor=BLUE, axesColor=BLACK, labelColor=BLACK, XLab
max_D = max(data)
min_D = min(data)
# add by NL 06-20-2011: fix the error: when max_D is infinite, log function in detScale will go wrong
- if max_D == float('inf') or max_D > webqtlConfig.MAXLRS:
+ if (max_D == float('inf') or max_D > webqtlConfig.MAXLRS) and min_D < webqtlConfig.MAXLRS:
max_D = webqtlConfig.MAXLRS # maximum LRS value
xLow, xTop, stepX = detScale(min_D, max_D)
@@ -156,7 +156,7 @@ def plotBar(canvas, data, barColor=BLUE, axesColor=BLACK, labelColor=BLACK, XLab
j += step
for i, item in enumerate(data):
- if item == float('inf') or item > webqtlConfig.MAXLRS:
+ if (item == float('inf') or item > webqtlConfig.MAXLRS) and min_D < webqtlConfig.MAXLRS:
item = webqtlConfig.MAXLRS # maximum LRS value
j = int((item - xLow) / step)
Count[j] += 1
diff --git a/wqflask/wqflask/marker_regression/run_mapping.py b/wqflask/wqflask/marker_regression/run_mapping.py
index f601201b..ebad7d36 100644
--- a/wqflask/wqflask/marker_regression/run_mapping.py
+++ b/wqflask/wqflask/marker_regression/run_mapping.py
@@ -220,7 +220,7 @@ class RunMapping:
elif self.mapping_method == "rqtl_plink":
results = self.run_rqtl_plink()
elif self.mapping_method == "rqtl_geno":
- perm_strata = []
+ self.perm_strata = []
if "perm_strata" in start_vars and "categorical_vars" in start_vars:
self.categorical_vars = start_vars["categorical_vars"].split(
",")
@@ -229,7 +229,7 @@ class RunMapping:
sample_names=self.samples,
this_trait=self.this_trait)
- perm_strata = get_perm_strata(
+ self.perm_strata = get_perm_strata(
self.this_trait, primary_samples, self.categorical_vars, self.samples)
self.score_type = "LOD"
self.control_marker = start_vars['control_marker']
@@ -243,10 +243,10 @@ class RunMapping:
# self.pair_scan = True
if self.permCheck and self.num_perm > 0:
self.perm_output, self.suggestive, self.significant, results = rqtl_mapping.run_rqtl(
- self.this_trait.name, self.vals, self.samples, self.dataset, self.mapping_scale, self.model, self.method, self.num_perm, perm_strata, self.do_control, self.control_marker, self.manhattan_plot, self.covariates)
+ self.this_trait.name, self.vals, self.samples, self.dataset, self.mapping_scale, self.model, self.method, self.num_perm, self.perm_strata, self.do_control, self.control_marker, self.manhattan_plot, self.covariates)
else:
results = rqtl_mapping.run_rqtl(self.this_trait.name, self.vals, self.samples, self.dataset, self.mapping_scale, self.model, self.method,
- self.num_perm, perm_strata, self.do_control, self.control_marker, self.manhattan_plot, self.covariates)
+ self.num_perm, self.perm_strata, self.do_control, self.control_marker, self.manhattan_plot, self.covariates)
elif self.mapping_method == "reaper":
if "startMb" in start_vars: # ZS: Check if first time page loaded, so it can default to ON
if "additiveCheck" in start_vars:
@@ -765,9 +765,9 @@ def get_perm_strata(this_trait, sample_list, categorical_vars, used_samples):
if sample in list(sample_list.sample_attribute_values.keys()):
combined_string = ""
for var in categorical_vars:
- if var.lower() in sample_list.sample_attribute_values[sample]:
+ if var in sample_list.sample_attribute_values[sample]:
combined_string += str(
- sample_list.sample_attribute_values[sample][var.lower()])
+ sample_list.sample_attribute_values[sample][var])
else:
combined_string += "NA"
else:
diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py
index 96f6901a..36e69fa3 100644
--- a/wqflask/wqflask/show_trait/show_trait.py
+++ b/wqflask/wqflask/show_trait/show_trait.py
@@ -701,7 +701,7 @@ def get_categorical_variables(this_trait, sample_list) -> list:
if len(sample_list.attributes) > 0:
for attribute in sample_list.attributes:
if len(sample_list.attributes[attribute].distinct_values) < 10:
- categorical_var_list.append(sample_list.attributes[attribute].name)
+ categorical_var_list.append(str(sample_list.attributes[attribute].id))
return categorical_var_list
diff --git a/wqflask/wqflask/templates/mapping_results.html b/wqflask/wqflask/templates/mapping_results.html
index 35d8a157..81eb1ba1 100644
--- a/wqflask/wqflask/templates/mapping_results.html
+++ b/wqflask/wqflask/templates/mapping_results.html
@@ -44,7 +44,12 @@
{% endif %}
<input type="hidden" name="num_perm" value="{{ nperm }}">
<input type="hidden" name="perm_info" value="">
- <input type="hidden" name="perm_strata" value="{{ perm_strata }}">
+ {% if categorical_vars is defined %}
+ <input type="hidden" name="categorical_vars" value="{{ categorical_vars|join(',') }}">
+ {% endif %}
+ {% if perm_strata is defined %}
+ <input type="hidden" name="perm_strata" value="True">
+ {% endif %}
<input type="hidden" name="num_bootstrap" value="{{ nboot }}">
<input type="hidden" name="do_control" value="{{ doControl }}">
<input type="hidden" name="control_marker" value="{{ controlLocus }}">
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py
index 957c34be..11a9380c 100644
--- a/wqflask/wqflask/views.py
+++ b/wqflask/wqflask/views.py
@@ -1067,7 +1067,6 @@ def mapping_results_page():
'num_perm',
'permCheck',
'perm_strata',
- 'strat_var',
'categorical_vars',
'perm_output',
'num_bootstrap',