diff options
author | zsloan | 2020-04-23 14:11:53 -0500 |
---|---|---|
committer | zsloan | 2020-04-23 14:11:53 -0500 |
commit | a6234c3d2d17273062ec206b7146949c1e64a5ba (patch) | |
tree | 7d9df796109dcda01907cac39761b7a2f1e98b36 | |
parent | 3409cba77edf79f0f2e088b07a17f3b6df33a445 (diff) | |
download | genenetwork2-a6234c3d2d17273062ec206b7146949c1e64a5ba.tar.gz |
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
-rw-r--r-- | wqflask/wqflask/marker_regression/display_mapping_results.py | 3 | ||||
-rw-r--r-- | wqflask/wqflask/marker_regression/rqtl_mapping.py | 29 | ||||
-rw-r--r-- | wqflask/wqflask/marker_regression/run_mapping.py | 9 | ||||
-rw-r--r-- | wqflask/wqflask/templates/mapping_results.html | 22 | ||||
-rw-r--r-- | wqflask/wqflask/user_login.py | 3 | ||||
-rw-r--r-- | 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 @@ <input type="hidden" name="value:{{ sample }}" value="{{ vals[loop.index - 1] }}"> {% endfor %} <input type="hidden" name="num_vals" value="{{ n_samples }}"> - <input type="hidden" name="maf"> + <input type="hidden" name="maf" value="{{ maf }}"> <input type="hidden" name="use_loco" value="{{ use_loco }}"> <input type="hidden" name="selected_chr" value="{{ selectedChr }}"> <input type="hidden" name="manhattan_plot" value="{{ manhattan_plot }}"> @@ -45,10 +45,14 @@ <input type="hidden" name="num_bootstrap" value="{{ nboot }}"> <input type="hidden" name="do_control" value="{{ doControl }}"> <input type="hidden" name="control_marker" value="{{ controlLocus }}"> - <input type="hidden" name="covariates" values="{{ covariates }}"> + <input type="hidden" name="covariates" value="{{ covariates }}"> <input type="hidden" name="mapmethod_rqtl_geno" value="{{ mapmethod_rqtl_geno }}"> <input type="hidden" name="mapmodel_rqtl_geno" value="{{ mapmodel_rqtl_geno }}"> <input type="hidden" name="pair_scan" value="{{ pair_scan }}"> + <input type="hidden" name="transform" value="{{ transform }}"> + <input type="hidden" name="tool_used" value="Mapping"> + <input type="hidden" name="wanted_inputs" value=""> + <input type="hidden" name="form_url" value="/run_mapping"> <div class="container"> <div class="col-xs-5"> @@ -422,11 +426,19 @@ }); + var mapping_input_list = ['temp_uuid', 'trait_id', 'dataset', 'tool_used', 'form_url', 'method', 'transform', 'trimmed_markers', 'selected_chr', 'chromosomes', 'mapping_scale', + 'score_type', 'suggestive', 'significant', 'num_perm', 'permCheck', 'perm_output', 'perm_strata', 'categorical_vars', 'num_bootstrap', 'bootCheck', 'bootstrap_results', + 'LRSCheck', 'covariates', 'maf', 'use_loco', 'manhattan_plot', 'control_marker', 'control_marker_db', 'do_control', 'genofile', + 'pair_scan', 'startMb', 'endMb', 'graphWidth', 'lrsMax', 'additiveCheck', 'showSNP', 'showGenes', 'viewLegend', 'haplotypeAnalystCheck', + 'mapmethod_rqtl_geno', 'mapmodel_rqtl_geno', 'temp_trait', 'group', 'species', 'reaper_version', 'primary_samples', 'num_vals'] + + $('input[name=wanted_inputs]').val(mapping_input_list.join(",")); + chrView = function(this_chr, chr_mb_list) { $('input[name=selected_chr]').val(this_chr) $('input[name=chr_mb_list]').val(chr_mb_list) - $('#marker_regression_form').attr('action', '/run_mapping'); + $('#marker_regression_form').attr('action', '/loading'); return $('#marker_regression_form').submit(); }; @@ -436,13 +448,13 @@ $('input[name=endMb]').val(end_mb) //$('input[name=mb_range]').val(start_mb + "," + end_mb) - $('#marker_regression_form').attr('action', '/run_mapping'); + $('#marker_regression_form').attr('action', '/loading'); return $('#marker_regression_form').submit(); }; remap = function() { $('input[name=selected_chr]').val($('select[name=chromosomes]').val()); - $('#marker_regression_form').attr('action', '/run_mapping'); + $('#marker_regression_form').attr('action', '/loading'); return $('#marker_regression_form').submit(); }; diff --git a/wqflask/wqflask/user_login.py b/wqflask/wqflask/user_login.py index 40d9925c..edd272c2 100644 --- a/wqflask/wqflask/user_login.py +++ b/wqflask/wqflask/user_login.py @@ -42,9 +42,6 @@ def basic_info(): user_agent = request.headers.get('User-Agent')) def encode_password(pass_gen_fields, unencrypted_password): - logger.debug("THE TYPE:", type(pass_gen_fields)) - logger.debug("pass_gen_fields:", pass_gen_fields) - logger.debug("hashfunc:", pass_gen_fields['hashfunc']) hashfunc = getattr(hashlib, pass_gen_fields['hashfunc']) salt = base64.b64decode(pass_gen_fields['salt']) diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 76857650..e351a2d4 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -583,18 +583,23 @@ def loading_page(): if key in wanted or key.startswith(('value:')): start_vars[key] = value - if 'primary_samples' in start_vars: - samples = start_vars['primary_samples'].split(",") - for sample in samples: - value = start_vars.get('value:' + sample) - if value != "x": - num_vals += 1 + if 'num_vals' in start_vars: + num_vals = int(start_vars['num_vals']) + else: + if 'primary_samples' in start_vars: + samples = start_vars['primary_samples'].split(",") + for sample in samples: + value = start_vars.get('value:' + sample) + if value != "x": + num_vals += 1 start_vars['num_vals'] = num_vals + start_vars['wanted_inputs'] = initial_start_vars['wanted_inputs'] start_vars_container['start_vars'] = start_vars else: start_vars_container['start_vars'] = initial_start_vars + rendered_template = render_template("loading.html", **start_vars_container) return rendered_template @@ -658,7 +663,8 @@ def mapping_results_page(): 'mapmodel_rqtl_geno', 'temp_trait', 'reaper_version', - 'num_vals' + 'num_vals', + 'transform' ) start_vars = {} for key, value in initial_start_vars.iteritems(): |