From 9c9ab3fc175306e4ed9b67facdcd65bbe63066eb Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Mon, 14 Jul 2014 16:38:22 +0000 Subject: Made interval map zoom look better Started creating probability plot for show trait page Added outlier detection message when user does mapping --- .../correlation_matrix/.show_corr_matrix.py.swn | Bin 16384 -> 0 bytes .../wqflask/marker_regression/marker_regression.py | 7 + wqflask/wqflask/show_trait/SampleList.py | 11 + wqflask/wqflask/show_trait/show_trait.py | 1 + wqflask/wqflask/static/new/css/panelutil.css | 4 +- wqflask/wqflask/static/new/css/show_trait.css | 3 + .../new/javascript/create_interval_map.coffee | 26 +- .../static/new/javascript/create_interval_map.js | 14 + .../new/javascript/create_manhattan_plot.coffee | 21 + .../static/new/javascript/create_manhattan_plot.js | 14 + .../static/new/javascript/dataset_select_menu.js | 137 ------- .../new/javascript/draw_probability_plot.coffee | 37 ++ .../wqflask/static/new/javascript/lod_chart.coffee | 12 +- wqflask/wqflask/static/new/javascript/lod_chart.js | 12 +- .../static/new/javascript/manhattan_plot.coffee | 97 +---- .../static/new/javascript/manhattan_plot.js | 10 +- .../static/new/javascript/probability_plot.coffee | 424 +++++++++++++++++++++ .../static/new/javascript/show_trait.coffee | 4 +- .../wqflask/static/new/javascript/show_trait.js | 4 +- .../new/javascript/show_trait_mapping_tools.coffee | 194 ++++++---- .../new/javascript/show_trait_mapping_tools.js | 127 ++---- .../packages/DataTables/css/jquery.dataTables.css | 2 + .../wqflask/templates/corr_scatter_plot_old.html | 63 --- wqflask/wqflask/templates/interval_mapping.html | 7 +- wqflask/wqflask/templates/marker_regression.html | 7 +- .../wqflask/templates/marker_regression_old.html | 106 ++++++ wqflask/wqflask/templates/show_trait.html | 3 +- .../templates/show_trait_mapping_tools.html | 1 + wqflask/wqflask/views.py | 12 + 29 files changed, 900 insertions(+), 460 deletions(-) delete mode 100755 wqflask/wqflask/correlation_matrix/.show_corr_matrix.py.swn create mode 100644 wqflask/wqflask/static/new/css/show_trait.css delete mode 100755 wqflask/wqflask/static/new/javascript/dataset_select_menu.js create mode 100644 wqflask/wqflask/static/new/javascript/draw_probability_plot.coffee create mode 100644 wqflask/wqflask/static/new/javascript/probability_plot.coffee delete mode 100755 wqflask/wqflask/templates/corr_scatter_plot_old.html create mode 100644 wqflask/wqflask/templates/marker_regression_old.html diff --git a/wqflask/wqflask/correlation_matrix/.show_corr_matrix.py.swn b/wqflask/wqflask/correlation_matrix/.show_corr_matrix.py.swn deleted file mode 100755 index fd928439..00000000 Binary files a/wqflask/wqflask/correlation_matrix/.show_corr_matrix.py.swn and /dev/null differ diff --git a/wqflask/wqflask/marker_regression/marker_regression.py b/wqflask/wqflask/marker_regression/marker_regression.py index 30c6453c..0bee5994 100755 --- a/wqflask/wqflask/marker_regression/marker_regression.py +++ b/wqflask/wqflask/marker_regression/marker_regression.py @@ -65,6 +65,8 @@ class MarkerRegression(object): self.dataset.group.get_markers() if self.mapping_method == "gemma": qtl_results = self.run_gemma() + elif self.mapping_method == "rqtl": + qtl_results = self.run_rqtl() elif self.mapping_method == "plink": qtl_results = self.run_plink() #print("qtl_results:", pf(qtl_results)) @@ -184,6 +186,11 @@ class MarkerRegression(object): # # + #def run_rqtl(self): + # os.chdir("/home/zas1024/plink") + # + + def run_plink(self): os.chdir("/home/zas1024/plink") diff --git a/wqflask/wqflask/show_trait/SampleList.py b/wqflask/wqflask/show_trait/SampleList.py index 9cd7d895..6be6ddcd 100755 --- a/wqflask/wqflask/show_trait/SampleList.py +++ b/wqflask/wqflask/show_trait/SampleList.py @@ -6,6 +6,8 @@ from base import webqtlCaseData from utility import webqtlUtil, Plot, Bunch from base.trait import GeneralTrait +import numpy as np +from scipy import stats from pprint import pformat as pf class SampleList(object): @@ -71,6 +73,15 @@ class SampleList(object): def __repr__(self): return " --> %s" % (pf(self.__dict__)) + def get_z_scores(self): + values = [sample.value for sample in self.sample_list if sample.value != None] + numpy_array = np.array(values) + z_scores = stats.zscore(numpy_array) + + for i, sample in enumerate(self.sample_list): + if sample.value: + sample.z_score = z_scores[i] + def do_outliers(self): values = [sample.value for sample in self.sample_list if sample.value != None] upper_bound, lower_bound = Plot.find_outliers(values) diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py index 670a1188..a7dd59d5 100755 --- a/wqflask/wqflask/show_trait/show_trait.py +++ b/wqflask/wqflask/show_trait/show_trait.py @@ -97,6 +97,7 @@ class ShowTrait(object): hddn['trait_id'] = self.trait_id hddn['dataset'] = self.dataset.name + hddn['use_outliers'] = False hddn['method'] = "pylmm" hddn['mapping_display_all'] = True hddn['suggestive'] = 0 diff --git a/wqflask/wqflask/static/new/css/panelutil.css b/wqflask/wqflask/static/new/css/panelutil.css index 35e40db7..ff363e49 100644 --- a/wqflask/wqflask/static/new/css/panelutil.css +++ b/wqflask/wqflask/static/new/css/panelutil.css @@ -30,7 +30,7 @@ div.qtlcharts .x.axis text.title { fill: slateblue; } -div.qtlcharts line.axis.grid { +/*div.qtlcharts line.axis.grid { fill: none; stroke-width: 1; pointer-events: none; @@ -48,7 +48,7 @@ div.qtlcharts line.y.axis.grid { div.qtlcharts .extent { fill: #cac; opacity: 0.3; -} +}*/ div.qtlcharts circle.selected { fill: hotpink; diff --git a/wqflask/wqflask/static/new/css/show_trait.css b/wqflask/wqflask/static/new/css/show_trait.css new file mode 100644 index 00000000..9dcbfce9 --- /dev/null +++ b/wqflask/wqflask/static/new/css/show_trait.css @@ -0,0 +1,3 @@ +tr .outlier { + background-color: #ffff99; +} \ No newline at end of file diff --git a/wqflask/wqflask/static/new/javascript/create_interval_map.coffee b/wqflask/wqflask/static/new/javascript/create_interval_map.coffee index cacba03e..2b4b20c8 100644 --- a/wqflask/wqflask/static/new/javascript/create_interval_map.coffee +++ b/wqflask/wqflask/static/new/javascript/create_interval_map.coffee @@ -1,4 +1,4 @@ -create_interval_map = -> +create_interval_map = () -> h = 500 w = 1200 margin = {left:60, top:40, right:40, bottom: 40, inner:5} @@ -39,6 +39,7 @@ create_interval_map = -> create_interval_map() $("#export").click => + #Get d3 SVG element svg = $("#topchart").find("svg")[0] @@ -54,6 +55,29 @@ $("#export").click => form.find("#data").val(svg_xml) form.find("#filename").val(filename) form.submit() + + +$("#export_pdf").click => + + #$('#topchart').remove() + #$('#chart_container').append('
') + #create_interval_map() + + #Get d3 SVG element + svg = $("#topchart").find("svg")[0] + + #Extract SVG text string + svg_xml = (new XMLSerializer).serializeToString(svg) + console.log("svg_xml:", svg_xml) + + #Set filename + filename = "interval_map_pdf" + + #Make a form with the SVG data + form = $("#exportpdfform") + form.find("#data").val(svg_xml) + form.find("#filename").val(filename) + form.submit() # two LOD charts within one SVG #d3.json "data.json", (data) -> diff --git a/wqflask/wqflask/static/new/javascript/create_interval_map.js b/wqflask/wqflask/static/new/javascript/create_interval_map.js index 5041cfea..341e92c0 100644 --- a/wqflask/wqflask/static/new/javascript/create_interval_map.js +++ b/wqflask/wqflask/static/new/javascript/create_interval_map.js @@ -51,3 +51,17 @@ $("#export").click((function(_this) { return form.submit(); }; })(this)); + +$("#export_pdf").click((function(_this) { + return function() { + var filename, form, svg, svg_xml; + svg = $("#topchart").find("svg")[0]; + svg_xml = (new XMLSerializer).serializeToString(svg); + console.log("svg_xml:", svg_xml); + filename = "interval_map_pdf"; + form = $("#exportpdfform"); + form.find("#data").val(svg_xml); + form.find("#filename").val(filename); + return form.submit(); + }; +})(this)); diff --git a/wqflask/wqflask/static/new/javascript/create_manhattan_plot.coffee b/wqflask/wqflask/static/new/javascript/create_manhattan_plot.coffee index 258d5c01..05ad5419 100644 --- a/wqflask/wqflask/static/new/javascript/create_manhattan_plot.coffee +++ b/wqflask/wqflask/static/new/javascript/create_manhattan_plot.coffee @@ -55,3 +55,24 @@ $("#export").click => form.find("#filename").val(filename) form.submit() +$("#export_pdf").click => + + #$('#topchart').remove() + #$('#chart_container').append('
') + #create_interval_map() + + #Get d3 SVG element + svg = $("#topchart").find("svg")[0] + + #Extract SVG text string + svg_xml = (new XMLSerializer).serializeToString(svg) + console.log("svg_xml:", svg_xml) + + #Set filename + filename = "manhattan_plot_" + js_data.this_trait + + #Make a form with the SVG data + form = $("#exportpdfform") + form.find("#data").val(svg_xml) + form.find("#filename").val(filename) + form.submit() diff --git a/wqflask/wqflask/static/new/javascript/create_manhattan_plot.js b/wqflask/wqflask/static/new/javascript/create_manhattan_plot.js index 7daaa921..62584fb2 100644 --- a/wqflask/wqflask/static/new/javascript/create_manhattan_plot.js +++ b/wqflask/wqflask/static/new/javascript/create_manhattan_plot.js @@ -51,3 +51,17 @@ $("#export").click((function(_this) { return form.submit(); }; })(this)); + +$("#export_pdf").click((function(_this) { + return function() { + var filename, form, svg, svg_xml; + svg = $("#topchart").find("svg")[0]; + svg_xml = (new XMLSerializer).serializeToString(svg); + console.log("svg_xml:", svg_xml); + filename = "manhattan_plot_" + js_data.this_trait; + form = $("#exportpdfform"); + form.find("#data").val(svg_xml); + form.find("#filename").val(filename); + return form.submit(); + }; +})(this)); diff --git a/wqflask/wqflask/static/new/javascript/dataset_select_menu.js b/wqflask/wqflask/static/new/javascript/dataset_select_menu.js deleted file mode 100755 index f4ca2c37..00000000 --- a/wqflask/wqflask/static/new/javascript/dataset_select_menu.js +++ /dev/null @@ -1,137 +0,0 @@ -// Generated by CoffeeScript 1.7.1 -$(function() { - var apply_default, dataset_info, group_info, make_default, open_window, populate_dataset, populate_group, populate_species, populate_type, process_json, redo_dropdown; - process_json = function(data) { - window.jdata = data; - populate_species(); - return apply_default(); - }; - $.ajax('/static/new/javascript/dataset_menu_structure.json', { - dataType: 'json', - success: process_json - }); - populate_species = function() { - var species_list; - species_list = this.jdata.species; - redo_dropdown($('#species'), species_list); - return populate_group(); - }; - window.populate_species = populate_species; - populate_group = function() { - var group_list, species; - console.log("in populate group"); - species = $('#species').val(); - group_list = this.jdata.groups[species]; - redo_dropdown($('#group'), group_list); - return populate_type(); - }; - window.populate_group = populate_group; - populate_type = function() { - var group, species, type_list; - species = $('#species').val(); - group = $('#group').val(); - type_list = this.jdata.types[species][group]; - redo_dropdown($('#type'), type_list); - return populate_dataset(); - }; - window.populate_type = populate_type; - populate_dataset = function() { - var dataset_list, group, species, type; - species = $('#species').val(); - group = $('#group').val(); - type = $('#type').val(); - console.log("sgt:", species, group, type); - dataset_list = this.jdata.datasets[species][group][type]; - console.log("pop_dataset:", dataset_list); - return redo_dropdown($('#dataset'), dataset_list); - }; - window.populate_dataset = populate_dataset; - redo_dropdown = function(dropdown, items) { - var item, _i, _len, _results; - console.log("in redo:", dropdown, items); - dropdown.empty(); - _results = []; - for (_i = 0, _len = items.length; _i < _len; _i++) { - item = items[_i]; - _results.push(dropdown.append($("