aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--wqflask/wqflask/collect.py86
-rwxr-xr-xwqflask/wqflask/my_pylmm/pyLMM/lmm.py4
-rwxr-xr-xwqflask/wqflask/show_trait/show_trait.py35
-rw-r--r--wqflask/wqflask/static/new/javascript/chr_manhattan_plot.coffee85
-rw-r--r--wqflask/wqflask/static/new/javascript/chr_manhattan_plot.js60
-rw-r--r--wqflask/wqflask/static/new/javascript/marker_regression.coffee148
-rw-r--r--wqflask/wqflask/static/new/javascript/marker_regression.js88
-rw-r--r--wqflask/wqflask/templates/collections/view.html14
-rw-r--r--wqflask/wqflask/templates/marker_regression.html2
9 files changed, 392 insertions, 130 deletions
diff --git a/wqflask/wqflask/collect.py b/wqflask/wqflask/collect.py
index 34def295..a77e19af 100644
--- a/wqflask/wqflask/collect.py
+++ b/wqflask/wqflask/collect.py
@@ -44,28 +44,54 @@ from wqflask import user_manager
from base import trait
+def get_collection():
+ if g.user_session.logged_in:
+ return UserCollection()
+ else:
+ return AnonCollection()
+ #else:
+ # CauseError
+
class AnonCollection(object):
"""User is not logged in"""
def __init__(self):
self.anon_user = user_manager.AnonUser()
- self.key = "anon_collection:v1:{}".format(self.anon_user.anon_id)
-
+ self.key = "anon_collection:v4:{}".format(self.anon_user.anon_id)
- def add_traits(params, collection_name):
+ def add_traits(self, params, collection_name):
assert collection_name == "Default", "Unexpected collection name for anonymous user"
+ print("params[traits]:", params['traits'])
traits = process_traits(params['traits'])
- len_before = len(Redis.smembers)
- Redis.sadd(self.key, traits)
+ print("traits is:", traits)
+ print("self.key is:", self.key)
+ len_before = len(Redis.smembers(self.key))
+ Redis.sadd(self.key, *list(traits))
Redis.expire(self.key, 60 * 60 * 24 * 3)
- len_now = len(Redis.smembers)
+ print("currently in redis:", Redis.smembers(self.key))
+ len_now = len(Redis.smembers(self.key))
report_change(len_before, len_now)
+ def remove_traits(self, params):
+ traits_to_remove = params.getlist('traits[]')
+ print("traits_to_remove:", traits_to_remove)
+ len_before = len(Redis.smembers(self.key))
+ Redis.srem(self.key, traits_to_remove)
+ len_now = len(Redis.smembers(self.key))
+ print("Went from {} to {} members in set.".format(len(self.collection_members), len(members_now)))
+
+ # We need to return something so we'll return this...maybe in the future
+ # we can use it to check the results
+ return str(len(members_now))
+ def get_traits(self):
+ traits = Redis.smembers(self.key)
+ print("traits:", traits)
+ return traits
class UserCollection(object):
"""User is logged in"""
- def add_traits(params, collection_name):
+ def add_traits(self, params, collection_name):
print("---> params are:", params.keys())
print(" type(params):", type(params))
if collection_name=="Default":
@@ -94,15 +120,40 @@ class UserCollection(object):
# Probably have to change that
return redirect(url_for('view_collection', uc_id=uc.id))
+ def remove_traits(self, params):
+
+ #params = request.form
+ print("params are:", params)
+ uc_id = params['uc_id']
+ uc = model.UserCollection.query.get(uc_id)
+ traits_to_remove = params.getlist('traits[]')
+ print("traits_to_remove are:", traits_to_remove)
+ traits_to_remove = process_traits(traits_to_remove)
+ print("\n\n after processing, traits_to_remove:", traits_to_remove)
+ all_traits = uc.members_as_set()
+ print(" all_traits:", all_traits)
+ members_now = all_traits - traits_to_remove
+ print(" members_now:", members_now)
+ print("Went from {} to {} members in set.".format(len(all_traits), len(members_now)))
+ uc.members = json.dumps(list(members_now))
+ uc.changed_timestamp = datetime.datetime.utcnow()
+ db_session.commit()
+
+ # We need to return something so we'll return this...maybe in the future
+ # we can use it to check the results
+ return str(len(members_now))
+
def report_change(len_before, len_now):
new_length = len_now - len_before
if new_length:
+ print("We've added {} to your collection.".format(
+ numify(new_length, 'new trait', 'new traits')))
flash("We've added {} to your collection.".format(
numify(new_length, 'new trait', 'new traits')))
else:
- flash("No new traits were added.")
+ print("No new traits were added.")
+
-
@app.route("/collections/add")
@@ -128,7 +179,8 @@ def collections_new():
print("request.args in collections_new are:", params)
if "anonymous_add" in params:
- return add_anon_traits(params)
+ AnonCollection().add_traits(params, "Default")
+ return redirect(url_for('view_collection'))
collection_name = params['new_collection']
@@ -143,8 +195,6 @@ def collections_new():
CauseAnError
-
-
def process_traits(unprocessed_traits):
print("unprocessed_traits are:", unprocessed_traits)
if isinstance(unprocessed_traits, basestring):
@@ -239,11 +289,9 @@ def view_collection():
uc_id = params['uc_id']
uc = model.UserCollection.query.get(uc_id)
traits = json.loads(uc.members)
+ print("traits are:", traits)
else:
- anon_id = params['key']
- uc = model.AnonCollection(anon_id = anon_id)
- traits = Redis.smembers(anon_id)
- print("the traits are:", traits)
+ traits = AnonCollection().get_traits()
print("in view_collection traits are:", traits)
@@ -251,6 +299,7 @@ def view_collection():
json_version = []
for atrait in traits:
+ print("atrait is:", atrait)
name, dataset_name = atrait.split(':')
trait_ob = trait.GeneralTrait(name=name, dataset_name=dataset_name)
@@ -267,8 +316,9 @@ def view_collection():
# dis=trait_ob.description))
#json_version.append(trait_ob.__dict__th)
- collection_info = dict(trait_obs=trait_obs,
- uc = uc)
+ #collection_info = dict(trait_obs=trait_obs,
+ # uc = uc)
+ collection_info = dict(trait_obs=trait_obs)
if "json" in params:
print("json_version:", json_version)
return json.dumps(json_version)
diff --git a/wqflask/wqflask/my_pylmm/pyLMM/lmm.py b/wqflask/wqflask/my_pylmm/pyLMM/lmm.py
index a0ff31ef..04310083 100755
--- a/wqflask/wqflask/my_pylmm/pyLMM/lmm.py
+++ b/wqflask/wqflask/my_pylmm/pyLMM/lmm.py
@@ -714,7 +714,9 @@ def main():
json_params = Redis.get(key)
params = json.loads(json_params)
- print("params:", params)
+ #print("params:", params)
+
+ #print("kinship_matrix:", params['kinship_matrix'])
tempdata = temp_data.TempData(params['temp_uuid'])
if species == "human" :
diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py
index 7a3ae1e5..a46e33ee 100755
--- a/wqflask/wqflask/show_trait/show_trait.py
+++ b/wqflask/wqflask/show_trait/show_trait.py
@@ -1190,6 +1190,20 @@ class ShowTrait(object):
print("-*- primary_samplelist is:", pf(primary_sample_names))
+ other_sample_names = []
+ for sample in this_trait.data.keys():
+ if sample not in all_samples_ordered:
+ all_samples_ordered.append(sample)
+ other_sample_names.append(sample)
+
+ other_sample_names, all_samples_ordered = get_samplelist_from_trait_data(this_trait,
+ all_samples_ordered)
+
+
+ print("species:", self.dataset.group.species)
+ if self.dataset.group.species == "human":
+ primary_sample_names += other_sample_names
+
primary_samples = SampleList(dataset = self.dataset,
sample_names=primary_sample_names,
this_trait=this_trait,
@@ -1197,13 +1211,8 @@ class ShowTrait(object):
header="%s Only" % (self.dataset.group.name))
print("primary_samples is: ", pf(primary_samples))
- other_sample_names = []
- for sample in this_trait.data.keys():
- if sample not in all_samples_ordered:
- all_samples_ordered.append(sample)
- other_sample_names.append(sample)
-
- if other_sample_names:
+ print("other_sample_names2:", other_sample_names)
+ if other_sample_names and self.dataset.group.species != "human":
parent_f1_samples = None
if self.dataset.group.parlist and self.dataset.group.f1list:
parent_f1_samples = self.dataset.group.parlist + self.dataset.group.f1list
@@ -1212,6 +1221,8 @@ class ShowTrait(object):
if parent_f1_samples:
other_sample_names = parent_f1_samples + other_sample_names
+ print("other_sample_names:", other_sample_names)
+
other_samples = SampleList(dataset=self.dataset,
sample_names=other_sample_names,
this_trait=this_trait,
@@ -1227,3 +1238,13 @@ class ShowTrait(object):
# or (fd.f1list and this_trait.data.has_key(fd.f1list[1]))):
# print("hjs")
self.dataset.group.allsamples = all_samples_ordered
+
+
+def get_samplelist_from_trait_data(this_trait, all_samples_ordered):
+ other_sample_names = []
+ for sample in this_trait.data.keys():
+ if sample not in all_samples_ordered:
+ all_samples_ordered.append(sample)
+ other_sample_names.append(sample)
+
+ return other_sample_names, all_samples_ordered
diff --git a/wqflask/wqflask/static/new/javascript/chr_manhattan_plot.coffee b/wqflask/wqflask/static/new/javascript/chr_manhattan_plot.coffee
index 30e6ea5e..74eb2e88 100644
--- a/wqflask/wqflask/static/new/javascript/chr_manhattan_plot.coffee
+++ b/wqflask/wqflask/static/new/javascript/chr_manhattan_plot.coffee
@@ -29,6 +29,8 @@ class Chr_Manhattan_Plot
@x_max = d3.max(@x_coords)
@y_max = d3.max(@y_coords) * 1.2
+ @y_threshold = @get_lod_threshold()
+
@svg = @create_svg()
@plot_coordinates = _.zip(@x_coords, @y_coords, @marker_names)
@@ -100,11 +102,20 @@ class Chr_Manhattan_Plot
@y_scale = d3.scale.linear()
.domain([@y_axis_filter, @y_max])
.range([@plot_height, @y_buffer])
+
+ get_lod_threshold: () ->
+ if @y_max/2 > 2
+ return @y_max/2
+ else
+ return 2
+
create_graph: () ->
@add_border()
@add_x_axis()
@add_y_axis()
+ @add_title()
+ @add_back_button()
@add_plot_points()
add_border: () ->
@@ -164,7 +175,35 @@ class Chr_Manhattan_Plot
.attr("class", "y_axis")
.attr("transform", "translate(" + @x_buffer + ",0)")
.call(@yAxis)
-
+
+ add_title: () ->
+ @svg.append("text")
+ .attr("class", "title")
+ .text("Chr " + @chr[0])
+ .attr("x", (d) =>
+ return (@plot_width + @x_buffer)/2
+ )
+ .attr("y", @y_buffer + 20)
+ .attr("dx", "0em")
+ .attr("text-anchor", "middle")
+ .attr("font-family", "sans-serif")
+ .attr("font-size", "18px")
+ .attr("fill", "black")
+
+ add_back_button: () ->
+ @svg.append("text")
+ .attr("class", "back")
+ .text("Return to full view")
+ .attr("x", @x_buffer*2)
+ .attr("y", @y_buffer/2)
+ .attr("dx", "0em")
+ .attr("text-anchor", "middle")
+ .attr("font-family", "sans-serif")
+ .attr("font-size", "18px")
+ .attr("cursor", "pointer")
+ .attr("fill", "black")
+ .on("click", @return_to_full_view)
+
add_plot_points: () ->
@plot_point = @svg.selectAll("circle")
.data(@plot_coordinates)
@@ -176,7 +215,20 @@ class Chr_Manhattan_Plot
.attr("cy", (d) =>
return @y_scale(d[1])
)
- .attr("r", 2)
+ .attr("r", (d) =>
+ if d[1] > 2
+ return 3
+ else
+ return 2
+ )
+ .attr("fill", (d) =>
+ if d[1] > 2
+ return "white"
+ else
+ return "black"
+ )
+ .attr("stroke", "black")
+ .attr("stroke-width", "1")
.attr("id", (d) =>
return "point_" + String(d[2])
)
@@ -187,16 +239,37 @@ class Chr_Manhattan_Plot
this_id = "point_" + String(d[2])
d3.select("#" + this_id).classed("d3_highlight", true)
.attr("r", 5)
- .attr("fill", "yellow")
+ .attr("stroke", "none")
+ .attr("fill", "blue")
.call(@show_marker_in_table(d))
)
.on("mouseout", (d) =>
this_id = "point_" + String(d[2])
d3.select("#" + this_id).classed("d3_highlight", false)
- .attr("r", 2)
- .attr("fill", "black")
- #.call(@show_marker_in_table())
+ .attr("r", (d) =>
+ if d[1] > 2
+ return 3
+ else
+ return 2
+ )
+ .attr("fill", (d) =>
+ if d[1] > 2
+ return "white"
+ else
+ return "black"
+ )
+ .attr("stroke", "black")
+ .attr("stroke-width", "1")
)
+ .append("svg:title")
+ .text((d) =>
+ return d[2]
+ )
+
+ return_to_full_view: () ->
+ $('#manhattan_plot').remove()
+ $('#manhattan_plot_container').append('<div id="manhattan_plot"></div>')
+ root.manhattan_plot = new root.Manhattan_Plot
show_marker_in_table: (marker_info) ->
console.log("in show_marker_in_table")
diff --git a/wqflask/wqflask/static/new/javascript/chr_manhattan_plot.js b/wqflask/wqflask/static/new/javascript/chr_manhattan_plot.js
index 2cbab00c..a38cfe5d 100644
--- a/wqflask/wqflask/static/new/javascript/chr_manhattan_plot.js
+++ b/wqflask/wqflask/static/new/javascript/chr_manhattan_plot.js
@@ -29,6 +29,7 @@
this.y_buffer = this.plot_height / 20;
this.x_max = d3.max(this.x_coords);
this.y_max = d3.max(this.y_coords) * 1.2;
+ this.y_threshold = this.get_lod_threshold();
this.svg = this.create_svg();
this.plot_coordinates = _.zip(this.x_coords, this.y_coords, this.marker_names);
console.log("coordinates:", this.plot_coordinates);
@@ -125,10 +126,20 @@
return this.y_scale = d3.scale.linear().domain([this.y_axis_filter, this.y_max]).range([this.plot_height, this.y_buffer]);
};
+ Chr_Manhattan_Plot.prototype.get_lod_threshold = function() {
+ if (this.y_max / 2 > 2) {
+ return this.y_max / 2;
+ } else {
+ return 2;
+ }
+ };
+
Chr_Manhattan_Plot.prototype.create_graph = function() {
this.add_border();
this.add_x_axis();
this.add_y_axis();
+ this.add_title();
+ this.add_back_button();
return this.add_plot_points();
};
@@ -164,27 +175,70 @@
return this.svg.append("g").attr("class", "y_axis").attr("transform", "translate(" + this.x_buffer + ",0)").call(this.yAxis);
};
+ Chr_Manhattan_Plot.prototype.add_title = function() {
+ var _this = this;
+ return this.svg.append("text").attr("class", "title").text("Chr " + this.chr[0]).attr("x", function(d) {
+ return (_this.plot_width + _this.x_buffer) / 2;
+ }).attr("y", this.y_buffer + 20).attr("dx", "0em").attr("text-anchor", "middle").attr("font-family", "sans-serif").attr("font-size", "18px").attr("fill", "black");
+ };
+
+ Chr_Manhattan_Plot.prototype.add_back_button = function() {
+ return this.svg.append("text").attr("class", "back").text("Return to full view").attr("x", this.x_buffer * 2).attr("y", this.y_buffer / 2).attr("dx", "0em").attr("text-anchor", "middle").attr("font-family", "sans-serif").attr("font-size", "18px").attr("cursor", "pointer").attr("fill", "black").on("click", this.return_to_full_view);
+ };
+
Chr_Manhattan_Plot.prototype.add_plot_points = function() {
var _this = this;
return this.plot_point = this.svg.selectAll("circle").data(this.plot_coordinates).enter().append("circle").attr("cx", function(d) {
return _this.x_scale(d[0]);
}).attr("cy", function(d) {
return _this.y_scale(d[1]);
- }).attr("r", 2).attr("id", function(d) {
+ }).attr("r", function(d) {
+ if (d[1] > 2) {
+ return 3;
+ } else {
+ return 2;
+ }
+ }).attr("fill", function(d) {
+ if (d[1] > 2) {
+ return "white";
+ } else {
+ return "black";
+ }
+ }).attr("stroke", "black").attr("stroke-width", "1").attr("id", function(d) {
return "point_" + String(d[2]);
}).classed("circle", true).on("mouseover", function(d) {
var this_id;
console.log("d3.event is:", d3.event);
console.log("d is:", d);
this_id = "point_" + String(d[2]);
- return d3.select("#" + this_id).classed("d3_highlight", true).attr("r", 5).attr("fill", "yellow").call(_this.show_marker_in_table(d));
+ return d3.select("#" + this_id).classed("d3_highlight", true).attr("r", 5).attr("stroke", "none").attr("fill", "blue").call(_this.show_marker_in_table(d));
}).on("mouseout", function(d) {
var this_id;
this_id = "point_" + String(d[2]);
- return d3.select("#" + this_id).classed("d3_highlight", false).attr("r", 2).attr("fill", "black");
+ return d3.select("#" + this_id).classed("d3_highlight", false).attr("r", function(d) {
+ if (d[1] > 2) {
+ return 3;
+ } else {
+ return 2;
+ }
+ }).attr("fill", function(d) {
+ if (d[1] > 2) {
+ return "white";
+ } else {
+ return "black";
+ }
+ }).attr("stroke", "black").attr("stroke-width", "1");
+ }).append("svg:title").text(function(d) {
+ return d[2];
});
};
+ Chr_Manhattan_Plot.prototype.return_to_full_view = function() {
+ $('#manhattan_plot').remove();
+ $('#manhattan_plot_container').append('<div id="manhattan_plot"></div>');
+ return root.manhattan_plot = new root.Manhattan_Plot;
+ };
+
Chr_Manhattan_Plot.prototype.show_marker_in_table = function(marker_info) {
var marker_name;
console.log("in show_marker_in_table");
diff --git a/wqflask/wqflask/static/new/javascript/marker_regression.coffee b/wqflask/wqflask/static/new/javascript/marker_regression.coffee
index 091dab93..44f4d9f7 100644
--- a/wqflask/wqflask/static/new/javascript/marker_regression.coffee
+++ b/wqflask/wqflask/static/new/javascript/marker_regression.coffee
@@ -1,10 +1,11 @@
root = exports ? this
class Manhattan_Plot
- constructor: (@plot_height, @plot_width) ->
+ constructor: (@plot_height = 600, @plot_width = 1200) ->
@qtl_results = js_data.qtl_results
console.log("qtl_results are:", @qtl_results)
@chromosomes = js_data.chromosomes
+ console.log("chromosomes are:", @chromosomes)
@total_length = 0
@@ -31,6 +32,8 @@ class Manhattan_Plot
console.log("@x_buffer: ", @x_buffer)
@y_max = d3.max(@y_coords) * 1.2
+ @y_threshold = @get_lod_threshold()
+
@svg = @create_svg()
console.log("svg created")
@@ -62,8 +65,6 @@ class Manhattan_Plot
#
###
- console.log("@chromosomes: ", @chromosomes)
-
cumulative_chr_lengths = []
chr_lengths = []
total_length = 0
@@ -97,16 +98,18 @@ class Manhattan_Plot
chr_seen = []
for result in js_data.qtl_results
if result.chr == "X"
- chr_length = parseFloat(@chromosomes[20])
+ chr_length = parseFloat(@chromosomes[13])
else
- chr_length = parseFloat(@chromosomes[result.chr])
+ chr_length = parseFloat(@chromosomes[result.chr])
+ console.log("chr_seen is", chr_seen)
if not(result.chr in chr_seen)
chr_seen.push(result.chr)
chr_lengths.push(chr_length)
console.log("result.chr:", result.chr)
console.log("total_length:", @total_length)
if parseInt(result.chr) != 1
- console.log("plus:", chr_lengths.length - 2)
+ console.log("plus:", chr_lengths.length - 2)
+ console.log("chr_lengths.length", chr_lengths.length)
@total_length += parseFloat(chr_lengths[chr_lengths.length - 2])
if result.lod_score > @y_axis_filter
@x_coords.push(@total_length + parseFloat(result.Mb))
@@ -151,9 +154,10 @@ class Manhattan_Plot
@add_y_axis()
@add_axis_labels()
@add_chr_lines()
- #@fill_chr_areas()
+ @fill_chr_areas()
@add_chr_labels()
@add_plot_points()
+
#@create_zoom_pane()
add_border: () ->
@@ -298,51 +302,52 @@ class Manhattan_Plot
)
.enter()
.append("rect")
- .attr("x", (d) =>
- if i == 0
- return @x_scale(0)
- else
- return @x_scale(d[1])
+ .attr("x", (d, i) =>
+ return @x_scale(d[1] - d[0])
)
- .attr("y", @y_buffer)
- .attr("width", (d) =>
- return @x_scale(d[0])
+ .attr("y", @y_buffer + 2)
+ .attr("width", (d, i) =>
+ starting = @x_scale(d[1] - d[0])
+ ending = @x_scale(@cumulative_chr_lengths[i])
+ width = ending - starting
+ console.log("width:", d[0])
+ return width
)
- .attr("height", @plot_height-@y_buffer)
- #.attr("fill", (d, i) =>
- # if i%2
- # return "whitesmoke"
- # else
- # return "none"
- #)
-
- fill_chr_areas2: () ->
- console.log("cumu_chr_lengths:", @cumulative_chr_lengths)
- console.log("example:", @x_scale(@cumulative_chr_lengths[0]))
- @svg.selectAll("rect.chr_fill_area")
- .data(_.zip(@chr_lengths, @cumulative_chr_lengths), (d) =>
- return d
- )
- .enter()
- .append("rect")
- .attr("x", (d) =>
- if i == 0
- return @x_scale(0)
- else
- return @x_scale(d[1])
- )
- .attr("y", @y_buffer)
- .attr("width", (d) =>
- return @x_scale(d[0])
- )
- .attr("height", @plot_height-@y_buffer)
+ .attr("height", @plot_height-@y_buffer-3)
.attr("fill", (d, i) =>
- return "whitesmoke"
- #if i%2
- # return "whitesmoke"
- #else
- # return "none"
+ if (i+1)%2
+ return "none"
+ else
+ return "whitesmoke"
)
+
+ #fill_chr_areas2: () ->
+ # console.log("cumu_chr_lengths:", @cumulative_chr_lengths)
+ # console.log("example:", @x_scale(@cumulative_chr_lengths[0]))
+ # @svg.selectAll("rect.chr_fill_area")
+ # .data(_.zip(@chr_lengths, @cumulative_chr_lengths), (d) =>
+ # return d
+ # )
+ # .enter()
+ # .append("rect")
+ # .attr("x", (d) =>
+ # if i == 0
+ # return @x_scale(0)
+ # else
+ # return @x_scale(d[1])
+ # )
+ # .attr("y", @y_buffer)
+ # .attr("width", (d) =>
+ # return @x_scale(d[0])
+ # )
+ # .attr("height", @plot_height-@y_buffer)
+ # .attr("fill", (d, i) =>
+ # return "whitesmoke"
+ # #if i%2
+ # # return "whitesmoke"
+ # #else
+ # # return "none"
+ # )
add_chr_labels: () ->
chr_names = []
@@ -372,6 +377,7 @@ class Manhattan_Plot
.attr("text-anchor", "middle")
.attr("font-family", "sans-serif")
.attr("font-size", "18px")
+ .attr("cursor", "pointer")
.attr("fill", "black")
.on("click", (d) =>
this_chr = d
@@ -389,7 +395,20 @@ class Manhattan_Plot
.attr("cy", (d) =>
return @y_scale(d[1])
)
- .attr("r", 2)
+ .attr("r", (d) =>
+ if d[1] > 2
+ return 3
+ else
+ return 2
+ )
+ .attr("fill", (d) =>
+ if d[1] > 2
+ return "white"
+ else
+ return "black"
+ )
+ .attr("stroke", "black")
+ .attr("stroke-width", "1")
.attr("id", (d) =>
return "point_" + String(d[2])
)
@@ -400,15 +419,32 @@ class Manhattan_Plot
this_id = "point_" + String(d[2])
d3.select("#" + this_id).classed("d3_highlight", true)
.attr("r", 5)
- .attr("fill", "yellow")
+ .attr("stroke", "none")
+ .attr("fill", "blue")
.call(@show_marker_in_table(d))
)
.on("mouseout", (d) =>
this_id = "point_" + String(d[2])
d3.select("#" + this_id).classed("d3_highlight", false)
- .attr("r", 2)
- .attr("fill", "black")
+ .attr("r", (d) =>
+ if d[1] > 2
+ return 3
+ else
+ return 2
+ )
+ .attr("fill", (d) =>
+ if d[1] > 2
+ return "white"
+ else
+ return "black"
+ )
+ .attr("stroke", "black")
+ .attr("stroke-width", "1")
)
+ .append("svg:title")
+ .text((d) =>
+ return d[2]
+ )
redraw_plot: (chr_ob) ->
console.log("chr_name is:", chr_ob[0])
@@ -434,9 +470,7 @@ class Manhattan_Plot
@svg.select("path.area").attr("d", area);
@svg.select("path.line").attr("d", line);
-
- #console.time('Create manhattan plot')
- #new Manhattan_Plot(600, 1200)
- #console.timeEnd('Create manhattan plot')
-root.Manhattan_Plot = new Manhattan_Plot(600, 1200) \ No newline at end of file
+root.Manhattan_Plot = Manhattan_Plot
+
+new Manhattan_Plot(600, 1200) \ No newline at end of file
diff --git a/wqflask/wqflask/static/new/javascript/marker_regression.js b/wqflask/wqflask/static/new/javascript/marker_regression.js
index 86509316..1965e7aa 100644
--- a/wqflask/wqflask/static/new/javascript/marker_regression.js
+++ b/wqflask/wqflask/static/new/javascript/marker_regression.js
@@ -9,11 +9,12 @@
function Manhattan_Plot(plot_height, plot_width) {
var _ref;
- this.plot_height = plot_height;
- this.plot_width = plot_width;
+ this.plot_height = plot_height != null ? plot_height : 600;
+ this.plot_width = plot_width != null ? plot_width : 1200;
this.qtl_results = js_data.qtl_results;
console.log("qtl_results are:", this.qtl_results);
this.chromosomes = js_data.chromosomes;
+ console.log("chromosomes are:", this.chromosomes);
this.total_length = 0;
this.max_chr = this.get_max_chr();
this.x_coords = [];
@@ -32,6 +33,7 @@
console.log("@x_max: ", this.x_max);
console.log("@x_buffer: ", this.x_buffer);
this.y_max = d3.max(this.y_coords) * 1.2;
+ this.y_threshold = this.get_lod_threshold();
this.svg = this.create_svg();
console.log("svg created");
this.plot_coordinates = _.zip(this.x_coords, this.y_coords, this.marker_names);
@@ -68,7 +70,6 @@
*/
var chr_lengths, cumulative_chr_lengths, key, this_length, total_length;
- console.log("@chromosomes: ", this.chromosomes);
cumulative_chr_lengths = [];
chr_lengths = [];
total_length = 0;
@@ -110,10 +111,11 @@
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
result = _ref[_i];
if (result.chr === "X") {
- chr_length = parseFloat(this.chromosomes[20]);
+ chr_length = parseFloat(this.chromosomes[13]);
} else {
chr_length = parseFloat(this.chromosomes[result.chr]);
}
+ console.log("chr_seen is", chr_seen);
if (!(_ref1 = result.chr, __indexOf.call(chr_seen, _ref1) >= 0)) {
chr_seen.push(result.chr);
chr_lengths.push(chr_length);
@@ -121,6 +123,7 @@
console.log("total_length:", this.total_length);
if (parseInt(result.chr) !== 1) {
console.log("plus:", chr_lengths.length - 2);
+ console.log("chr_lengths.length", chr_lengths.length);
this.total_length += parseFloat(chr_lengths[chr_lengths.length - 2]);
}
}
@@ -157,6 +160,7 @@
this.add_y_axis();
this.add_axis_labels();
this.add_chr_lines();
+ this.fill_chr_areas();
this.add_chr_labels();
return this.add_plot_points();
};
@@ -266,33 +270,21 @@
console.log("example:", this.x_scale(this.cumulative_chr_lengths[0]));
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("x", function(d) {
- if (i === 0) {
- return _this.x_scale(0);
- } else {
- return _this.x_scale(d[1]);
- }
- }).attr("y", this.y_buffer).attr("width", function(d) {
- return _this.x_scale(d[0]);
- }).attr("height", this.plot_height - this.y_buffer);
- };
-
- Manhattan_Plot.prototype.fill_chr_areas2 = function() {
- var _this = this;
- console.log("cumu_chr_lengths:", this.cumulative_chr_lengths);
- console.log("example:", this.x_scale(this.cumulative_chr_lengths[0]));
- 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("x", function(d) {
- if (i === 0) {
- return _this.x_scale(0);
+ }).enter().append("rect").attr("x", function(d, i) {
+ return _this.x_scale(d[1] - d[0]);
+ }).attr("y", this.y_buffer + 2).attr("width", function(d, i) {
+ var ending, starting, width;
+ starting = _this.x_scale(d[1] - d[0]);
+ ending = _this.x_scale(_this.cumulative_chr_lengths[i]);
+ width = ending - starting;
+ console.log("width:", d[0]);
+ return width;
+ }).attr("height", this.plot_height - this.y_buffer - 3).attr("fill", function(d, i) {
+ if ((i + 1) % 2) {
+ return "none";
} else {
- return _this.x_scale(d[1]);
+ return "whitesmoke";
}
- }).attr("y", this.y_buffer).attr("width", function(d) {
- return _this.x_scale(d[0]);
- }).attr("height", this.plot_height - this.y_buffer).attr("fill", function(d, i) {
- return "whitesmoke";
});
};
@@ -316,7 +308,7 @@
}
}).attr("x", function(d) {
return _this.x_scale(d[2] - d[1] / 2);
- }).attr("y", this.plot_height * 0.1).attr("dx", "0em").attr("text-anchor", "middle").attr("font-family", "sans-serif").attr("font-size", "18px").attr("fill", "black").on("click", function(d) {
+ }).attr("y", this.plot_height * 0.1).attr("dx", "0em").attr("text-anchor", "middle").attr("font-family", "sans-serif").attr("font-size", "18px").attr("cursor", "pointer").attr("fill", "black").on("click", function(d) {
var this_chr;
this_chr = d;
return _this.redraw_plot(d);
@@ -329,18 +321,44 @@
return _this.x_scale(d[0]);
}).attr("cy", function(d) {
return _this.y_scale(d[1]);
- }).attr("r", 2).attr("id", function(d) {
+ }).attr("r", function(d) {
+ if (d[1] > 2) {
+ return 3;
+ } else {
+ return 2;
+ }
+ }).attr("fill", function(d) {
+ if (d[1] > 2) {
+ return "white";
+ } else {
+ return "black";
+ }
+ }).attr("stroke", "black").attr("stroke-width", "1").attr("id", function(d) {
return "point_" + String(d[2]);
}).classed("circle", true).on("mouseover", function(d) {
var this_id;
console.log("d3.event is:", d3.event);
console.log("d is:", d);
this_id = "point_" + String(d[2]);
- return d3.select("#" + this_id).classed("d3_highlight", true).attr("r", 5).attr("fill", "yellow").call(_this.show_marker_in_table(d));
+ return d3.select("#" + this_id).classed("d3_highlight", true).attr("r", 5).attr("stroke", "none").attr("fill", "blue").call(_this.show_marker_in_table(d));
}).on("mouseout", function(d) {
var this_id;
this_id = "point_" + String(d[2]);
- return d3.select("#" + this_id).classed("d3_highlight", false).attr("r", 2).attr("fill", "black");
+ return d3.select("#" + this_id).classed("d3_highlight", false).attr("r", function(d) {
+ if (d[1] > 2) {
+ return 3;
+ } else {
+ return 2;
+ }
+ }).attr("fill", function(d) {
+ if (d[1] > 2) {
+ return "white";
+ } else {
+ return "black";
+ }
+ }).attr("stroke", "black").attr("stroke-width", "1");
+ }).append("svg:title").text(function(d) {
+ return d[2];
});
};
@@ -369,6 +387,8 @@
})();
- root.Manhattan_Plot = new Manhattan_Plot(600, 1200);
+ root.Manhattan_Plot = Manhattan_Plot;
+
+ new Manhattan_Plot(600, 1200);
}).call(this);
diff --git a/wqflask/wqflask/templates/collections/view.html b/wqflask/wqflask/templates/collections/view.html
index 7f588e84..d826b63e 100644
--- a/wqflask/wqflask/templates/collections/view.html
+++ b/wqflask/wqflask/templates/collections/view.html
@@ -2,16 +2,24 @@
{% block title %}View Collection{% endblock %}
{% block content %}
<!-- Start of body -->
- {{ header(uc.name,
- 'This collection has {}.'.format(numify(trait_obs|count, "record", "records"))) }}
-
+ {% if uc %}
+ {{ header(uc.name,
+ 'This collection has {}.'.format(numify(trait_obs|count, "record", "records"))) }}
+ {% else %}
+ {{ header('Your Collection',
+ 'This collection has {}.'.format(numify(trait_obs|count, "record", "records"))) }}
+ {% endif %}
<div class="container">
<div class="page-header">
<h1>Your Collection</h1>
+ {% if uc %}
<h2>{{ uc.name }}</h2>
+ {% endif %}
<form action="/collections/delete" method="post">
+ {% if uc %}
<input type="hidden" name="uc_id" id="uc_id" value="{{ uc.id }}" />
+ {% endif %}
<input type="submit"
class="btn btn-small btn-danger"
value="Delete this collection" />
diff --git a/wqflask/wqflask/templates/marker_regression.html b/wqflask/wqflask/templates/marker_regression.html
index 05fb9845..e05e45fd 100644
--- a/wqflask/wqflask/templates/marker_regression.html
+++ b/wqflask/wqflask/templates/marker_regression.html
@@ -73,8 +73,8 @@
<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 language="javascript" type="text/javascript" src="/static/packages/underscore/underscore-min.js"></script>
- <script language="javascript" type="text/javascript" src="/static/new/javascript/marker_regression.js"></script>
<script language="javascript" type="text/javascript" src="/static/new/javascript/chr_manhattan_plot.js"></script>
+ <script language="javascript" type="text/javascript" src="/static/new/javascript/marker_regression.js"></script>
<script type="text/javascript" charset="utf-8">