diff options
Diffstat (limited to 'wqflask')
-rw-r--r-- | wqflask/utility/gen_geno_ob.py | 15 | ||||
-rw-r--r-- | wqflask/wqflask/marker_regression/display_mapping_results.py | 2 | ||||
-rw-r--r-- | wqflask/wqflask/marker_regression/qtlreaper_mapping.py | 17 | ||||
-rw-r--r-- | wqflask/wqflask/templates/mapping_results.html | 2 | ||||
-rw-r--r-- | wqflask/wqflask/templates/show_trait_statistics.html | 2 |
5 files changed, 27 insertions, 11 deletions
diff --git a/wqflask/utility/gen_geno_ob.py b/wqflask/utility/gen_geno_ob.py index e8780879..44e2722f 100644 --- a/wqflask/utility/gen_geno_ob.py +++ b/wqflask/utility/gen_geno_ob.py @@ -47,20 +47,20 @@ class genotype(object): elif line[0] == "@": label = line.split(":")[0][1:] if label == "name": - self.group = line.split(":")[1] + self.group = line.split(":")[1].strip() elif label == "filler": - if line.split(":")[1] == "yes": + if line.split(":")[1].strip() == "yes": self.filler = True elif label == "type": - self.type = line.split(":")[1] + self.type = line.split(":")[1].strip() elif label == "mat": - self.mat = line.split(":")[1] + self.mat = line.split(":")[1].strip() elif label == "pat": - self.pat = line.split(":")[1] + self.pat = line.split(":")[1].strip() elif label == "het": - self.het = line.split(":")[1] + self.het = line.split(":")[1].strip() elif label == "unk": - self.unk = line.split(":")[1] + self.unk = line.split(":")[1].strip() else: continue elif line[:3] == "Chr": @@ -133,6 +133,7 @@ class Locus(object): start_pos = 4 else: start_pos = 3 + for allele in marker_row[start_pos:]: if allele in geno_table.keys(): self.genotype.append(geno_table[allele]) diff --git a/wqflask/wqflask/marker_regression/display_mapping_results.py b/wqflask/wqflask/marker_regression/display_mapping_results.py index f3755758..a2f9651b 100644 --- a/wqflask/wqflask/marker_regression/display_mapping_results.py +++ b/wqflask/wqflask/marker_regression/display_mapping_results.py @@ -1341,7 +1341,7 @@ class DisplayMappingResults(object): for i, _chr in enumerate(self.genotype): if _chr.name == self.ChrList[self.selectedChr][0]: - for j, _geno in enumerate(_chr[1]): + for j, _geno in enumerate(_chr[1].genotype): plotbxd=0 for item in smd: diff --git a/wqflask/wqflask/marker_regression/qtlreaper_mapping.py b/wqflask/wqflask/marker_regression/qtlreaper_mapping.py index 50e6bd7e..fe216166 100644 --- a/wqflask/wqflask/marker_regression/qtlreaper_mapping.py +++ b/wqflask/wqflask/marker_regression/qtlreaper_mapping.py @@ -1,4 +1,4 @@ -import os, math, string, random, json +import os, math, string, random, json, re from base import webqtlConfig from base.trait import GeneralTrait @@ -105,6 +105,9 @@ def parse_reaper_output(gwa_filename, permu_filename, bootstrap_filename): marker['additive'] = float(line.split("\t")[6]) marker_obs.append(marker) + #ZS: Results have to be reordered because the new reaper returns results sorted alphabetically by chr for some reason, resulting in chr 1 being followed by 10, etc + sorted_indices = natural_sort(marker_obs) + permu_vals = [] if permu_filename: with open("{}{}.txt".format(webqtlConfig.GENERATED_IMAGE_DIR, permu_filename)) as permu_file: @@ -117,6 +120,9 @@ def parse_reaper_output(gwa_filename, permu_filename, bootstrap_filename): for line in bootstrap_file: bootstrap_vals.append(int(line)) + marker_obs = [marker_obs[i] for i in sorted_indices] + bootstrap_vals = [bootstrap_vals[i] for i in sorted_indices] + return marker_obs, permu_vals, bootstrap_vals def run_original_reaper(this_trait, dataset, samples_before, trait_vals, json_data, num_perm, bootCheck, num_bootstrap, do_control, control_marker, manhattan_plot): @@ -210,3 +216,12 @@ def run_original_reaper(this_trait, dataset, samples_before, trait_vals, json_da "cM":reaper_locus.cM, "name":reaper_locus.name, "additive":qtl.additive, "dominance":qtl.dominance} qtl_results.append(qtl) return qtl_results, json_data, perm_output, suggestive, significant, bootstrap_results + +def natural_sort(marker_list): + """ + Function to naturally sort numbers + strings, adopted from user Mark Byers here: https://stackoverflow.com/questions/4836710/does-python-have-a-built-in-function-for-string-natural-sort + Changed to return indices instead of values, though, since the same reordering needs to be applied to bootstrap results + """ + convert = lambda text: int(text) if text.isdigit() else text.lower() + alphanum_key = lambda key: [ convert(c) for c in re.split('([0-9]+)', str(marker_list[key]['chr'])) ] + return sorted(range(len(marker_list)), key = alphanum_key)
\ No newline at end of file diff --git a/wqflask/wqflask/templates/mapping_results.html b/wqflask/wqflask/templates/mapping_results.html index 1fc792d8..8422b1d2 100644 --- a/wqflask/wqflask/templates/mapping_results.html +++ b/wqflask/wqflask/templates/mapping_results.html @@ -144,7 +144,7 @@ <span style="color:red;">*</span> <br> <input type="checkbox" name="showGenes" class="checkbox" style="display: inline; margin-top: 0px;" {% if geneChecked|upper == "ON" %}value="ON" checked{% endif %}> <span style="font-size: 12px;">Gene Track </span> <span style="color:red;">*</span><br> - {% if plotScale != "morgan" and mapping_method != "gemma" and mapping_method != "plink" %} + {% if plotScale != "morgan" %} <input type="checkbox" name="haplotypeAnalystCheck" class="checkbox" style="display: inline; margin-top: 0px;" {% if haplotypeAnalystChecked|upper == "ON" %}value="ON" checked{% endif %}> <span style="font-size: 12px;">Haplotype Analyst </span> <span style="color:red;">*</span><br> {% endif %} <input type="checkbox" name="viewLegend" class="checkbox" style="display: inline; margin-top: 0px;" {% if legendChecked|upper == "ON" %}value="ON" checked{% endif %}> <span style="font-size: 12px;">Legend </span> diff --git a/wqflask/wqflask/templates/show_trait_statistics.html b/wqflask/wqflask/templates/show_trait_statistics.html index 1093e1bb..4653b398 100644 --- a/wqflask/wqflask/templates/show_trait_statistics.html +++ b/wqflask/wqflask/templates/show_trait_statistics.html @@ -70,7 +70,7 @@ </select> </div> {% endif %} - <div id="update_bar_chart" class="btn-group"> + <div id="update_bar_chart" class="btn-group" style="margin-bottom: 5px;"> <button type="button" class="btn btn-default sort_by_name" value="name"> <i class="icon-resize-horizontal"></i> Sort By Name </button> |