From 59fb44e4e79fd7343d64527d129b2192b739a13e Mon Sep 17 00:00:00 2001 From: zsloan Date: Tue, 8 Sep 2015 19:28:15 +0000 Subject: Fixed covariates with R/qtl mapping A few minor GUI changes on trait page (button names, locations, etc) Fixed "pressing enter to search" on index page --- .../wqflask/marker_regression/marker_regression.py | 7 +-- wqflask/wqflask/show_trait/show_trait.py | 25 ++++++---- .../new/javascript/show_trait_mapping_tools.js | 1 + wqflask/wqflask/templates/index_page.html | 2 +- wqflask/wqflask/templates/show_trait_details.html | 12 ++--- .../templates/show_trait_mapping_tools.html | 54 ++++++++++++++-------- wqflask/wqflask/views.py | 1 + 7 files changed, 65 insertions(+), 37 deletions(-) diff --git a/wqflask/wqflask/marker_regression/marker_regression.py b/wqflask/wqflask/marker_regression/marker_regression.py index 757aeb72..b33efc1f 100755 --- a/wqflask/wqflask/marker_regression/marker_regression.py +++ b/wqflask/wqflask/marker_regression/marker_regression.py @@ -91,6 +91,7 @@ class MarkerRegression(object): else: self.num_perm = start_vars['num_perm'] self.control = start_vars['control_marker'] + self.do_control = start_vars['do_control'] print("StartVars:", start_vars) self.method = start_vars['mapmethod_rqtl_geno'] self.model = start_vars['mapmodel_rqtl_geno'] @@ -352,7 +353,7 @@ class MarkerRegression(object): covar = self.create_covariates(cross_object) # Create the additive covariate matrix if self.pair_scan: - if(r_sum(covar)[0] > 0): # If sum(covar) > 0 we have a covariate matrix + if self.do_control == "true": # If sum(covar) > 0 we have a covariate matrix print("Using covariate"); result_data_frame = scantwo(cross_object, pheno = "the_pheno", addcovar = covar, model=self.model, method=self.method, n_cluster = 16) else: print("No covariates"); result_data_frame = scantwo(cross_object, pheno = "the_pheno", model=self.model, method=self.method, n_cluster = 16) @@ -367,13 +368,13 @@ class MarkerRegression(object): return self.process_pair_scan_results(result_data_frame) else: - if(r_sum(covar)[0] > 0): + if self.do_control == "true": print("Using covariate"); result_data_frame = scanone(cross_object, pheno = "the_pheno", addcovar = covar, model=self.model, method=self.method) else: print("No covariates"); result_data_frame = scanone(cross_object, pheno = "the_pheno", model=self.model, method=self.method) if int(self.num_perm) > 0: # Do permutation (if requested by user) - if(r_sum(covar)[0] > 0): + if self.do_control == "true": perm_data_frame = scanone(cross_object, pheno_col = "the_pheno", addcovar = covar, n_perm = int(self.num_perm), model=self.model, method=self.method) else: perm_data_frame = scanone(cross_object, pheno_col = "the_pheno", n_perm = int(self.num_perm), model=self.model, method=self.method) diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py index 871d1880..e83437ab 100755 --- a/wqflask/wqflask/show_trait/show_trait.py +++ b/wqflask/wqflask/show_trait/show_trait.py @@ -102,11 +102,13 @@ class ShowTrait(object): print("self.dataset.type:", self.dataset.type) if hasattr(self.this_trait, 'locus_chr') and self.this_trait.locus_chr != "" and self.dataset.type != "Geno" and self.dataset.type != "Publish": - self.nearest_marker1 = get_nearest_marker(self.this_trait, self.dataset)[0] - self.nearest_marker2 = get_nearest_marker(self.this_trait, self.dataset)[1] + self.nearest_marker = get_nearest_marker(self.this_trait, self.dataset) + #self.nearest_marker1 = get_nearest_marker(self.this_trait, self.dataset)[0] + #self.nearest_marker2 = get_nearest_marker(self.this_trait, self.dataset)[1] else: - self.nearest_marker1 = "" - self.nearest_marker2 = "" + self.nearest_marker = "" + #self.nearest_marker1 = "" + #self.nearest_marker2 = "" self.make_sample_lists(self.this_trait) @@ -120,11 +122,13 @@ class ShowTrait(object): hddn['mapping_display_all'] = True hddn['suggestive'] = 0 hddn['num_perm'] = 0 - hddn['manhattan_plot'] = False + hddn['manhattan_plot'] = "" if hasattr(self.this_trait, 'locus_chr') and self.this_trait.locus_chr != "" and self.dataset.type != "Geno" and self.dataset.type != "Publish": - hddn['control_marker'] = self.nearest_marker1+","+self.nearest_marker2 + hddn['control_marker'] = self.nearest_marker + #hddn['control_marker'] = self.nearest_marker1+","+self.nearest_marker2 else: hddn['control_marker'] = "" + hddn['do_control'] = False hddn['maf'] = 0.01 hddn['compare_traits'] = [] hddn['export_data'] = "" @@ -1231,21 +1235,24 @@ def get_nearest_marker(this_trait, this_db): print("this_chr:", this_chr) this_mb = this_trait.locus_mb print("this_mb:", this_mb) + #One option is to take flanking markers, another is to take the two (or one) closest query = """SELECT Geno.Name FROM Geno, GenoXRef, GenoFreeze WHERE Geno.Chr = '{}' AND GenoXRef.GenoId = Geno.Id AND GenoFreeze.Id = GenoXRef.GenoFreezeId AND GenoFreeze.Name = '{}' - ORDER BY ABS( Geno.Mb - {}) LIMIT 2""".format(this_chr, this_db.group.name+"Geno", this_mb) + ORDER BY ABS( Geno.Mb - {}) LIMIT 1""".format(this_chr, this_db.group.name+"Geno", this_mb) print("query:", query) result = g.db.execute(query).fetchall() print("result:", result) if result == []: - return "", "" + return "" + #return "", "" else: - return result[0][0], result[1][0] + return result[0][0] + #return result[0][0], result[1][0] 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 3be40a57..2f26d6cb 100755 --- a/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js +++ b/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js @@ -185,6 +185,7 @@ $('input[name=num_perm]').val($('input[name=num_perm_rqtl_geno]').val()); $('input[name=manhattan_plot]').val($('input[name=manhattan_plot_rqtl]:checked').val()); $('input[name=control_marker]').val($('input[name=control_rqtl_geno]').val()); + $('input[name=do_control]').val($('input[name=do_control_rqtl]:checked').val()); form_data = $('#trait_data_form').serialize(); console.log("form_data is:", form_data); return do_ajax_post(url, form_data); diff --git a/wqflask/wqflask/templates/index_page.html b/wqflask/wqflask/templates/index_page.html index 2bbfcd91..6c630344 100755 --- a/wqflask/wqflask/templates/index_page.html +++ b/wqflask/wqflask/templates/index_page.html @@ -271,7 +271,7 @@ // Has the enter key been pressed? if ( (window.event ? event.keyCode : e.which) == 13) { // If it has been so, manually submit the
- document.forms[0].submit(); + document.forms[1].submit(); } } diff --git a/wqflask/wqflask/templates/show_trait_details.html b/wqflask/wqflask/templates/show_trait_details.html index 3259d349..cdaa919e 100755 --- a/wqflask/wqflask/templates/show_trait_details.html +++ b/wqflask/wqflask/templates/show_trait_details.html @@ -38,12 +38,6 @@
Resource Links
{% if this_trait.dataset.type == 'ProbeSet' %}
- {% if this_trait.symbol != None %} - - Genotation - -    - {% endif %} {% if this_trait.geneid != None %} Gene @@ -62,6 +56,12 @@    {% endif %} + {% if this_trait.symbol != None %} + + Genotation + +    + {% endif %}
{% endif %} diff --git a/wqflask/wqflask/templates/show_trait_mapping_tools.html b/wqflask/wqflask/templates/show_trait_mapping_tools.html index 7f26a252..de25f4ee 100755 --- a/wqflask/wqflask/templates/show_trait_mapping_tools.html +++ b/wqflask/wqflask/templates/show_trait_mapping_tools.html @@ -1,6 +1,6 @@
{% if (use_pylmm_rqtl and dataset.group.species != "human") or use_plink_gemma %} -
+