From cd6f5b8c9470f309163b0fdc85374c408a96dfdc Mon Sep 17 00:00:00 2001 From: zsloan Date: Wed, 18 Mar 2015 22:21:12 +0000 Subject: Begun adding pair scan option, fixed bug if no closest markers found --- .../wqflask/marker_regression/marker_regression.py | 37 +++++++--- wqflask/wqflask/show_trait/show_trait.py | 5 +- .../templates/show_trait_mapping_tools.html | 83 +++++++++++++--------- wqflask/wqflask/views.py | 3 +- 4 files changed, 82 insertions(+), 46 deletions(-) diff --git a/wqflask/wqflask/marker_regression/marker_regression.py b/wqflask/wqflask/marker_regression/marker_regression.py index 9a3ff073..db92e14c 100755 --- a/wqflask/wqflask/marker_regression/marker_regression.py +++ b/wqflask/wqflask/marker_regression/marker_regression.py @@ -65,6 +65,7 @@ class MarkerRegression(object): self.manhattan_plot = True else: self.manhattan_plot = False + self.maf = start_vars['maf'] # Minor allele frequency self.suggestive = "" self.significant = "" @@ -82,6 +83,12 @@ class MarkerRegression(object): self.num_perm = start_vars['num_perm'] self.control = start_vars['control_marker'] + if start_vars['pair_scan'] == "true": + self.pair_scan = True + else: + self.pair_scan = False + print("pair scan:", self.pair_scan) + print("DOING RQTL GENO") qtl_results = self.run_rqtl_geno() print("qtl_results:", qtl_results) @@ -277,6 +284,7 @@ class MarkerRegression(object): ## Get pointers to some R/qtl functions scanone = ro.r["scanone"] # Map the scanone function + scantwo = ro.r["scantwo"] # Map the scantwo function calc_genoprob = ro.r["calc.genoprob"] # Map the calc.genoprob function read_cross = ro.r["read.cross"] # Map the read.cross function write_cross = ro.r["write.cross"] # Map the write.cross function @@ -300,20 +308,31 @@ class MarkerRegression(object): # Scan for QTLs covar = self.create_covariates(cross_object) - if(r_sum(covar)[0] > 0): - print("Using covariate"); result_data_frame = scanone(cross_object, pheno = "the_pheno", addcovar = covar) - else: - print("No covariates"); result_data_frame = scanone(cross_object, pheno = "the_pheno") - if int(self.num_perm) > 0: # Do permutation (if requested by user) + if self.pair_scan: + if(r_sum(covar)[0] > 0): + print("Using covariate"); result_data_frame = scantwo(cross_object, pheno = "the_pheno", addcovar = covar) + else: + print("No covariates"); result_data_frame = scantwo(cross_object, pheno = "the_pheno") + + print("pair scan results:", result_data_frame) + + return 0 + else: if(r_sum(covar)[0] > 0): - perm_data_frame = scanone(cross_object, pheno_col = "the_pheno", addcovar = covar, n_perm = int(self.num_perm)) + print("Using covariate"); result_data_frame = scanone(cross_object, pheno = "the_pheno", addcovar = covar) else: - perm_data_frame = scanone(cross_object, pheno_col = "the_pheno", n_perm = int(self.num_perm)) + print("No covariates"); result_data_frame = scanone(cross_object, pheno = "the_pheno") + + if int(self.num_perm) > 0: # Do permutation (if requested by user) + if(r_sum(covar)[0] > 0): + perm_data_frame = scanone(cross_object, pheno_col = "the_pheno", addcovar = covar, n_perm = int(self.num_perm)) + else: + perm_data_frame = scanone(cross_object, pheno_col = "the_pheno", n_perm = int(self.num_perm)) - self.process_rqtl_perm_results(perm_data_frame) # Functions that sets the thresholds for the webinterface + self.process_rqtl_perm_results(perm_data_frame) # Functions that sets the thresholds for the webinterface - return self.process_rqtl_results(result_data_frame) + return self.process_rqtl_results(result_data_frame) def add_phenotype(self, cross, pheno_as_string): ro.globalenv["the_cross"] = cross diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py index 62411640..11fd2644 100755 --- a/wqflask/wqflask/show_trait/show_trait.py +++ b/wqflask/wqflask/show_trait/show_trait.py @@ -1310,6 +1310,9 @@ def get_nearest_marker(this_trait, this_db): result = g.db.execute(query).fetchall() print("result:", result) - return result[0][0], result[1][0] + if result == []: + return "", "" + else: + return result[0][0], result[1][0] diff --git a/wqflask/wqflask/templates/show_trait_mapping_tools.html b/wqflask/wqflask/templates/show_trait_mapping_tools.html index d6c7b18e..946dab49 100755 --- a/wqflask/wqflask/templates/show_trait_mapping_tools.html +++ b/wqflask/wqflask/templates/show_trait_mapping_tools.html @@ -80,19 +80,31 @@
+
- -
- + +
+
- -
+ +
+ {% if dataset.type == 'ProbeSet' and this_trait.locus_chr != "" %} + + {% else %} + + {% endif %} +
+
+ +
+ +
- -
- -
- -
-
-
- -
- + +
+
- -
+ +
{% if dataset.type == 'ProbeSet' and this_trait.locus_chr != "" %} {% else %} @@ -144,8 +147,8 @@
- -
+ +
-
- -
- -
- +
+ +
+ + +
+
+
+
+ +
-
{% if dataset.group.species == 'human' %} diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 9110c5a1..e60852d5 100755 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -285,7 +285,8 @@ def marker_regression_page(): 'maf', 'manhattan_plot', 'control_marker', - 'control_marker_db' + 'control_marker_db', + 'pair_scan' ) start_vars = {} -- cgit v1.2.3