aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZachary Sloan2014-01-23 21:52:03 +0000
committerZachary Sloan2014-01-23 21:52:03 +0000
commit6b367e3e2ee144aae5b79c50234faf0ea49adba6 (patch)
treecca03b3c56b0482b24b138f214b845c554052806
parentbd48ca02770735cff482b1612399f236e8ac377f (diff)
downloadgenenetwork2-6b367e3e2ee144aae5b79c50234faf0ea49adba6.tar.gz
Histogram is working
Fixed some bug with generating the manhattan plot for the HLC data set
-rwxr-xr-xwqflask/base/data_set.py2
-rwxr-xr-xwqflask/wqflask/marker_regression/marker_regression.py11
-rw-r--r--wqflask/wqflask/my_pylmm/data/genofile_parser.py6
-rw-r--r--wqflask/wqflask/my_pylmm/pyLMM/lmm.py2
-rw-r--r--wqflask/wqflask/static/new/javascript/histogram.coffee96
-rw-r--r--wqflask/wqflask/static/new/javascript/histogram.js72
-rw-r--r--wqflask/wqflask/static/new/javascript/marker_regression.coffee42
-rw-r--r--wqflask/wqflask/static/new/javascript/marker_regression.js30
-rw-r--r--wqflask/wqflask/static/new/javascript/show_trait.coffee3
-rw-r--r--wqflask/wqflask/static/new/javascript/show_trait.js1
-rw-r--r--wqflask/wqflask/templates/marker_regression.html3
-rw-r--r--wqflask/wqflask/templates/show_trait.html41
-rw-r--r--wqflask/wqflask/templates/show_trait_edit_data.html132
-rw-r--r--wqflask/wqflask/views.py7
14 files changed, 226 insertions, 222 deletions
diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py
index d421f21e..0d295bed 100755
--- a/wqflask/base/data_set.py
+++ b/wqflask/base/data_set.py
@@ -185,6 +185,7 @@ class HumanMarkers(Markers):
self.markers = []
for line in marker_data_fh:
splat = line.strip().split()
+ print("splat:", splat)
marker = {}
marker['chr'] = int(splat[0])
marker['name'] = splat[1]
@@ -204,6 +205,7 @@ class HumanMarkers(Markers):
# #Using -log(p) for the LRS; need to ask Rob how he wants to get LRS from p-values
# marker['lrs_value'] = -math.log10(marker['p_value']) * 4.61
+ print("p_values2:", p_values)
super(HumanMarkers, self).add_pvalues(p_values)
with Bench("deleting markers"):
diff --git a/wqflask/wqflask/marker_regression/marker_regression.py b/wqflask/wqflask/marker_regression/marker_regression.py
index 006c586b..fa9e0b67 100755
--- a/wqflask/wqflask/marker_regression/marker_regression.py
+++ b/wqflask/wqflask/marker_regression/marker_regression.py
@@ -48,7 +48,7 @@ class MarkerRegression(object):
self.samples.append(str(sample))
self.vals.append(value)
- self.gen_data(tempdata)
+ self.qtl_results = self.gen_data(tempdata)
#Get chromosome lengths for drawing the manhattan plot
chromosome_mb_lengths = {}
@@ -78,9 +78,9 @@ class MarkerRegression(object):
genotype_matrix = np.array(trimmed_genotype_data).T
- print("pheno_vector: ", pf(pheno_vector))
- print("genotype_matrix: ", pf(genotype_matrix))
- print("genotype_matrix.shape: ", pf(genotype_matrix.shape))
+ #print("pheno_vector: ", pf(pheno_vector))
+ #print("genotype_matrix: ", pf(genotype_matrix))
+ #print("genotype_matrix.shape: ", pf(genotype_matrix.shape))
t_stats, p_values = lmm.run(
pheno_vector,
@@ -89,9 +89,10 @@ class MarkerRegression(object):
refit=False,
temp_data=tempdata
)
+ #print("p_values:", p_values)
self.dataset.group.markers.add_pvalues(p_values)
- self.qtl_results = self.dataset.group.markers.markers
+ return self.dataset.group.markers.markers
def gen_human_results(self, pheno_vector, tempdata):
diff --git a/wqflask/wqflask/my_pylmm/data/genofile_parser.py b/wqflask/wqflask/my_pylmm/data/genofile_parser.py
index c8c0929f..4ebadb6e 100644
--- a/wqflask/wqflask/my_pylmm/data/genofile_parser.py
+++ b/wqflask/wqflask/my_pylmm/data/genofile_parser.py
@@ -106,7 +106,7 @@ class ConvertGenoFile(object):
this_marker.genotypes.append("NA")
#print("this_marker is:", pf(this_marker.__dict__))
- if this_marker.chr == "5":
+ if this_marker.chr == "14":
self.markers.append(this_marker.__dict__)
with open(self.output_file, 'w') as fh:
@@ -125,8 +125,8 @@ class ConvertGenoFile(object):
def process_rows(self):
for self.latest_row_pos, row in enumerate(self.input_fh):
- if self.input_file.endswith(".geno.gz"):
- print("row: ", row)
+ #if self.input_file.endswith(".geno.gz"):
+ # print("row: ", row)
self.latest_row_value = row
# Take care of headers
if not row.strip():
diff --git a/wqflask/wqflask/my_pylmm/pyLMM/lmm.py b/wqflask/wqflask/my_pylmm/pyLMM/lmm.py
index 60d36b8d..6d12991f 100644
--- a/wqflask/wqflask/my_pylmm/pyLMM/lmm.py
+++ b/wqflask/wqflask/my_pylmm/pyLMM/lmm.py
@@ -136,7 +136,7 @@ def run_human(pheno_vector,
#print("***** Added to {} queue *****".format(key))
for snp, this_id in plink_input:
#with Bench("part before association"):
- #if count > 2000:
+ #if count > 1000:
# break
count += 1
diff --git a/wqflask/wqflask/static/new/javascript/histogram.coffee b/wqflask/wqflask/static/new/javascript/histogram.coffee
index 03332835..f1799307 100644
--- a/wqflask/wqflask/static/new/javascript/histogram.coffee
+++ b/wqflask/wqflask/static/new/javascript/histogram.coffee
@@ -4,10 +4,7 @@ class Histogram
constructor: (@sample_list, @sample_group) ->
@sort_by = "name"
@format_count = d3.format(",.0f") #a formatter for counts
- @get_samples()
- #if @sample_attr_vals.length > 0
- # @get_distinct_attr_vals()
- # @get_attr_color_dict(@distinct_attr_vals)
+ @get_sample_vals()
@margin = {top: 10, right: 30, bottom: 30, left: 30}
@plot_width = 960 - @margin.left - @margin.right
@@ -28,21 +25,9 @@ class Histogram
@create_graph()
- get_samples: () ->
- @sample_names = (sample.name for sample in @sample_list when sample.value != null)
+ get_sample_vals: () ->
@sample_vals = (sample.value for sample in @sample_list when sample.value != null)
- @attributes = (key for key of @sample_list[0]["extra_attributes"])
- console.log("attributes:", @attributes)
- @sample_attr_vals = []
- if @attributes.length > 0
- for sample in @sample_list
- attr_vals = {}
- for attribute in @attributes
- attr_vals[attribute] = sample["extra_attributes"][attribute]
- @sample_attr_vals.push(attr_vals)
- @samples = _.zip(@sample_names, @sample_vals, @sample_attr_vals)
-
create_svg: () ->
svg = d3.select("#histogram")
.append("svg")
@@ -51,18 +36,19 @@ class Histogram
.attr("height", @plot_height + @margin.top + @margin.bottom)
.append("g")
.attr("transform", "translate(" + @margin.left + "," + @margin.top + ")")
-
+
return svg
-
+
create_x_scale: () ->
+ console.log("min/max:", d3.min(@sample_vals) + "," + d3.max(@sample_vals))
@x_scale = d3.scale.linear()
.domain([d3.min(@sample_vals), d3.max(@sample_vals)])
- .range([0, @plot_width])
+ .range([0, @plot_width])
get_histogram_data: () ->
console.log("sample_vals:", @sample_vals)
@histogram_data = d3.layout.histogram()
- .bins(@x_scale.ticks(10))(@sample_vals)
+ .bins(@x_scale.ticks(20))(@sample_vals)
console.log("histogram_data:", @histogram_data[0])
create_y_scale: () ->
@@ -71,12 +57,9 @@ class Histogram
.range([@plot_height, 0])
create_graph: () ->
-
@add_x_axis()
- #@add_y_axis()
-
@add_bars()
-
+
add_x_axis: () ->
x_axis = d3.svg.axis()
.scale(@x_scale)
@@ -86,64 +69,37 @@ class Histogram
.attr("class", "x axis")
.attr("transform", "translate(0," + @plot_height + ")")
.call(x_axis)
- #.selectAll("text")
- # .style("text-anchor", "end")
- # .style("font-size", "12px")
- # .attr("dx", "-.8em")
- # .attr("dy", "-.3em")
- # .attr("transform", (d) =>
- # return "rotate(-90)"
- # )
-
- #add_y_axis: () ->
- # y_axis = d3.svg.axis()
- # .scale(@y_scale)
- # .orient("left")
- # .ticks(5)
- #
- # @svg.append("g")
- # .attr("class", "y axis")
- # .call(y_axis)
- # .append("text")
- # .attr("transform", "rotate(-90)")
- # .attr("y", 6)
- # .attr("dy", ".71em")
- # .style("text-anchor", "end")
-
+
+ add_y_axis: () ->
+ y_axis = d3.svg.axis()
+ .scale(@y_scale)
+ .orient("left")
+ .ticks(5)
add_bars: () ->
- @svg.selectAll(".bar")
+ console.log("bar_width:", @x_scale(@histogram_data[0].dx))
+ bar = @svg.selectAll(".bar")
.data(@histogram_data)
.enter().append("g")
.attr("class", "bar")
.attr("transform", (d) =>
- return "translate(" + @margin.left + "," + @margin.top + ")")
- .append("rect")
+ return "translate(" + @x_scale(d.x) + "," + @y_scale(d.y) + ")")
+
+ bar.append("rect")
.attr("x", 1)
- .attr("width", @x_scale(@histogram_data[0].dx) - 1)
+ .attr("width", (@x_scale(@histogram_data[1].x) - @x_scale(@histogram_data[0].x)) - 1)
.attr("height", (d) =>
return @plot_height - @y_scale(d.y)
)
- .append("text")
+ bar.append("text")
.attr("dy", ".75em")
.attr("y", 6)
- .attr("x", @x_scale(@histogram_data[0].dx) / 2)
+ .attr("x", (@x_scale(@histogram_data[1].x) - @x_scale(@histogram_data[0].x))/2)
.attr("text-anchor", "middle")
+ .style("fill", "#fff")
.text((d) =>
- return @format_count(d.y)
+ bar_height = @plot_height - @y_scale(d.y)
+ if bar_height > 20
+ return @format_count(d.y)
)
- #open_trait_selection: () ->
- # $('#collections_holder').load('/collections/list?color_by_trait #collections_list', =>
- # $.colorbox(
- # inline: true
- # href: "#collections_holder"
- # )
- # #Removes the links from the collection names, because clicking them would leave the page
- # #instead of loading the list of traits in the colorbox
- # $('a.collection_name').attr( 'onClick', 'return false' )
- # #$('.collection_name').each (index, element) =>
- # # console.log("contents:", $(element).contents())
- # # $(element).contents().unwrap()
- # )
-
root.Histogram = Histogram \ No newline at end of file
diff --git a/wqflask/wqflask/static/new/javascript/histogram.js b/wqflask/wqflask/static/new/javascript/histogram.js
index e7926ab1..eb00ca73 100644
--- a/wqflask/wqflask/static/new/javascript/histogram.js
+++ b/wqflask/wqflask/static/new/javascript/histogram.js
@@ -11,7 +11,7 @@
this.sample_group = sample_group;
this.sort_by = "name";
this.format_count = d3.format(",.0f");
- this.get_samples();
+ this.get_sample_vals();
this.margin = {
top: 10,
right: 30,
@@ -32,21 +32,9 @@
this.create_graph();
}
- Histogram.prototype.get_samples = function() {
- var attr_vals, attribute, key, sample, _i, _j, _len, _len1, _ref, _ref1;
- this.sample_names = (function() {
- var _i, _len, _ref, _results;
- _ref = this.sample_list;
- _results = [];
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- sample = _ref[_i];
- if (sample.value !== null) {
- _results.push(sample.name);
- }
- }
- return _results;
- }).call(this);
- this.sample_vals = (function() {
+ Histogram.prototype.get_sample_vals = function() {
+ var sample;
+ return this.sample_vals = (function() {
var _i, _len, _ref, _results;
_ref = this.sample_list;
_results = [];
@@ -58,30 +46,6 @@
}
return _results;
}).call(this);
- this.attributes = (function() {
- var _results;
- _results = [];
- for (key in this.sample_list[0]["extra_attributes"]) {
- _results.push(key);
- }
- return _results;
- }).call(this);
- console.log("attributes:", this.attributes);
- this.sample_attr_vals = [];
- if (this.attributes.length > 0) {
- _ref = this.sample_list;
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- sample = _ref[_i];
- attr_vals = {};
- _ref1 = this.attributes;
- for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
- attribute = _ref1[_j];
- attr_vals[attribute] = sample["extra_attributes"][attribute];
- }
- this.sample_attr_vals.push(attr_vals);
- }
- }
- return this.samples = _.zip(this.sample_names, this.sample_vals, this.sample_attr_vals);
};
Histogram.prototype.create_svg = function() {
@@ -91,12 +55,13 @@
};
Histogram.prototype.create_x_scale = function() {
+ console.log("min/max:", d3.min(this.sample_vals) + "," + d3.max(this.sample_vals));
return this.x_scale = d3.scale.linear().domain([d3.min(this.sample_vals), d3.max(this.sample_vals)]).range([0, this.plot_width]);
};
Histogram.prototype.get_histogram_data = function() {
console.log("sample_vals:", this.sample_vals);
- this.histogram_data = d3.layout.histogram().bins(this.x_scale.ticks(10))(this.sample_vals);
+ this.histogram_data = d3.layout.histogram().bins(this.x_scale.ticks(20))(this.sample_vals);
return console.log("histogram_data:", this.histogram_data[0]);
};
@@ -120,14 +85,27 @@
return this.svg.append("g").attr("class", "x axis").attr("transform", "translate(0," + this.plot_height + ")").call(x_axis);
};
+ Histogram.prototype.add_y_axis = function() {
+ var y_axis;
+ return y_axis = d3.svg.axis().scale(this.y_scale).orient("left").ticks(5);
+ };
+
Histogram.prototype.add_bars = function() {
- var _this = this;
- return this.svg.selectAll(".bar").data(this.histogram_data).enter().append("g").attr("class", "bar").attr("transform", function(d) {
- return "translate(" + _this.margin.left + "," + _this.margin.top + ")";
- }).append("rect").attr("x", 1).attr("width", this.x_scale(this.histogram_data[0].dx) - 1).attr("height", function(d) {
+ var bar,
+ _this = this;
+ console.log("bar_width:", this.x_scale(this.histogram_data[0].dx));
+ bar = this.svg.selectAll(".bar").data(this.histogram_data).enter().append("g").attr("class", "bar").attr("transform", function(d) {
+ return "translate(" + _this.x_scale(d.x) + "," + _this.y_scale(d.y) + ")";
+ });
+ bar.append("rect").attr("x", 1).attr("width", (this.x_scale(this.histogram_data[1].x) - this.x_scale(this.histogram_data[0].x)) - 1).attr("height", function(d) {
return _this.plot_height - _this.y_scale(d.y);
- }).append("text").attr("dy", ".75em").attr("y", 6).attr("x", this.x_scale(this.histogram_data[0].dx) / 2).attr("text-anchor", "middle").text(function(d) {
- return _this.format_count(d.y);
+ });
+ return bar.append("text").attr("dy", ".75em").attr("y", 6).attr("x", (this.x_scale(this.histogram_data[1].x) - this.x_scale(this.histogram_data[0].x)) / 2).attr("text-anchor", "middle").style("fill", "#fff").text(function(d) {
+ var bar_height;
+ bar_height = _this.plot_height - _this.y_scale(d.y);
+ if (bar_height > 20) {
+ return _this.format_count(d.y);
+ }
});
};
diff --git a/wqflask/wqflask/static/new/javascript/marker_regression.coffee b/wqflask/wqflask/static/new/javascript/marker_regression.coffee
index f5f13c27..93d3b5de 100644
--- a/wqflask/wqflask/static/new/javascript/marker_regression.coffee
+++ b/wqflask/wqflask/static/new/javascript/marker_regression.coffee
@@ -14,7 +14,7 @@ $ ->
@marker_names = []
console.time('Create coordinates')
@create_coordinates()
- console.log("@x_coords: ", @x_coords)
+ #console.log("@x_coords: ", @x_coords)
console.log("@y_coords: ", @y_coords)
console.timeEnd('Create coordinates')
[@chr_lengths, @cumulative_chr_lengths] = @get_chr_lengths()
@@ -30,7 +30,10 @@ $ ->
@y_max = d3.max(@y_coords) * 1.2
@svg = @create_svg()
+ console.log("svg created")
@plot_coordinates = _.zip(@x_coords, @y_coords, @marker_names)
+ #console.log("coordinates:", @plot_coordinates)
+
@plot_height -= @y_buffer
@create_scales()
@@ -73,6 +76,7 @@ $ ->
create_coordinates: () ->
chr_lengths = []
chr_seen = []
+ #console.log("total_length2:", @total_length)
for result in js_data.qtl_results
if result.chr == "X"
chr_length = parseFloat(@chromosomes[20])
@@ -80,12 +84,16 @@ $ ->
chr_length = parseFloat(@chromosomes[result.chr])
if not(result.chr in chr_seen)
chr_seen.push(result.chr)
- chr_lengths.push(chr_length)
- if result.chr != "1"
+ chr_lengths.push(chr_length)
+ #console.log("result.chr:", result.chr)
+ if result.chr != 1
@total_length += parseFloat(chr_lengths[chr_lengths.length - 2])
- @x_coords.push(@total_length + parseFloat(result.Mb))
- @y_coords.push(result.lod_score)
- @marker_names.push(result.name)
+ #console.log("total_length3:", @total_length)
+ #console.log("Mb:", result.Mb)
+ if result.lod_score > 2
+ @x_coords.push(@total_length + parseFloat(result.Mb))
+ @y_coords.push(result.lod_score)
+ @marker_names.push(result.name)
@total_length += parseFloat(chr_lengths[chr_lengths.length-1])
#console.log("chr_lengths: ", chr_lengths)
@@ -141,12 +149,19 @@ $ ->
.style("stroke", "#000")
create_scales: () ->
+ #@x_scale = d3.scale.linear()
+ # .domain([0, d3.max(@x_coords)])
+ # .range([@x_buffer, @plot_width])
+ console.log("@chromosomes[24]:", @chromosomes['24'])
+ console.log("@chromosomes[23]:", @chromosomes['23'])
+ console.log("@total_length:", @total_length)
+ console.log("d3.max(@xcoords):", d3.max(@x_coords))
@x_scale = d3.scale.linear()
- .domain([0, d3.max(@x_coords)])
+ .domain([0, (@total_length + @chromosomes['24'])])
.range([@x_buffer, @plot_width])
@y_scale = d3.scale.linear()
- .domain([0, @y_max])
+ .domain([2, @y_max])
.range([@plot_height, @y_buffer])
create_x_axis_tick_values: () ->
@@ -230,13 +245,13 @@ $ ->
.style("stroke", "#ccc")
fill_chr_areas: () ->
- @svg.selectAll("rect.chr_fill_area_1")
+ @svg.selectAll("rect.chr_fill_area")
.data(_.zip(@chr_lengths, @cumulative_chr_lengths), (d) =>
return d
)
.enter()
.append("rect")
- .attr("class", "chr_fill_area_1")
+ .attr("class", "chr_fill_area")
.attr("x", (d, i) =>
if i == 0
return @x_scale(0)
@@ -247,7 +262,8 @@ $ ->
.attr("width", (d) =>
return @x_scale(d[0])
)
- .attr("height", @plot_height-@y_buffer)
+ .attr("height", @plot_height-@y_buffer)
+ .attr("fill", "none")
add_chr_labels: () ->
chr_names = []
@@ -279,10 +295,10 @@ $ ->
.enter()
.append("circle")
.attr("cx", (d) =>
- return parseFloat(@x_buffer) + ((parseFloat(@plot_width)-parseFloat(@x_buffer)) * d[0]/parseFloat(@x_max))
+ return @x_scale(d[0])
)
.attr("cy", (d) =>
- return @plot_height - ((@plot_height-@y_buffer) * d[1]/@y_max)
+ return @y_scale(d[1])
)
.attr("r", 2)
.attr("id", (d) =>
diff --git a/wqflask/wqflask/static/new/javascript/marker_regression.js b/wqflask/wqflask/static/new/javascript/marker_regression.js
index cdf37671..8e5b6c11 100644
--- a/wqflask/wqflask/static/new/javascript/marker_regression.js
+++ b/wqflask/wqflask/static/new/javascript/marker_regression.js
@@ -20,7 +20,6 @@
this.marker_names = [];
console.time('Create coordinates');
this.create_coordinates();
- console.log("@x_coords: ", this.x_coords);
console.log("@y_coords: ", this.y_coords);
console.timeEnd('Create coordinates');
_ref = this.get_chr_lengths(), this.chr_lengths = _ref[0], this.cumulative_chr_lengths = _ref[1];
@@ -31,6 +30,7 @@
console.log("@x_buffer: ", this.x_buffer);
this.y_max = d3.max(this.y_coords) * 1.2;
this.svg = this.create_svg();
+ console.log("svg created");
this.plot_coordinates = _.zip(this.x_coords, this.y_coords, this.marker_names);
this.plot_height -= this.y_buffer;
this.create_scales();
@@ -93,13 +93,15 @@
if (!(_ref1 = result.chr, __indexOf.call(chr_seen, _ref1) >= 0)) {
chr_seen.push(result.chr);
chr_lengths.push(chr_length);
- if (result.chr !== "1") {
+ if (result.chr !== 1) {
this.total_length += parseFloat(chr_lengths[chr_lengths.length - 2]);
}
}
- this.x_coords.push(this.total_length + parseFloat(result.Mb));
- this.y_coords.push(result.lod_score);
- this.marker_names.push(result.name);
+ if (result.lod_score > 2) {
+ this.x_coords.push(this.total_length + parseFloat(result.Mb));
+ this.y_coords.push(result.lod_score);
+ this.marker_names.push(result.name);
+ }
}
return this.total_length += parseFloat(chr_lengths[chr_lengths.length - 1]);
};
@@ -150,8 +152,12 @@
};
Manhattan_Plot.prototype.create_scales = function() {
- this.x_scale = d3.scale.linear().domain([0, d3.max(this.x_coords)]).range([this.x_buffer, this.plot_width]);
- return this.y_scale = d3.scale.linear().domain([0, this.y_max]).range([this.plot_height, this.y_buffer]);
+ console.log("@chromosomes[24]:", this.chromosomes['24']);
+ console.log("@chromosomes[23]:", this.chromosomes['23']);
+ console.log("@total_length:", this.total_length);
+ console.log("d3.max(@xcoords):", d3.max(this.x_coords));
+ this.x_scale = d3.scale.linear().domain([0, this.total_length + this.chromosomes['24']]).range([this.x_buffer, this.plot_width]);
+ return this.y_scale = d3.scale.linear().domain([2, this.y_max]).range([this.plot_height, this.y_buffer]);
};
Manhattan_Plot.prototype.create_x_axis_tick_values = function() {
@@ -224,9 +230,9 @@
Manhattan_Plot.prototype.fill_chr_areas = function() {
var _this = this;
- return this.svg.selectAll("rect.chr_fill_area_1").data(_.zip(this.chr_lengths, this.cumulative_chr_lengths), function(d) {
+ return this.svg.selectAll("rect.chr_fill_area").data(_.zip(this.chr_lengths, this.cumulative_chr_lengths), function(d) {
return d;
- }).enter().append("rect").attr("class", "chr_fill_area_1").attr("x", function(d, i) {
+ }).enter().append("rect").attr("class", "chr_fill_area").attr("x", function(d, i) {
if (i === 0) {
return _this.x_scale(0);
} else {
@@ -234,7 +240,7 @@
}
}).attr("y", this.y_buffer).attr("width", function(d) {
return _this.x_scale(d[0]);
- }).attr("height", this.plot_height - this.y_buffer);
+ }).attr("height", this.plot_height - this.y_buffer).attr("fill", "none");
};
Manhattan_Plot.prototype.add_chr_labels = function() {
@@ -257,9 +263,9 @@
Manhattan_Plot.prototype.add_plot_points = function() {
var _this = this;
return this.svg.selectAll("circle").data(this.plot_coordinates).enter().append("circle").attr("cx", function(d) {
- return parseFloat(_this.x_buffer) + ((parseFloat(_this.plot_width) - parseFloat(_this.x_buffer)) * d[0] / parseFloat(_this.x_max));
+ return _this.x_scale(d[0]);
}).attr("cy", function(d) {
- return _this.plot_height - ((_this.plot_height - _this.y_buffer) * d[1] / _this.y_max);
+ return _this.y_scale(d[1]);
}).attr("r", 2).attr("id", function(d) {
return "point_" + String(d[2]);
}).classed("circle", true).on("mouseover", function(d) {
diff --git a/wqflask/wqflask/static/new/javascript/show_trait.coffee b/wqflask/wqflask/static/new/javascript/show_trait.coffee
index e42a7d82..e45bb0be 100644
--- a/wqflask/wqflask/static/new/javascript/show_trait.coffee
+++ b/wqflask/wqflask/static/new/javascript/show_trait.coffee
@@ -64,7 +64,8 @@ $ ->
sample_lists = js_data.sample_lists
sample_group_types = js_data.sample_group_types
- $("#update_bar_chart.btn-group").button()
+ #if $("#update_bar_chart").length
+ # $("#update_bar_chart.btn-group").button()
root.bar_chart = new Bar_Chart(sample_lists[0])
root.histogram = new Histogram(sample_lists[0])
new Box_Plot(sample_lists[0])
diff --git a/wqflask/wqflask/static/new/javascript/show_trait.js b/wqflask/wqflask/static/new/javascript/show_trait.js
index d3a34166..c28b05f5 100644
--- a/wqflask/wqflask/static/new/javascript/show_trait.js
+++ b/wqflask/wqflask/static/new/javascript/show_trait.js
@@ -61,7 +61,6 @@
var block_by_attribute_value, block_by_index, block_outliers, change_stats_value, create_value_dropdown, edit_data_change, export_sample_table_data, get_sample_table_data, hide_no_value, hide_tabs, make_table, on_corr_method_change, populate_sample_attributes_values_dropdown, process_id, reset_samples_table, sample_group_types, sample_lists, show_hide_outliers, stats_mdp_change, update_stat_values;
sample_lists = js_data.sample_lists;
sample_group_types = js_data.sample_group_types;
- $("#update_bar_chart.btn-group").button();
root.bar_chart = new Bar_Chart(sample_lists[0]);
root.histogram = new Histogram(sample_lists[0]);
new Box_Plot(sample_lists[0]);
diff --git a/wqflask/wqflask/templates/marker_regression.html b/wqflask/wqflask/templates/marker_regression.html
index 64d2e9b7..c1d4d7e5 100644
--- a/wqflask/wqflask/templates/marker_regression.html
+++ b/wqflask/wqflask/templates/marker_regression.html
@@ -26,6 +26,7 @@
Genome Association Results
</h2>
</div>
+
<table cellpadding="0" cellspacing="0" border="0" id="qtl_results" class="table table-hover table-striped table-bordered">
<thead>
<tr>
@@ -61,7 +62,7 @@
</script>
<!--[if lt IE 9]>
- <script language="javascript" type="text/javascript" src="/static/packages/jqplot/excanvas.js"></script>
+<!-- <script language="javascript" type="text/javascript" src="/static/packages/jqplot/excanvas.js"></script>-->
<![endif]-->
<script language="javascript" type="text/javascript" src="http://d3js.org/d3.v3.min.js"></script>
<script language="javascript" type="text/javascript" src="/static/new/javascript/marker_regression.js"></script>
diff --git a/wqflask/wqflask/templates/show_trait.html b/wqflask/wqflask/templates/show_trait.html
index 26f21f08..8822fd00 100644
--- a/wqflask/wqflask/templates/show_trait.html
+++ b/wqflask/wqflask/templates/show_trait.html
@@ -64,4 +64,45 @@
<script type="text/javascript" src="/static/new/javascript/show_trait_mapping_tools.js"></script>
<script type="text/javascript" src="/static/new/javascript/show_trait.js"></script>
<script type="text/javascript" src="/static/new/javascript/validation.js"></script>
+
+<!-- <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/jquery.js"></script>
+ <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/jquery.dataTables.min.js"></script>
+ <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/dataTables.formattedNumbers.js"></script>
+ <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/dataTables.naturalSort.js"></script>
+ <script language="javascript" type="text/javascript" src="/static/packages/DT_bootstrap/DT_bootstrap.js"></script>
+ <script language="javascript" type="text/javascript" src="/static/packages/TableTools/media/js/TableTools.min.js"></script>
+
+ <script type="text/javascript" charset="utf-8">
+ $(document).ready( function () {
+ console.time("Creating table");
+ $('#samples_primary, #samples_other').dataTable( {
+ //"sDom": "<<'span3'l><'span3'T><'span4'f>'row-fluid'r>t<'row-fluid'<'span6'i><'span6'p>>",
+ "aoColumns": [
+ { "sType": "natural" },
+ null,
+ null,
+ { "bSortable": false },
+ null
+ ],
+ "sDom": "ftr",
+ "oTableTools": {
+ "aButtons": [
+ "copy",
+ "print",
+ {
+ "sExtends": "collection",
+ "sButtonText": 'Save <span class="caret" />',
+ "aButtons": [ "csv", "xls", "pdf" ]
+ }
+ ],
+ "sSwfPath": "/static/packages/TableTools/media/swf/copy_csv_xls_pdf.swf"
+ },
+ "bPaginate": false,
+ "bLengthChange": true,
+ "bDeferRender": true,
+ "bSortClasses": false
+ } );
+ console.timeEnd("Creating table");
+ });
+ </script>-->
{% endblock %}
diff --git a/wqflask/wqflask/templates/show_trait_edit_data.html b/wqflask/wqflask/templates/show_trait_edit_data.html
index 84c606b9..e7df3b13 100644
--- a/wqflask/wqflask/templates/show_trait_edit_data.html
+++ b/wqflask/wqflask/templates/show_trait_edit_data.html
@@ -82,75 +82,73 @@
<div>
<h3>{{ sample_type.header }}</h3>
- <table class="table table-hover table-striped" {# Todo: Enable sorting on table #}
+ <table cellpadding="0" cellspacing="0" border="0" class="table table-hover table-striped table-bordered"
id="samples_{{ sample_type.sample_group_type }}">
- <tr>
- <th>Index</th>
-
- <th>Sample</th>
-
- <th>Value</th>
- {% if sample_type.se_exists() %}
- <th>&nbsp;</th>
-
- <th>SE</th>
- {% endif %}
-
- {% for attribute in sample_type.attributes|sort() %}
- <th>
- {{ sample_type.attributes[attribute].name }}
- </th>
+ <thead>
+ <tr>
+ <td>Index</td>
+ <td>Sample</td>
+ <td>Value</td>
+ {% if sample_type.se_exists() %}
+ <td>&nbsp;</td>
+ <td>SE</td>
+ {% endif %}
+ {% for attribute in sample_type.attributes|sort() %}
+ <td>
+ {{ sample_type.attributes[attribute].name }}
+ </td>
+ {% endfor %}
+ </tr>
+ </thead>
+ <tbody>
+ {% for sample in sample_type.sample_list %}
+ <tr class="{{ sample.class_outlier }} value_se" id="{{ sample.this_id }}">
+ <td class="column_name-Index">
+ {{ loop.index }}
+ <input type="checkbox" name="selectCheck"
+ class="checkbox edit_sample_checkbox"
+ value="{{ sample.name }}" checked="checked">
+ </td>
+
+ <td class="column_name-Sample">
+ <span class="edit_sample_sample_name">
+ {{ sample.name }}
+ </span>
+ </td>
+
+ {# Todo: Add IDs #}
+ <td class="column_name-Value">
+ <input type="text" data-value="{{ sample.display_value }}" name="{{ 'value:' + sample.name }}"
+ class="trait_value_input edit_sample_value"
+ value="{{ sample.display_value }}"
+ size=8 maxlength=8
+ >
+ </td>
+
+ {% if sample_type.se_exists() %}
+ <td>
+ ±
+ </td>
+
+ {# Todo: Add IDs #}
+ <td class="column_name-SE">
+ <input type="text" data-value="{{ sample.display_variance }}" name="{{ 'variance:' + sample.name}}"
+ class="trait_value_input edit_sample_se"
+ value="{{ sample.display_variance }}"
+ size=8 maxlength=8
+ >
+ </td>
+ {% endif %}
+
+ {# Loop through each attribute type and input value #}
+ {% for attribute in sample_type.attributes|sort() %}
+ <td class="std_cell column_name-{{ sample_type.attributes[attribute].name.replace(' ', '_') }}">
+ {{ sample.extra_attributes[sample_type.attributes[attribute].name] }}
+ </td>
+ {% endfor %}
+ </tr>
{% endfor %}
- </tr>
-
- {% for sample in sample_type.sample_list %}
- <tr class="{{ sample.class_outlier }} value_se" id="{{ sample.this_id }}">
- <td class="column_name-Index">
- {{ loop.index }}
- <input type="checkbox" name="selectCheck"
- class="checkbox edit_sample_checkbox"
- value="{{ sample.name }}" checked="checked">
- </td>
-
- <td class="column_name-Sample">
- <span class="edit_sample_sample_name">
- {{ sample.name }}
- </span>
- </td>
-
- {# Todo: Add IDs #}
- <td class="column_name-Value">
- <input type="text" data-value="{{ sample.display_value }}" name="{{ 'value:' + sample.name }}"
- class="trait_value_input edit_sample_value"
- value="{{ sample.display_value }}"
- size=8 maxlength=8
- >
- </td>
-
- {% if sample_type.se_exists() %}
- <td>
- ±
- </td>
-
- {# Todo: Add IDs #}
- <td class="column_name-SE">
- <input type="text" data-value="{{ sample.display_variance }}" name="{{ 'variance:' + sample.name}}"
- class="trait_value_input edit_sample_se"
- value="{{ sample.display_variance }}"
- size=8 maxlength=8
- >
- </td>
- {% endif %}
-
- {# Loop through each attribute type and input value #}
- {% for attribute in sample_type.attributes|sort() %}
- <td class="std_cell column_name-{{ sample_type.attributes[attribute].name.replace(' ', '_') }}">
- {{ sample.extra_attributes[sample_type.attributes[attribute].name] }}
- </td>
- {% endfor %}
- </tr>
- {% endfor %}
-
+ </tbody>
</table>
</div>
{% endfor %}
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py
index 828199c5..89820145 100644
--- a/wqflask/wqflask/views.py
+++ b/wqflask/wqflask/views.py
@@ -243,7 +243,12 @@ def marker_regression_page():
print(" ---**--- {}: {}".format(type(template_vars.__dict__[item]), item))
#causeerror
- Redis.set(key, pickle.dumps(result, pickle.HIGHEST_PROTOCOL))
+
+ #qtl_length = len(result['js_data']['qtl_results'])
+ #print("qtl_length:", qtl_length)
+ pickled_result = pickle.dumps(result, pickle.HIGHEST_PROTOCOL)
+ print("pickled result length:", len(pickled_result))
+ Redis.set(key, pickled_result)
Redis.expire(key, 60*60)
with Bench("Rendering template"):