aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZachary Sloan2014-01-29 19:01:45 +0000
committerZachary Sloan2014-01-29 19:01:45 +0000
commitd8dae52c0b534a37697962326f0fcbac781b0ce1 (patch)
treea5aff47bd70556bd7e12e2caf377e1ec40dcc2cd
parent2df34255de526e1e016100a8772d2c8e10eb970f (diff)
downloadgenenetwork2-d8dae52c0b534a37697962326f0fcbac781b0ce1.tar.gz
Limited number of markers in marker regression result table to
those with a lod score > 2 Did some work towards adding the colored backgrounds to chromosome areas in the manhattan plot Changed the last two chromosomes for human manhattan plots to X and X/Y Started work on writing a script that can independently run the pyLMM code and store the results in redis
-rwxr-xr-xwqflask/base/data_set.py1
-rwxr-xr-xwqflask/wqflask/marker_regression/marker_regression.py5
-rw-r--r--wqflask/wqflask/my_pylmm/run_pylmm.py2
-rw-r--r--wqflask/wqflask/static/new/javascript/marker_regression.coffee80
-rw-r--r--wqflask/wqflask/static/new/javascript/marker_regression.js56
-rw-r--r--wqflask/wqflask/static/new/javascript/show_trait.coffee1
-rw-r--r--wqflask/wqflask/static/new/javascript/show_trait.js1
-rw-r--r--wqflask/wqflask/templates/marker_regression.html16
-rw-r--r--wqflask/wqflask/templates/show_trait.html4
-rw-r--r--wqflask/wqflask/templates/show_trait_mapping_tools.html2
10 files changed, 127 insertions, 41 deletions
diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py
index 0d295bed..9fbccf80 100755
--- a/wqflask/base/data_set.py
+++ b/wqflask/base/data_set.py
@@ -169,7 +169,6 @@ class Markers(object):
for marker, p_value in itertools.izip(self.markers, p_values):
marker['p_value'] = p_value
if math.isnan(marker['p_value']) or marker['p_value'] <= 0:
- print("p_value is:", marker['p_value'])
marker['lod_score'] = 0
marker['lrs_value'] = 0
else:
diff --git a/wqflask/wqflask/marker_regression/marker_regression.py b/wqflask/wqflask/marker_regression/marker_regression.py
index fa9e0b67..5fa288df 100755
--- a/wqflask/wqflask/marker_regression/marker_regression.py
+++ b/wqflask/wqflask/marker_regression/marker_regression.py
@@ -158,6 +158,11 @@ def create_snp_iterator_file(group):
with gzip.open(snp_file_base, "wb") as fh:
pickle.dump(data, fh, pickle.HIGHEST_PROTOCOL)
+#if __name__ == '__main__':
+# import cPickle as pickle
+# import gzip
+# create_snp_iterator_file("HLC")
+
if __name__ == '__main__':
import cPickle as pickle
import gzip
diff --git a/wqflask/wqflask/my_pylmm/run_pylmm.py b/wqflask/wqflask/my_pylmm/run_pylmm.py
index 9ac03ad2..0c96d986 100644
--- a/wqflask/wqflask/my_pylmm/run_pylmm.py
+++ b/wqflask/wqflask/my_pylmm/run_pylmm.py
@@ -28,7 +28,7 @@ from base.species import TheSpecies
if dataset.group.species == "human":
p_values, t_stats = gen_human_results(pheno_vector, tempdata)
else:
- genotype_data = [marker['genotypes'] for marker in self.dataset.group.markers.markers]
+ genotype_data = [marker['genotypes'] for marker in dataset.group.markers.markers]
no_val_samples = self.identify_empty_samples()
trimmed_genotype_data = self.trim_genotypes(genotype_data, no_val_samples)
diff --git a/wqflask/wqflask/static/new/javascript/marker_regression.coffee b/wqflask/wqflask/static/new/javascript/marker_regression.coffee
index 93d3b5de..2063e638 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()
@@ -85,8 +85,10 @@ $ ->
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("result.chr:", result.chr)
+ console.log("total_length:", @total_length)
if result.chr != 1
+ console.log("plus:", chr_lengths.length - 2)
@total_length += parseFloat(chr_lengths[chr_lengths.length - 2])
#console.log("total_length3:", @total_length)
#console.log("Mb:", result.Mb)
@@ -120,7 +122,7 @@ $ ->
@add_x_axis()
@add_y_axis()
@add_chr_lines()
- @fill_chr_areas()
+ #@fill_chr_areas()
@add_chr_labels()
@add_plot_points()
@@ -152,14 +154,18 @@ $ ->
#@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, (@total_length + @chromosomes['24'])])
- .range([@x_buffer, @plot_width])
-
+ if '24' of @chromosomes
+ 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, (@total_length + @chromosomes['24'])])
+ .range([@x_buffer, @plot_width])
+ else
+ @x_scale = d3.scale.linear()
+ .domain([0, (@total_length + @chromosomes['20'])])
+ .range([@x_buffer, @plot_width])
@y_scale = d3.scale.linear()
.domain([2, @y_max])
.range([@plot_height, @y_buffer])
@@ -244,26 +250,61 @@ $ ->
.attr("y2", @plot_height)
.style("stroke", "#ccc")
+
fill_chr_areas: () ->
+ 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) =>
+ # 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("class", "chr_fill_area")
- .attr("x", (d, i) =>
+ .attr("x", (d) =>
if i == 0
return @x_scale(0)
else
- return @x_scale(@cumulative_chr_lengths[i-1])
+ 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", "none")
+ .attr("fill", (d, i) =>
+ return "whitesmoke"
+ #if i%2
+ # return "whitesmoke"
+ #else
+ # return "none"
+ )
add_chr_labels: () ->
chr_names = []
@@ -277,7 +318,12 @@ $ ->
.enter()
.append("text")
.text((d) =>
- return d[0]
+ if d[0] == "23"
+ return "X"
+ else if d[0] == "24"
+ return "X/Y"
+ else
+ return d[0]
)
.attr("x", (d) =>
return @x_scale(d[2] - d[1]/2)
@@ -287,7 +333,7 @@ $ ->
.attr("text-anchor", "middle")
.attr("font-family", "sans-serif")
.attr("font-size", "18px")
- .attr("fill", "grey")
+ .attr("fill", "black")
add_plot_points: () ->
@svg.selectAll("circle")
diff --git a/wqflask/wqflask/static/new/javascript/marker_regression.js b/wqflask/wqflask/static/new/javascript/marker_regression.js
index 8e5b6c11..af6e0dbe 100644
--- a/wqflask/wqflask/static/new/javascript/marker_regression.js
+++ b/wqflask/wqflask/static/new/javascript/marker_regression.js
@@ -20,6 +20,7 @@
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];
@@ -93,7 +94,10 @@
if (!(_ref1 = result.chr, __indexOf.call(chr_seen, _ref1) >= 0)) {
chr_seen.push(result.chr);
chr_lengths.push(chr_length);
+ console.log("result.chr:", result.chr);
+ console.log("total_length:", this.total_length);
if (result.chr !== 1) {
+ console.log("plus:", chr_lengths.length - 2);
this.total_length += parseFloat(chr_lengths[chr_lengths.length - 2]);
}
}
@@ -131,7 +135,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();
};
@@ -152,11 +155,15 @@
};
Manhattan_Plot.prototype.create_scales = function() {
- 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]);
+ if ('24' in this.chromosomes) {
+ 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]);
+ } else {
+ this.x_scale = d3.scale.linear().domain([0, this.total_length + this.chromosomes['20']]).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]);
};
@@ -230,17 +237,38 @@
Manhattan_Plot.prototype.fill_chr_areas = 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("class", "chr_fill_area").attr("x", function(d, i) {
+ }).enter().append("rect").attr("x", function(d) {
if (i === 0) {
return _this.x_scale(0);
} else {
- return _this.x_scale(_this.cumulative_chr_lengths[i - 1]);
+ 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).attr("fill", "none");
+ }).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);
+ } 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).attr("fill", function(d, i) {
+ return "whitesmoke";
+ });
};
Manhattan_Plot.prototype.add_chr_labels = function() {
@@ -254,10 +282,16 @@
return this.svg.selectAll("text").data(chr_info, function(d) {
return d;
}).enter().append("text").text(function(d) {
- return d[0];
+ if (d[0] === "23") {
+ return "X";
+ } else if (d[0] === "24") {
+ return "X/Y";
+ } else {
+ return d[0];
+ }
}).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", "grey");
+ }).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");
};
Manhattan_Plot.prototype.add_plot_points = function() {
diff --git a/wqflask/wqflask/static/new/javascript/show_trait.coffee b/wqflask/wqflask/static/new/javascript/show_trait.coffee
index e45bb0be..84e465e8 100644
--- a/wqflask/wqflask/static/new/javascript/show_trait.coffee
+++ b/wqflask/wqflask/static/new/javascript/show_trait.coffee
@@ -125,6 +125,7 @@ $ ->
console.log("*-* the_value:", the_value)
console.log("*-* current_value:", current_value)
if the_value != current_value
+ console.log("object:", $(id).html(the_value))
$(id).html(the_value).effect("highlight")
# We go ahead and always change the title value if we have it
diff --git a/wqflask/wqflask/static/new/javascript/show_trait.js b/wqflask/wqflask/static/new/javascript/show_trait.js
index c28b05f5..d4e01e6d 100644
--- a/wqflask/wqflask/static/new/javascript/show_trait.js
+++ b/wqflask/wqflask/static/new/javascript/show_trait.js
@@ -123,6 +123,7 @@
console.log("*-* the_value:", the_value);
console.log("*-* current_value:", current_value);
if (the_value !== current_value) {
+ console.log("object:", $(id).html(the_value));
$(id).html(the_value).effect("highlight");
}
if (title_value) {
diff --git a/wqflask/wqflask/templates/marker_regression.html b/wqflask/wqflask/templates/marker_regression.html
index c1d4d7e5..61a18e66 100644
--- a/wqflask/wqflask/templates/marker_regression.html
+++ b/wqflask/wqflask/templates/marker_regression.html
@@ -39,13 +39,15 @@
</thead>
<tbody>
{% for marker in qtl_results %}
- <tr>
- <td>{{loop.index}}</td>
- <td>{{marker.lod_score}}</td>
- <td>{{marker.chr}}</td>
- <td>{{marker.Mb}}</td>
- <td>{{marker.name}}</td>
- </tr>
+ {% if marker.lod_score > 2 %}
+ <tr>
+ <td>{{loop.index}}</td>
+ <td>{{marker.lod_score}}</td>
+ <td>{{marker.chr}}</td>
+ <td>{{marker.Mb}}</td>
+ <td>{{marker.name}}</td>
+ </tr>
+ {% endif %}
{% endfor %}
</tbody>
</table>
diff --git a/wqflask/wqflask/templates/show_trait.html b/wqflask/wqflask/templates/show_trait.html
index 8822fd00..e15d043b 100644
--- a/wqflask/wqflask/templates/show_trait.html
+++ b/wqflask/wqflask/templates/show_trait.html
@@ -65,9 +65,7 @@
<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>
@@ -104,5 +102,5 @@
} );
console.timeEnd("Creating table");
});
- </script>-->
+ </script>
{% endblock %}
diff --git a/wqflask/wqflask/templates/show_trait_mapping_tools.html b/wqflask/wqflask/templates/show_trait_mapping_tools.html
index 58ee8982..cfa49456 100644
--- a/wqflask/wqflask/templates/show_trait_mapping_tools.html
+++ b/wqflask/wqflask/templates/show_trait_mapping_tools.html
@@ -133,7 +133,7 @@
<div class="controls">
<input name="num_perm" value="2000" type="text" />
</div>
- </div> -->
+ </div> -->
<div class="control-group">
<div class="controls">