From 5e8934baf749b8fee396813637035fbb7ece5b0e Mon Sep 17 00:00:00 2001 From: zsloan Date: Wed, 6 Jan 2016 20:11:18 +0000 Subject: Single chromosome view now works for mapping page using GN1's image code Removed loading bar that appeared on show trait page since it didn't work with GN1 mapping (which opens in a new page) --- .../wqflask/marker_regression/marker_regression.py | 11 ++++++- .../marker_regression/marker_regression_gn1.py | 18 ++++++++---- .../new/javascript/show_trait_mapping_tools.js | 2 +- .../wqflask/templates/marker_regression_gn1.html | 34 ++++++++++++++++------ wqflask/wqflask/views.py | 1 + 5 files changed, 50 insertions(+), 16 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/marker_regression/marker_regression.py b/wqflask/wqflask/marker_regression/marker_regression.py index 05bb5b60..c396b14b 100755 --- a/wqflask/wqflask/marker_regression/marker_regression.py +++ b/wqflask/wqflask/marker_regression/marker_regression.py @@ -52,6 +52,8 @@ class MarkerRegression(object): #tempdata = temp_data.TempData(temp_uuid) + self.temp_uuid = temp_uuid #needed to pass temp_uuid to gn1 mapping code (marker_regression_gn1.py) + self.json_data = {} self.json_data['lodnames'] = ['lod.hk'] @@ -76,6 +78,11 @@ class MarkerRegression(object): self.score_type = "LRS" #ZS: LRS or LOD self.mapping_scale = "physic" self.num_perm = 0 + + #ZS: This is passed to GN1 code for single chr mapping + self.selected_chr = -1 + if "selected_chr" in start_vars: + self.selected_chr = int(start_vars['selected_chr']) self.dataset.group.get_markers() if self.mapping_method == "gemma": @@ -720,7 +727,9 @@ class MarkerRegression(object): def gen_data(self, temp_uuid): """Generates p-values for each marker""" - pheno_vector = np.array([val == "x" and np.nan or float(val) for val in self.vals]) + + print("self.vals is:", self.vals) + pheno_vector = np.array([(val == "x" or val == "") and np.nan or float(val) for val in self.vals]) #lmm_uuid = str(uuid.uuid4()) diff --git a/wqflask/wqflask/marker_regression/marker_regression_gn1.py b/wqflask/wqflask/marker_regression/marker_regression_gn1.py index 1da98c63..a0033bd2 100644 --- a/wqflask/wqflask/marker_regression/marker_regression_gn1.py +++ b/wqflask/wqflask/marker_regression/marker_regression_gn1.py @@ -172,10 +172,16 @@ class MarkerRegression(object): #helper_functions.get_species_dataset_trait(self, start_vars) + self.temp_uuid = start_vars['temp_uuid'] + self.dataset = start_vars['dataset'] self.this_trait = start_vars['this_trait'] self.species = start_vars['species'] + + self.vals = start_vars['vals'] #Needed to put into form for when it is resubmitted for single chr views or remapping + self.mapping_method = start_vars['mapping_method'] #Needing for form submission when doing single chr mapping or remapping after changing options + self.js_data = start_vars['js_data'] #ZS: Think I can just get all this from dataset object now @@ -226,9 +232,9 @@ class MarkerRegression(object): #self.controlLocus = fd.formdata.getvalue('controlLocus', '') #try: - # self.selectedChr = int(fd.formdata.getvalue('chromosomes', "-1")) + self.selectedChr = int(start_vars['selected_chr']) #except: - self.selectedChr = -1 + # self.selectedChr = -1 #whether include parents and F1 for InbredSet #fd.parentsf14regression = fd.formdata.getvalue('parentsf14regression') @@ -1921,10 +1927,12 @@ class MarkerRegression(object): #startPosX = xLeftOffset thisLRSColor = self.colorCollection[0] - if qtlresult['chr'] != previous_chr: + if qtlresult['chr'] != previous_chr and self.selectedChr == -1: previous_chr = qtlresult['chr'] previous_chr_as_int += 1 + print("ChrLengthDistList:", self.ChrLengthDistList) + newStartPosX = (self.ChrLengthDistList[previous_chr_as_int - 1]+self.GraphInterval)*plotXScale if newStartPosX != oldStartPosX: startPosX += newStartPosX @@ -1933,7 +1941,7 @@ class MarkerRegression(object): #startPosX += (self.ChrLengthDistList[j]+self.GraphInterval)*plotXScale #for j, _chr in enumerate(self.genotype): - if 1 == 1: + if self.selectedChr == -1 or qtlresult['chr'] == self.selectedChr: #LRSCoordXY = [] #AdditiveCoordXY = [] #DominanceCoordXY = [] @@ -2120,7 +2128,7 @@ class MarkerRegression(object): COORDS = "%d,%d,%d,%d" %(chrStartPix, yTopOffset, chrEndPix,yTopOffset +20) #add by NL 09-03-2010 - HREF = "javascript placeholder" + HREF = "javascript:chrView(%d,%s);" % (i,self.ChrLengthMbList) #HREF = "javascript:changeView(%d,%s);" % (i,self.ChrLengthMbList) Areas = HT.Area(shape='rect',coords=COORDS,href=HREF) gifmap.areas.append(Areas) 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 3834e60b..721752dd 100755 --- a/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js +++ b/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js @@ -165,7 +165,7 @@ $("#pylmm_compute").on("click", (function(_this) { return function() { var form_data, url; - $("#progress_bar_container").modal(); + //$("#progress_bar_container").modal(); url = "/marker_regression"; $('input[name=method]').val("pylmm"); $('input[name=num_perm]').val($('input[name=num_perm_pylmm]').val()); diff --git a/wqflask/wqflask/templates/marker_regression_gn1.html b/wqflask/wqflask/templates/marker_regression_gn1.html index e6bc2d65..f5bec6ea 100644 --- a/wqflask/wqflask/templates/marker_regression_gn1.html +++ b/wqflask/wqflask/templates/marker_regression_gn1.html @@ -6,22 +6,30 @@ {% endblock %} {% from "base_macro.html" import header %} {% block content %} - {{ header("Mapping", + {{ header("Whole Genome Mapping Results", '{}: {}'.format(this_trait.name, this_trait.description_fmt)) }}