From a6234c3d2d17273062ec206b7146949c1e64a5ba Mon Sep 17 00:00:00 2001 From: zsloan Date: Thu, 23 Apr 2020 14:11:53 -0500 Subject: Fixed issue where covariates weren't being passed when zooming in or remapping Added loading paage for zooming/remapping Added temporary option for checking mapping scale in .geno files --- .../marker_regression/display_mapping_results.py | 3 +++ wqflask/wqflask/marker_regression/rqtl_mapping.py | 29 +++++++++++++++++++--- wqflask/wqflask/marker_regression/run_mapping.py | 9 ++++--- wqflask/wqflask/templates/mapping_results.html | 22 ++++++++++++---- wqflask/wqflask/user_login.py | 3 --- wqflask/wqflask/views.py | 20 +++++++++------ 6 files changed, 64 insertions(+), 22 deletions(-) diff --git a/wqflask/wqflask/marker_regression/display_mapping_results.py b/wqflask/wqflask/marker_regression/display_mapping_results.py index a7e11738..2a53b60e 100644 --- a/wqflask/wqflask/marker_regression/display_mapping_results.py +++ b/wqflask/wqflask/marker_regression/display_mapping_results.py @@ -166,6 +166,7 @@ class DisplayMappingResults(object): #Needing for form submission when doing single chr mapping or remapping after changing options self.samples = start_vars['samples'] self.vals = start_vars['vals'] + self.transform = start_vars['transform'] self.mapping_method = start_vars['mapping_method'] self.mapping_results_path = start_vars['mapping_results_path'] if self.mapping_method == "rqtl_geno": @@ -233,6 +234,8 @@ class DisplayMappingResults(object): self.covariates = start_vars['covariates'] if 'maf' in start_vars.keys(): self.maf = start_vars['maf'] + else: + self.maf = "" if 'output_files' in start_vars.keys(): self.output_files = start_vars['output_files'] if 'use_loco' in start_vars.keys() and self.mapping_method == "gemma": diff --git a/wqflask/wqflask/marker_regression/rqtl_mapping.py b/wqflask/wqflask/marker_regression/rqtl_mapping.py index aae8e602..e1aa290b 100644 --- a/wqflask/wqflask/marker_regression/rqtl_mapping.py +++ b/wqflask/wqflask/marker_regression/rqtl_mapping.py @@ -36,7 +36,10 @@ def run_rqtl_geno(vals, samples, dataset, method, model, permCheck, num_perm, pe generate_cross_from_geno(dataset) GENOtoCSVR = ro.r["GENOtoCSVR"] # Map the local GENOtoCSVR function crossfilelocation = TMPDIR + crossname + ".cross" - genofilelocation = locate(dataset.group.genofile, "genotype") + if dataset.group.genofile: + genofilelocation = locate(dataset.group.genofile, "genotype") + else: + genofilelocation = locate(dataset.group.name + ".geno", "genotype") cross_object = GENOtoCSVR(genofilelocation, crossfilelocation) # TODO: Add the SEX if that is available if manhattan_plot: @@ -91,9 +94,11 @@ def run_rqtl_geno(vals, samples, dataset, method, model, permCheck, num_perm, pe perm_data_frame = scanone(cross_object, pheno_col = "the_pheno", n_perm = num_perm, model=model, method=method) perm_output, suggestive, significant = process_rqtl_perm_results(num_perm, perm_data_frame) # Functions that sets the thresholds for the webinterface - return perm_output, suggestive, significant, process_rqtl_results(result_data_frame, dataset.group.species) + the_scale = check_mapping_scale(genofilelocation) + return perm_output, suggestive, significant, process_rqtl_results(result_data_frame, dataset.group.species), the_scale else: - return process_rqtl_results(result_data_frame, dataset.group.species) + the_scale = check_mapping_scale(genofilelocation) + return process_rqtl_results(result_data_frame, dataset.group.species), the_scale def generate_cross_from_rdata(dataset): rdata_location = locate(dataset.group.name + ".RData", "genotype/rdata") @@ -286,4 +291,20 @@ def process_rqtl_results(result, species_name): # TODO: how to make this marker['lod_score'] = output[i][2] qtl_results.append(marker) - return qtl_results \ No newline at end of file + return qtl_results + +def check_mapping_scale(genofile_location): + scale = "physic" + with open(genofile_location, "r") as geno_fh: + for line in geno_fh: + if line[0] == "@" or line[0] == "#": + + if "@scale" in line: + scale = line.split(":")[1].strip() + break + else: + continue + else: + break + + return scale \ No newline at end of file diff --git a/wqflask/wqflask/marker_regression/run_mapping.py b/wqflask/wqflask/marker_regression/run_mapping.py index e191902c..589be702 100644 --- a/wqflask/wqflask/marker_regression/run_mapping.py +++ b/wqflask/wqflask/marker_regression/run_mapping.py @@ -150,6 +150,10 @@ class RunMapping(object): self.suggestive = "" self.significant = "" self.pair_scan = False # Initializing this since it is checked in views to determine which template to use + if 'transform' in start_vars: + self.transform = start_vars['transform'] + else: + self.transform = "" self.score_type = "LRS" #ZS: LRS or LOD self.mapping_scale = "physic" self.num_perm = 0 @@ -241,7 +245,6 @@ class RunMapping(object): perm_strata = get_perm_strata(self.this_trait, primary_samples, self.categorical_vars, self.samples) self.score_type = "LOD" - #self.mapping_scale = "morgan" self.control_marker = start_vars['control_marker'] self.do_control = start_vars['do_control'] if 'mapmethod_rqtl_geno' in start_vars: @@ -252,9 +255,9 @@ class RunMapping(object): #if start_vars['pair_scan'] == "true": # self.pair_scan = True if self.permCheck and self.num_perm > 0: - self.perm_output, self.suggestive, self.significant, results = rqtl_mapping.run_rqtl_geno(self.vals, self.samples, self.dataset, self.method, self.model, self.permCheck, self.num_perm, perm_strata, self.do_control, self.control_marker, self.manhattan_plot, self.pair_scan, self.covariates) + self.perm_output, self.suggestive, self.significant, results, self.mapping_scale = rqtl_mapping.run_rqtl_geno(self.vals, self.samples, self.dataset, self.method, self.model, self.permCheck, self.num_perm, perm_strata, self.do_control, self.control_marker, self.manhattan_plot, self.pair_scan, self.covariates) else: - results = rqtl_mapping.run_rqtl_geno(self.vals, self.samples, self.dataset, self.method, self.model, self.permCheck, self.num_perm, perm_strata, self.do_control, self.control_marker, self.manhattan_plot, self.pair_scan, self.covariates) + results, self.mapping_scale = rqtl_mapping.run_rqtl_geno(self.vals, self.samples, self.dataset, self.method, self.model, self.permCheck, self.num_perm, perm_strata, self.do_control, self.control_marker, self.manhattan_plot, self.pair_scan, self.covariates) elif self.mapping_method == "reaper": if "startMb" in start_vars: #ZS: Check if first time page loaded, so it can default to ON if "additiveCheck" in start_vars: diff --git a/wqflask/wqflask/templates/mapping_results.html b/wqflask/wqflask/templates/mapping_results.html index ba0ebef9..7e05be18 100644 --- a/wqflask/wqflask/templates/mapping_results.html +++ b/wqflask/wqflask/templates/mapping_results.html @@ -36,7 +36,7 @@ {% endfor %} - + @@ -45,10 +45,14 @@ - + + + + +