aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
authorZachary Sloan2013-04-09 19:36:43 +0000
committerZachary Sloan2013-04-09 19:36:43 +0000
commitc7c306c69254ca49ddeccc495a8a096fcf03974d (patch)
treed022224c537e4b297836e94209a292b17c6765a8 /wqflask
parent27d0c86528fdbeaed56a7f5eaa71a950c522f183 (diff)
downloadgenenetwork2-c7c306c69254ca49ddeccc495a8a096fcf03974d.tar.gz
Nick's code works fine with human data
Added option to limit results based on lod score (which also changes the y-axis of the plot)
Diffstat (limited to 'wqflask')
-rwxr-xr-xwqflask/base/data_set.py2
-rw-r--r--wqflask/base/species.py10
-rwxr-xr-xwqflask/wqflask/marker_regression/marker_regression.py13
-rw-r--r--wqflask/wqflask/my_pylmm/pyLMM/lmm.py4
-rw-r--r--wqflask/wqflask/static/new/javascript/marker_regression.coffee16
-rw-r--r--wqflask/wqflask/static/new/javascript/marker_regression.js12
-rw-r--r--wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.coffee12
-rw-r--r--wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js11
-rw-r--r--wqflask/wqflask/templates/show_trait_mapping_tools.html22
-rw-r--r--wqflask/wqflask/views.py1
10 files changed, 62 insertions, 41 deletions
diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py
index 16bc4ba4..111597a9 100755
--- a/wqflask/base/data_set.py
+++ b/wqflask/base/data_set.py
@@ -83,8 +83,6 @@ class Markers(object):
marker['lod_score'] = -math.log10(marker['p_value'])
#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
-
-
class HumanMarkers(Markers):
diff --git a/wqflask/base/species.py b/wqflask/base/species.py
index 689e5c05..191f4535 100644
--- a/wqflask/base/species.py
+++ b/wqflask/base/species.py
@@ -16,8 +16,7 @@ class TheSpecies(object):
print("self.dataset is:", pf(self.dataset.__dict__))
self.chromosomes = Chromosomes(self.dataset)
self.genome_mb_length = self.chromosomes.get_genome_mb_length()
-
-
+
#@property
#def chromosomes(self):
# chromosomes = [("All", -1)]
@@ -31,7 +30,8 @@ class TheSpecies(object):
# return chromosomes
class IndChromosome(object):
- def __init__(self, length):
+ def __init__(self, name, length):
+ self.name = name
self.length = length
@property
@@ -50,7 +50,7 @@ class Chromosomes(object):
results = g.db.execute("""
Select
- Chr_Length.Name, Length from Chr_Length, InbredSet
+ Chr_Length.Name, Chr_Length.OrderId, Length from Chr_Length, InbredSet
where
Chr_Length.SpeciesId = InbredSet.SpeciesId AND
InbredSet.Name = %s
@@ -59,7 +59,7 @@ class Chromosomes(object):
print("bike:", results)
for item in results:
- self.chromosomes[item.Name] = IndChromosome(item.Length)
+ self.chromosomes[item.OrderId] = IndChromosome(item.Name, item.Length)
self.set_mb_graph_interval()
#self.get_cm_length_list()
diff --git a/wqflask/wqflask/marker_regression/marker_regression.py b/wqflask/wqflask/marker_regression/marker_regression.py
index 545c8162..86d9fe06 100755
--- a/wqflask/wqflask/marker_regression/marker_regression.py
+++ b/wqflask/wqflask/marker_regression/marker_regression.py
@@ -41,6 +41,8 @@ class MarkerRegression(object):
self.samples = [] # Want only ones with values
self.vals = []
+ print("start_vars: ", pf(start_vars))
+ self.suggestive = float(start_vars['suggestive'])
for sample in self.dataset.group.samplelist:
value = start_vars['value:' + sample]
@@ -50,12 +52,13 @@ class MarkerRegression(object):
self.gen_data(tempdata)
#Get chromosome lengths for drawing the manhattan plot
- chromosome_mb_lengths = {}
+ chromosomes = {}
for key in self.species.chromosomes.chromosomes.keys():
- chromosome_mb_lengths[key] = self.species.chromosomes.chromosomes[key].mb_length
+ this_chr = self.species.chromosomes.chromosomes[key]
+ chromosomes[key] = [this_chr.name, this_chr.mb_length]
self.js_data = dict(
- chromosomes = chromosome_mb_lengths,
+ chromosomes = chromosomes,
qtl_results = self.qtl_results,
)
@@ -87,12 +90,12 @@ class MarkerRegression(object):
refit=False,
temp_data=tempdata
)
-
+
self.dataset.group.markers.add_pvalues(p_values)
self.qtl_results = []
for marker in self.dataset.group.markers.markers:
- if marker['p_value'] < 0.2:
+ if marker['lod_score'] >= self.suggestive:
self.qtl_results.append(marker)
#self.qtl_results = self.dataset.group.markers.markers
diff --git a/wqflask/wqflask/my_pylmm/pyLMM/lmm.py b/wqflask/wqflask/my_pylmm/pyLMM/lmm.py
index 0e965c8e..e5978933 100644
--- a/wqflask/wqflask/my_pylmm/pyLMM/lmm.py
+++ b/wqflask/wqflask/my_pylmm/pyLMM/lmm.py
@@ -66,8 +66,8 @@ def run_human(pheno_vector,
with Bench("snp iterator loop"):
count = 0
for snp, this_id in plink_input:
- #if count > 5000:
- # break
+ if count > 5000:
+ break
count += 1
diff --git a/wqflask/wqflask/static/new/javascript/marker_regression.coffee b/wqflask/wqflask/static/new/javascript/marker_regression.coffee
index 78b6fdbc..fd1fac54 100644
--- a/wqflask/wqflask/static/new/javascript/marker_regression.coffee
+++ b/wqflask/wqflask/static/new/javascript/marker_regression.coffee
@@ -25,6 +25,7 @@ $ ->
#@x_max = d3.max(@x_coords)
@x_max = @total_length
+ @y_min = d3.min(@y_coords)
@y_max = d3.max(@y_coords) * 1.2
@svg = @create_svg()
@@ -57,7 +58,7 @@ $ ->
chr_lengths = []
total_length = 0
for key of @chromosomes
- this_length = @chromosomes[key]
+ this_length = @chromosomes[key][1]
chr_lengths.push(this_length)
cumulative_chr_lengths.push(total_length + this_length)
total_length += this_length
@@ -70,10 +71,11 @@ $ ->
chr_lengths = []
chr_seen = []
for result in js_data.qtl_results
- chr_length = @chromosomes[result.chr]
+ chr_length = @chromosomes[result.chr][1]
if not(result.chr in chr_seen)
chr_seen.push(result.chr)
- chr_lengths.push(chr_length)
+ chr_lengths.push(chr_length)
+
if result.chr != "1"
@total_length += chr_lengths[chr_lengths.length - 2]
@x_coords.push(@total_length + parseFloat(result.Mb))
@@ -104,7 +106,7 @@ $ ->
@add_x_axis()
@add_y_axis()
@add_chr_lines()
- @fill_chr_areas()
+ #@fill_chr_areas()
@add_chr_labels()
@add_plot_points()
@@ -138,7 +140,7 @@ $ ->
.range([@x_buffer, @plot_width])
@y_scale = d3.scale.linear()
- .domain([0, @y_max])
+ .domain([@y_min, @y_max])
.range([@plot_height, @y_buffer])
create_x_axis_tick_values: () ->
@@ -244,7 +246,7 @@ $ ->
add_chr_labels: () ->
chr_names = []
for key of @chromosomes
- chr_names.push(key)
+ chr_names.push(@chromosomes[key][0])
chr_info = _.zip(chr_names, @chr_lengths, @cumulative_chr_lengths)
@svg.selectAll("text")
.data(chr_info, (d) =>
@@ -274,7 +276,7 @@ $ ->
return @x_buffer + ((@plot_width-@x_buffer) * d[0]/@x_max)
)
.attr("cy", (d) =>
- return @plot_height - ((@plot_height-@y_buffer) * d[1]/@y_max)
+ return @plot_height - ((@plot_height-@y_buffer) * (d[1]-@y_min)/@y_max)
)
.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 25d88ec0..37a4e1e5 100644
--- a/wqflask/wqflask/static/new/javascript/marker_regression.js
+++ b/wqflask/wqflask/static/new/javascript/marker_regression.js
@@ -27,6 +27,7 @@
this.x_buffer = this.plot_width / 30;
this.y_buffer = this.plot_height / 20;
this.x_max = this.total_length;
+ this.y_min = d3.min(this.y_coords);
this.y_max = d3.max(this.y_coords) * 1.2;
this.svg = this.create_svg();
this.plot_coordinates = _.zip(this.x_coords, this.y_coords, this.marker_names);
@@ -65,7 +66,7 @@
chr_lengths = [];
total_length = 0;
for (key in this.chromosomes) {
- this_length = this.chromosomes[key];
+ this_length = this.chromosomes[key][1];
chr_lengths.push(this_length);
cumulative_chr_lengths.push(total_length + this_length);
total_length += this_length;
@@ -80,7 +81,7 @@
_ref = js_data.qtl_results;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
result = _ref[_i];
- chr_length = this.chromosomes[result.chr];
+ chr_length = this.chromosomes[result.chr][1];
if (!(_ref1 = result.chr, __indexOf.call(chr_seen, _ref1) >= 0)) {
chr_seen.push(result.chr);
chr_lengths.push(chr_length);
@@ -120,7 +121,6 @@
this.add_x_axis();
this.add_y_axis();
this.add_chr_lines();
- this.fill_chr_areas();
this.add_chr_labels();
return this.add_plot_points();
};
@@ -142,7 +142,7 @@
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]);
+ return this.y_scale = d3.scale.linear().domain([this.y_min, this.y_max]).range([this.plot_height, this.y_buffer]);
};
Manhattan_Plot.prototype.create_x_axis_tick_values = function() {
@@ -233,7 +233,7 @@
_this = this;
chr_names = [];
for (key in this.chromosomes) {
- chr_names.push(key);
+ chr_names.push(this.chromosomes[key][0]);
}
chr_info = _.zip(chr_names, this.chr_lengths, this.cumulative_chr_lengths);
return this.svg.selectAll("text").data(chr_info, function(d) {
@@ -250,7 +250,7 @@
return this.svg.selectAll("circle").data(this.plot_coordinates).enter().append("circle").attr("cx", function(d) {
return _this.x_buffer + ((_this.plot_width - _this.x_buffer) * d[0] / _this.x_max);
}).attr("cy", function(d) {
- return _this.plot_height - ((_this.plot_height - _this.y_buffer) * d[1] / _this.y_max);
+ return _this.plot_height - ((_this.plot_height - _this.y_buffer) * (d[1] - _this.y_min) / _this.y_max);
}).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_mapping_tools.coffee b/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.coffee
index bc176ab9..03f872ca 100644
--- a/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.coffee
+++ b/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.coffee
@@ -60,7 +60,17 @@ $ ->
)
return false
- $("#marker_regression").click(() =>
+ $('#suggestive').hide()
+
+ $('input[name=display_all]').change(() =>
+ console.log("check")
+ if $('input[name=display_all]:checked').val() == "False"
+ $('#suggestive').show()
+ else
+ $('#suggestive').hide()
+ )
+
+ $("#marker_regression_compute").click(() =>
$("#progress_bar_container").modal()
url = "/marker_regression"
form_data = $('#trait_data_form').serialize()
diff --git a/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js b/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js
index b017257a..329dcdd9 100644
--- a/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js
+++ b/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js
@@ -62,7 +62,16 @@
});
return false;
};
- $("#marker_regression").click(function() {
+ $('#suggestive').hide();
+ $('input[name=display_all]').change(function() {
+ console.log("check");
+ if ($('input[name=display_all]:checked').val() === "False") {
+ return $('#suggestive').show();
+ } else {
+ return $('#suggestive').hide();
+ }
+ });
+ $("#marker_regression_compute").click(function() {
var form_data, url;
$("#progress_bar_container").modal();
url = "/marker_regression";
diff --git a/wqflask/wqflask/templates/show_trait_mapping_tools.html b/wqflask/wqflask/templates/show_trait_mapping_tools.html
index a98a75c7..c2d5211f 100644
--- a/wqflask/wqflask/templates/show_trait_mapping_tools.html
+++ b/wqflask/wqflask/templates/show_trait_mapping_tools.html
@@ -95,26 +95,24 @@
</div>
<div class="tab-pane" id="marker_regression">
- <div class="control-group" id="display_all_lrs">
- <label class="control-label">Display all LRS</label>
+ <div class="control-group" id="display_all_div">
+ <label class="control-label">Display all</label>
<div class="controls">
<label class="radio inline">
- <input type="radio" name="display_all_lrs"
- id="display_all_lrs" value=True>
+ <input type="radio" name="display_all" value="True" checked>
Yes
</label>
<label class="radio inline">
- <input type="radio" name="display_all_lrs"
- id="display_all_lrs" value=False checked>
+ <input type="radio" name="display_all" value="False">
No
</label>
</div>
- </div>
- <div class="control-group">
- <label for="suggestive_lrs" class="control-label"
- title="Control Locus">LRS greater than</label>
+ </div>
+ <div class="control-group" id="suggestive" >
+ <label for="suggestive" class="control-label"
+ title="Control Locus">LOD score greater than: </label>
<div class="controls">
- <input name="suggestive_lrs" id="suggestive_lrs" type="text" />
+ <input name="suggestive" type="text" value="0"/>
</div>
</div>
@@ -127,7 +125,7 @@
<div class="control-group">
<div class="controls">
- <button id="marker_regression"
+ <button id="marker_regression_compute"
class="btn btn-inverse submit_special"
data-url="/marker_regression"
title="Compute Marker Regression">
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py
index c303e0d1..eb7ae8f8 100644
--- a/wqflask/wqflask/views.py
+++ b/wqflask/wqflask/views.py
@@ -161,6 +161,7 @@ def marker_regression_page():
wanted = (
'trait_id',
'dataset',
+ 'suggestive'
)
start_vars = {}