From a2d45b9c5593e4ecf37850db69d3bcd8c673419d Mon Sep 17 00:00:00 2001 From: Lei Yan Date: Sat, 29 Oct 2016 05:25:37 +0000 Subject: For those case that we have multiple genotypes we would like to add a selector. --- wqflask/base/data_set.py | 6 +++- .../wqflask/marker_regression/marker_regression.py | 3 ++ wqflask/wqflask/show_trait/show_trait.py | 12 ++++++++ .../new/javascript/show_trait_mapping_tools.js | 3 ++ .../wqflask/templates/marker_regression_gn1.html | 3 ++ wqflask/wqflask/templates/show_trait.html | 1 + .../templates/show_trait_mapping_tools.html | 36 ++++++++++++++++++++++ wqflask/wqflask/views.py | 1 + 8 files changed, 64 insertions(+), 1 deletion(-) (limited to 'wqflask') diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py index fddfce58..918932fa 100644 --- a/wqflask/base/data_set.py +++ b/wqflask/base/data_set.py @@ -278,6 +278,7 @@ class DatasetGroup(object): self.incparentsf1 = False self.allsamples = None self._datasets = None + self.genofile = None def get_specified_markers(self, markers = []): self.markers = HumanMarkers(self.name, markers) @@ -408,7 +409,10 @@ class DatasetGroup(object): genotype_1 = reaper.Dataset() # reaper barfs on unicode filenames, so here we ensure it's a string - full_filename = str(locate(self.name+'.geno','genotype')) + if self.genofile: + full_filename = str(locate(self.genofile, 'genotype')) + else: + full_filename = str(locate(self.name + '.geno', 'genotype')) genotype_1.read(full_filename) if genotype_1.type == "group" and self.parlist: diff --git a/wqflask/wqflask/marker_regression/marker_regression.py b/wqflask/wqflask/marker_regression/marker_regression.py index 37ee42a7..543eeede 100644 --- a/wqflask/wqflask/marker_regression/marker_regression.py +++ b/wqflask/wqflask/marker_regression/marker_regression.py @@ -165,6 +165,7 @@ class MarkerRegression(object): self.mapping_scale = "morgan" self.control_marker = start_vars['control_marker'] self.do_control = start_vars['do_control'] + self.dataset.group.genofile = start_vars['genofile'] self.method = start_vars['mapmethod_rqtl_geno'] self.model = start_vars['mapmodel_rqtl_geno'] if start_vars['pair_scan'] == "true": @@ -200,12 +201,14 @@ class MarkerRegression(object): self.control_marker = start_vars['control_marker'] self.do_control = start_vars['do_control'] + self.dataset.group.genofile = start_vars['genofile'] logger.info("Running qtlreaper") results = self.gen_reaper_results() elif self.mapping_method == "plink": results = self.run_plink() elif self.mapping_method == "pylmm": logger.debug("RUNNING PYLMM") + self.dataset.group.genofile = start_vars['genofile'] if self.num_perm > 0: self.run_permutations(str(temp_uuid)) results = self.gen_data(str(temp_uuid)) diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py index d9617c7c..ce8b2ced 100644 --- a/wqflask/wqflask/show_trait/show_trait.py +++ b/wqflask/wqflask/show_trait/show_trait.py @@ -4,6 +4,7 @@ import string import os import cPickle import uuid +import json as json #import pyXLWriter as xl from collections import OrderedDict @@ -24,6 +25,7 @@ from basicStatistics import BasicStatisticsFunctions from pprint import pformat as pf from utility.tools import flat_files, flat_file_exists +from utility.tools import get_setting from utility.logger import getLogger logger = getLogger(__name__ ) @@ -175,6 +177,7 @@ class ShowTrait(object): else: return False + self.genofiles = get_genofiles(self.this_trait) self.use_plink_gemma = check_plink_gemma() self.use_pylmm_rqtl = check_pylmm_rqtl() @@ -1260,6 +1263,15 @@ def get_nearest_marker(this_trait, this_db): else: return result[0][0] #return result[0][0], result[1][0] + +def get_genofiles(this_trait): + jsonfile = "%s/%s.json" % (get_setting('GENOFILE_META'), this_trait.dataset.group.name) + try: + f = open(jsonfile) + except: + return None + jsondata = json.load(f) + return jsondata['genofile'] def get_trait_table_width(sample_groups): table_width = 35 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 e9db0a12..e7df9228 100644 --- a/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js +++ b/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js @@ -168,6 +168,7 @@ //$("#progress_bar_container").modal(); url = "/marker_regression"; $('input[name=method]').val("pylmm"); + $('input[name=genofile').val($('#genofile_pylmm').val()); $('input[name=num_perm]').val($('input[name=num_perm_pylmm]').val()); $('input[name=manhattan_plot]').val($('input[name=manhattan_plot_pylmm]:checked').val()); form_data = $('#trait_data_form').serialize(); @@ -183,6 +184,7 @@ //$("#progress_bar_container").modal(); url = "/marker_regression"; $('input[name=method]').val("rqtl_geno"); + $('input[name=genofile').val($('#genofile_rqtl_geno').val()); $('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()); @@ -242,6 +244,7 @@ //$("#progress_bar_container").modal(); url = "/marker_regression"; $('input[name=method]').val("reaper"); + $('input[name=genofile').val($('#genofile_reaper').val()); $('input[name=num_perm]').val($('input[name=num_perm_reaper]').val()); $('input[name=control_marker]').val($('input[name=control_reaper]').val()); $('input[name=do_control]').val($('input[name=do_control_reaper]:checked').val()); diff --git a/wqflask/wqflask/templates/marker_regression_gn1.html b/wqflask/wqflask/templates/marker_regression_gn1.html index 7454b650..c6112edb 100644 --- a/wqflask/wqflask/templates/marker_regression_gn1.html +++ b/wqflask/wqflask/templates/marker_regression_gn1.html @@ -14,6 +14,9 @@ + {% if mapping_method == "reaper" %} + + {% endif %} {% for sample in samples %} diff --git a/wqflask/wqflask/templates/show_trait.html b/wqflask/wqflask/templates/show_trait.html index 59e0185e..d76e8af8 100644 --- a/wqflask/wqflask/templates/show_trait.html +++ b/wqflask/wqflask/templates/show_trait.html @@ -39,6 +39,7 @@ +
diff --git a/wqflask/wqflask/templates/show_trait_mapping_tools.html b/wqflask/wqflask/templates/show_trait_mapping_tools.html index 0f293942..149ad864 100644 --- a/wqflask/wqflask/templates/show_trait_mapping_tools.html +++ b/wqflask/wqflask/templates/show_trait_mapping_tools.html @@ -32,6 +32,18 @@ {% if use_pylmm_rqtl and not use_plink_gemma and dataset.group.species != "human" %}
+ {% if genofiles and genofiles|length>0 %} +
+ +
+ +
+
+ {% endif %}
@@ -114,6 +126,18 @@
+ {% if genofiles and genofiles|length>0 %} +
+ +
+ +
+
+ {% endif %}
@@ -169,6 +193,18 @@
+ {% if genofiles and genofiles|length>0 %} +
+ +
+ +
+
+ {% endif %}
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 33fab84d..406f8930 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -452,6 +452,7 @@ def marker_regression_page(): 'control_marker', 'control_marker_db', 'do_control', + 'genofile', 'pair_scan', 'startMb', 'endMb', -- cgit v1.2.3 From a5feb593a1fb541278ec213909c4e37239934796 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Mon, 31 Oct 2016 20:30:22 +0000 Subject: Fix spacing --- wqflask/wqflask/marker_regression/marker_regression.py | 2 +- wqflask/wqflask/show_trait/show_trait.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/marker_regression/marker_regression.py b/wqflask/wqflask/marker_regression/marker_regression.py index 4d622f21..d9dbd0da 100644 --- a/wqflask/wqflask/marker_regression/marker_regression.py +++ b/wqflask/wqflask/marker_regression/marker_regression.py @@ -201,7 +201,7 @@ class MarkerRegression(object): self.control_marker = start_vars['control_marker'] self.do_control = start_vars['do_control'] - self.dataset.group.genofile = start_vars['genofile'] + self.dataset.group.genofile = start_vars['genofile'] logger.info("Running qtlreaper") results, self.json_data, self.perm_output, self.suggestive, self.significant, self.bootstrap_results = qtlreaper_mapping.gen_reaper_results(self.this_trait, self.dataset, diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py index ce8b2ced..9a695d8e 100644 --- a/wqflask/wqflask/show_trait/show_trait.py +++ b/wqflask/wqflask/show_trait/show_trait.py @@ -1263,7 +1263,7 @@ def get_nearest_marker(this_trait, this_db): else: return result[0][0] #return result[0][0], result[1][0] - + def get_genofiles(this_trait): jsonfile = "%s/%s.json" % (get_setting('GENOFILE_META'), this_trait.dataset.group.name) try: -- cgit v1.2.3 From b1a255c0990641fb4b4b8682eae3589bf0d3abb3 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Mon, 31 Oct 2016 21:02:53 +0000 Subject: Use existing GENODIR - the metadata can be stored there, next to the .geno files. --- wqflask/wqflask/show_trait/show_trait.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py index 9a695d8e..8aff5482 100644 --- a/wqflask/wqflask/show_trait/show_trait.py +++ b/wqflask/wqflask/show_trait/show_trait.py @@ -1265,7 +1265,7 @@ def get_nearest_marker(this_trait, this_db): #return result[0][0], result[1][0] def get_genofiles(this_trait): - jsonfile = "%s/%s.json" % (get_setting('GENOFILE_META'), this_trait.dataset.group.name) + jsonfile = "%s/%s.json" % (webqtlConfig.GENODIR, this_trait.dataset.group.name) try: f = open(jsonfile) except: -- cgit v1.2.3