aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
authorZachary Sloan2013-10-16 18:02:28 -0500
committerZachary Sloan2013-10-16 18:02:28 -0500
commitda0526b9d870ba937fcf860c40731c9d96eb9f63 (patch)
tree039a902462091232c8e96679a0e592e1075791dc /wqflask
parenta823e66f8dc742e1608b3e0db6d521d5f63b641a (diff)
downloadgenenetwork2-da0526b9d870ba937fcf860c40731c9d96eb9f63.tar.gz
Added interval_mapping to views.py
Made some more changes to interval_mapping.py
Diffstat (limited to 'wqflask')
-rwxr-xr-x[-rw-r--r--]wqflask/wqflask/interval_mapping/interval_mapping.py70
-rw-r--r--wqflask/wqflask/views.py44
2 files changed, 79 insertions, 35 deletions
diff --git a/wqflask/wqflask/interval_mapping/interval_mapping.py b/wqflask/wqflask/interval_mapping/interval_mapping.py
index 5d660224..aca99cbe 100644..100755
--- a/wqflask/wqflask/interval_mapping/interval_mapping.py
+++ b/wqflask/wqflask/interval_mapping/interval_mapping.py
@@ -89,26 +89,56 @@ class IntervalMapping(object):
samples, values, variances = self.trait.export_informative()
if self.control_locus:
if self.weighted_regression:
- qtl_result = self.dataset.genotype.regression(strains = samples,
+ self.qtl_results = self.dataset.genotype.regression(strains = samples,
trait = values,
variance = variances,
control = self.control_locus)
else:
- qtl_result = self.dataset.genotype.regression(strains = samples,
+ self.qtl_results = self.dataset.genotype.regression(strains = samples,
trait = values,
control = self.control_locus)
else:
if self.weighted_regression:
- qtl_result = self.dataset.genotype.regression(strains = samples,
+ self.qtl_results = self.dataset.genotype.regression(strains = samples,
trait = values,
variance = variances)
else:
- qtl_result = self.dataset.genotype.regression(strains = samples,
+ self.qtl_results = self.dataset.genotype.regression(strains = samples,
trait = values)
- pheno_vector = np.array([val == "x" and np.nan or float(val) for val in self.vals])
+ #pheno_vector = np.array([val == "x" and np.nan or float(val) for val in self.vals])
+
+ #if self.dataset.group.species == "human":
+ # p_values, t_stats = self.gen_human_results(pheno_vector, tempdata)
+ #else:
+ genotype_data = [marker['genotypes'] for marker in self.dataset.group.markers.markers]
+
+ no_val_samples = self.identify_empty_samples()
+ trimmed_genotype_data = self.trim_genotypes(genotype_data, no_val_samples)
+
+ genotype_matrix = np.array(trimmed_genotype_data).T
+
+ #t_stats, p_values = lmm.run(
+ # pheno_vector,
+ # genotype_matrix,
+ # restricted_max_likelihood=True,
+ # refit=False,
+ # temp_data=tempdata
+ #)
+
+ #self.dataset.group.markers.add_pvalues(p_values)
+
+ #self.qtl_results = self.dataset.group.markers.markers
+ def gen_qtl_results_2(self, tempdata):
+ """Generates qtl results for plotting interval map"""
+
+ self.dataset.group.get_markers()
+ self.dataset.read_genotype_file()
+
+ pheno_vector = np.array([val == "x" and np.nan or float(val) for val in self.vals])
+
#if self.dataset.group.species == "human":
# p_values, t_stats = self.gen_human_results(pheno_vector, tempdata)
#else:
@@ -131,36 +161,6 @@ class IntervalMapping(object):
self.qtl_results = self.dataset.group.markers.markers
- #def gen_qtl_results_2(self, tempdata):
- # """Generates qtl results for plotting interval map"""
- #
- # self.dataset.group.get_markers()
- # self.dataset.read_genotype_file()
- #
- # pheno_vector = np.array([val == "x" and np.nan or float(val) for val in self.vals])
- #
- # #if self.dataset.group.species == "human":
- # # p_values, t_stats = self.gen_human_results(pheno_vector, tempdata)
- # #else:
- # genotype_data = [marker['genotypes'] for marker in self.dataset.group.markers.markers]
- #
- # no_val_samples = self.identify_empty_samples()
- # trimmed_genotype_data = self.trim_genotypes(genotype_data, no_val_samples)
- #
- # genotype_matrix = np.array(trimmed_genotype_data).T
- #
- # t_stats, p_values = lmm.run(
- # pheno_vector,
- # genotype_matrix,
- # restricted_max_likelihood=True,
- # refit=False,
- # temp_data=tempdata
- # )
- #
- # self.dataset.group.markers.add_pvalues(p_values)
- #
- # self.qtl_results = self.dataset.group.markers.markers
-
def identify_empty_samples(self):
no_val_samples = []
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py
index deccf459..29f7f150 100644
--- a/wqflask/wqflask/views.py
+++ b/wqflask/wqflask/views.py
@@ -32,6 +32,7 @@ from base.data_set import create_datasets_list
from wqflask.show_trait import show_trait
from wqflask.show_trait import export_trait_data
from wqflask.marker_regression import marker_regression
+from wqflask.interval_mapping import interval_mapping
from wqflask.correlation import show_corr_results
from utility import temp_data
@@ -246,6 +247,49 @@ def marker_regression_page():
return rendered_template
+@app.route("/interval_mapping", methods=('POST',))
+def interval_mapping_page():
+ initial_start_vars = request.form
+ temp_uuid = initial_start_vars['temp_uuid']
+ wanted = (
+ 'trait_id',
+ 'dataset',
+ 'suggestive'
+ )
+
+ start_vars = {}
+ for key, value in initial_start_vars.iteritems():
+ if key in wanted or key.startswith(('value:')):
+ start_vars[key] = value
+
+ version = "v1"
+ key = "interval_mapping:{}:".format(version) + json.dumps(start_vars, sort_keys=True)
+ print("key is:", pf(key))
+ with Bench("Loading cache"):
+ result = Redis.get(key)
+
+ if result:
+ print("Cache hit!!!")
+ with Bench("Loading results"):
+ result = pickle.loads(result)
+ else:
+ print("Cache miss!!!")
+ template_vars = interval_mapping.IntervalMapping(start_vars, temp_uuid)
+
+ template_vars.js_data = json.dumps(template_vars.js_data,
+ default=json_default_handler,
+ indent=" ")
+
+ result = template_vars.__dict__
+
+ #causeerror
+ Redis.set(key, pickle.dumps(result, pickle.HIGHEST_PROTOCOL))
+ Redis.expire(key, 60*60)
+
+ with Bench("Rendering template"):
+ rendered_template = render_template("interval_mapping.html", **result)
+
+ return rendered_template
@app.route("/corr_compute", methods=('POST',))
def corr_compute_page():