Commit 164115ae authored by Marc Duez's avatar Marc Duez

browser : rework

clones become clusters ( now stored as array instead of object)
split move to clone.js
use reads object from data file
auto detect germline
and more ...
parent 37b0c46a
...@@ -139,8 +139,8 @@ Axis.prototype = { ...@@ -139,8 +139,8 @@ Axis.prototype = {
var n_min = 0; var n_min = 0;
var n_max = 1; var n_max = 1;
for (var i=0; i<this.m.windows.length; i++){ for (var i=0; i<this.m.n_windows; i++){
if (this.m.windows[i].Nlength > n_max) n_max = this.m.windows[i].Nlength; if (this.m.clone(i).Nlength > n_max) n_max = this.m.clone(i).Nlength;
} }
this.sizeScale = d3.scale.linear() this.sizeScale = d3.scale.linear()
...@@ -149,7 +149,7 @@ Axis.prototype = { ...@@ -149,7 +149,7 @@ Axis.prototype = {
//clone position //clone position
this.pos = function(cloneID) { this.pos = function(cloneID) {
return self.sizeScale(self.m.windows[cloneID].Nlength) return self.sizeScale(self.m.clone(cloneID).Nlength)
} }
//labels //labels
......
...@@ -375,7 +375,7 @@ Builder.prototype = { ...@@ -375,7 +375,7 @@ Builder.prototype = {
$("#system_menu").css("display", "") $("#system_menu").css("display", "")
$("#color_system_button").css("display", "") $("#color_system_button").css("display", "")
for (var key in this.m.system_segmented) { for (var key in this.m.reads.germline) {
var radio=document.createElement("input"); var radio=document.createElement("input");
radio.type="radio"; radio.type="radio";
...@@ -587,17 +587,17 @@ Builder.prototype = { ...@@ -587,17 +587,17 @@ Builder.prototype = {
span.appendChild(document.createTextNode("edit")); span.appendChild(document.createTextNode("edit"));
span.className = "button_right" span.className = "button_right"
span.onclick = function () { span.onclick = function () {
self.edit(this, "timestamp2"); self.edit(this, "timestamp");
} }
div_date.appendChild(span) div_date.appendChild(span)
parent.appendChild(div_date) parent.appendChild(div_date)
var percent = (this.m.reads_segmented[this.m.t] / this.m.reads_total[this.m.t]) * 100 var percent = (this.m.reads.segmented[this.m.t] / this.m.reads.total[this.m.t]) * 100
var val = "" + this.m.reads_segmented[this.m.t] + " reads" + " (" + percent.toFixed(2) + "%)" var val = "" + this.m.reads.segmented[this.m.t] + " reads" + " (" + percent.toFixed(2) + "%)"
var div_segmented = this.build_info_line("info_segmented", "segmented", val) var div_segmented = this.build_info_line("info_segmented", "segmented", val)
parent.appendChild(div_segmented) parent.appendChild(div_segmented)
var div_total = this.build_info_line("info_total", "total", this.m.reads_total[this.m.t] + " reads") var div_total = this.build_info_line("info_total", "total", this.m.reads.total[this.m.t] + " reads")
parent.appendChild(div_total) parent.appendChild(div_total)
/*TODO put this somewhere else /*TODO put this somewhere else
...@@ -622,7 +622,7 @@ Builder.prototype = { ...@@ -622,7 +622,7 @@ Builder.prototype = {
var keys = 0 ; var keys = 0 ;
for (var key in this.m.system_segmented) { for (var key in this.m.reads.germline) {
if (key == "IGH" && keys > 0) { if (key == "IGH" && keys > 0) {
span2.appendChild(document.createElement("br")); span2.appendChild(document.createElement("br"));
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
function Clone(data, model, hash) { function Clone(data, model, hash) {
this.m = model this.m = model
this.hash = hash this.hash = hash
this.split = false
var key = Object.keys(data) var key = Object.keys(data)
for (var i=0; i<key.length; i++ ){ for (var i=0; i<key.length; i++ ){
this[key[i]]=data[key[i]] this[key[i]]=data[key[i]]
...@@ -58,10 +59,8 @@ Clone.prototype = { ...@@ -58,10 +59,8 @@ Clone.prototype = {
}, //end getCode }, //end getCode
getSystem: function () { getSystem: function () {
if (typeof (this.system) != 'undefined') { if (typeof (this.germline) != 'undefined') {
return this.system; return this.germline;
} else {
if (this.m.system != 'multi' ) return this.m.system;
} }
}, },
...@@ -71,8 +70,8 @@ Clone.prototype = { ...@@ -71,8 +70,8 @@ Clone.prototype = {
getSize: function (time) { getSize: function (time) {
time = typeof time !== 'undefined' ? time : this.m.t; time = typeof time !== 'undefined' ? time : this.m.t;
if (this.m.reads_segmented[time] == 0 ) return 0 if (this.m.reads.segmented[time] == 0 ) return 0
var result = this.getReads(time) / this.m.reads_segmented[time] var result = this.getReads(time) / this.m.reads.segmented[time]
if (this.m.norm) { if (this.m.norm) {
result = this.m.normalize(result, time) result = this.m.normalize(result, time)
...@@ -96,8 +95,8 @@ Clone.prototype = { ...@@ -96,8 +95,8 @@ Clone.prototype = {
getSequenceSize: function (time) { getSequenceSize: function (time) {
time = typeof time !== 'undefined' ? time : this.m.t; time = typeof time !== 'undefined' ? time : this.m.t;
if (this.m.reads_segmented[time] == 0 ) return 0 if (this.m.reads.segmented[time] == 0 ) return 0
var result = this.getSequenceReads(time) / this.m.reads_segmented[time] var result = this.getSequenceReads(time) / this.m.reads.segmented[time]
if (this.norm) { if (this.norm) {
result = this.m.normalize(result, time) result = this.m.normalize(result, time)
...@@ -115,8 +114,8 @@ Clone.prototype = { ...@@ -115,8 +114,8 @@ Clone.prototype = {
time = typeof time !== 'undefined' ? time : this.m.t; time = typeof time !== 'undefined' ? time : this.m.t;
var result = 0; var result = 0;
for (var j = 0; j < this.m.clones[this.hash].cluster.length; j++) { for (var j = 0; j < this.m.clusters[this.hash].length; j++) {
result += this.m.clone(this.m.clones[this.hash].cluster[j]).size[time]; result += this.m.clone(this.m.clusters[this.hash][j]).size[time];
} }
return result return result
...@@ -241,7 +240,7 @@ Clone.prototype = { ...@@ -241,7 +240,7 @@ Clone.prototype = {
* *
* */ * */
getHtmlInfo: function () { getHtmlInfo: function () {
var isCluster = this.m.clones[this.hash].cluster.length var isCluster = this.m.clusters[this.hash].length
var time_length = this.m.samples.order.length var time_length = this.m.samples.order.length
var html = "" var html = ""
...@@ -265,7 +264,7 @@ Clone.prototype = { ...@@ -265,7 +264,7 @@ Clone.prototype = {
html += "<tr><td> clone name </td><td colspan='" + time_length + "'>" + this.getName() + "</td></tr>" html += "<tr><td> clone name </td><td colspan='" + time_length + "'>" + this.getName() + "</td></tr>"
html += "<tr><td> clone size (n-reads (total reads) )</td>" html += "<tr><td> clone size (n-reads (total reads) )</td>"
for (var i = 0; i < time_length; i++) { for (var i = 0; i < time_length; i++) {
html += "<td>" + this.getReads(this.m.samples.order[i]) + " (" + this.m.reads_segmented[this.m.samples.order[i]] + ")</td>" html += "<td>" + this.getReads(this.m.samples.order[i]) + " (" + this.m.reads.segmented[this.m.samples.order[i]] + ")</td>"
} }
html += "</tr><tr><td> clone size (%)</td>" html += "</tr><tr><td> clone size (%)</td>"
for (var i = 0; i < time_length; i++) { for (var i = 0; i < time_length; i++) {
...@@ -283,7 +282,7 @@ Clone.prototype = { ...@@ -283,7 +282,7 @@ Clone.prototype = {
html += "<tr><td> size (n-reads (total reads) )</td>" html += "<tr><td> size (n-reads (total reads) )</td>"
for (var i = 0; i < time_length; i++) { for (var i = 0; i < time_length; i++) {
html += "<td>" + this.getSequenceReads(this.m.samples.order[i]) + html += "<td>" + this.getSequenceReads(this.m.samples.order[i]) +
" (" + this.m.reads_segmented[this.m.samples.order[i]] + ")</td>" " (" + this.m.reads.segmented[this.m.samples.order[i]] + ")</td>"
} }
html += "</tr>" html += "</tr>"
html += "<tr><td> size (%)</td>" html += "<tr><td> size (%)</td>"
......
...@@ -148,8 +148,8 @@ Graph.prototype = { ...@@ -148,8 +148,8 @@ Graph.prototype = {
this.resolution5 = [] this.resolution5 = []
for (i = 0; i < this.m.samples.number; i++) { for (i = 0; i < this.m.samples.number; i++) {
this.resolution1[i] = (1 / this.m.reads_segmented[i]) this.resolution1[i] = (1 / this.m.reads.segmented[i])
this.resolution5[i] = (5 / this.m.reads_segmented[i]) this.resolution5[i] = (5 / this.m.reads.segmented[i])
} }
this.data_res.push({ this.data_res.push({
...@@ -388,8 +388,8 @@ Graph.prototype = { ...@@ -388,8 +388,8 @@ Graph.prototype = {
} }
for (i = 0; i < this.m.samples.number; i++) { for (i = 0; i < this.m.samples.number; i++) {
this.resolution1[i] = (1 / this.m.reads_segmented[i]) this.resolution1[i] = (1 / this.m.reads.segmented[i])
this.resolution5[i] = (5 / this.m.reads_segmented[i]) this.resolution5[i] = (5 / this.m.reads.segmented[i])
} }
if(this.mode=="stack"){ if(this.mode=="stack"){
...@@ -399,15 +399,15 @@ Graph.prototype = { ...@@ -399,15 +399,15 @@ Graph.prototype = {
this.data_res[1].path = this.constructPathR(this.resolution5); this.data_res[1].path = this.constructPathR(this.resolution5);
for (var i = 0; i < this.m.n_windows; i++) { for (var i = 0; i < this.m.n_windows; i++) {
for (var j = 0; j < this.m.clones[i].cluster.length; j++) { for (var j = 0; j < this.m.clusters[i].length; j++) {
this.data_graph[this.m.clones[i].cluster[j]].path = this.constructPath(i, false); this.data_graph[this.m.clusters[i][j]].path = this.constructPath(i, false);
} }
} }
for (var i = 0; i < this.m.n_windows; i++) { for (var i = 0; i < this.m.n_windows; i++) {
var cloneID = i var cloneID = i
for (var j = 0; j < this.m.clones[cloneID].cluster.length; j++) { for (var j = 0; j < this.m.clusters[cloneID].length; j++) {
var seqID = this.m.clones[cloneID].cluster[j] var seqID = this.m.clusters[cloneID][j]
if (this.m.clones[cloneID].split) { if (this.m.clone(cloneID).split) {
this.data_graph[seqID].path = this.constructPath(seqID, true); this.data_graph[seqID].path = this.constructPath(seqID, true);
} else { } else {
this.data_graph[seqID].path = this.constructPath(cloneID, false); this.data_graph[seqID].path = this.constructPath(cloneID, false);
...@@ -423,7 +423,6 @@ Graph.prototype = { ...@@ -423,7 +423,6 @@ Graph.prototype = {
}, },
updateStack: function () { updateStack: function () {
console.log("bam")
var stack = new Stack(this.m) var stack = new Stack(this.m)
stack.compute(); stack.compute();
for (var i = 0; i < this.m.n_length; i++) { for (var i = 0; i < this.m.n_length; i++) {
...@@ -440,9 +439,9 @@ Graph.prototype = { ...@@ -440,9 +439,9 @@ Graph.prototype = {
}else{ }else{
for (var i = 0; i < list.length; i++) { for (var i = 0; i < list.length; i++) {
var cloneID = list[i] var cloneID = list[i]
for (var j = 0; j < this.m.clones[cloneID].cluster.length; j++) { for (var j = 0; j < this.m.clusters[cloneID].length; j++) {
var seqID = this.m.clones[cloneID].cluster[j] var seqID = this.m.clusters[cloneID][j]
if (this.m.clones[cloneID].split) { if (this.m.clone(cloneID).split) {
this.data_graph[seqID].path = this.constructPath(seqID, true); this.data_graph[seqID].path = this.constructPath(seqID, true);
} else { } else {
this.data_graph[seqID].path = this.constructPath(cloneID, false); this.data_graph[seqID].path = this.constructPath(cloneID, false);
......
...@@ -232,8 +232,8 @@ List.prototype = { ...@@ -232,8 +232,8 @@ List.prototype = {
var span_cluster = document.createElement('span') var span_cluster = document.createElement('span')
span_cluster.className = "clusterBox"; span_cluster.className = "clusterBox";
if (this.m.clones[cloneID].cluster.length > 1) { if (this.m.clusters[cloneID].length > 1) {
if (this.m.clones[cloneID].split) { if (this.m.clone(cloneID).split) {
span_cluster.onclick = function () { span_cluster.onclick = function () {
self.hideCluster(cloneID) self.hideCluster(cloneID)
} }
...@@ -286,17 +286,17 @@ List.prototype = { ...@@ -286,17 +286,17 @@ List.prototype = {
div_cluster.id = "cluster" + cloneID; div_cluster.id = "cluster" + cloneID;
div_cluster.id2 = cloneID; div_cluster.id2 = cloneID;
var display = this.m.clones[cloneID].split var display = this.m.clone(cloneID).split
if (this.m.clones[cloneID].cluster.length < 2) display = false if (this.m.clusters[cloneID].length < 2) display = false
if (!display) div_cluster.style.display = "none"; if (!display) div_cluster.style.display = "none";
var clusterSize = this.m.clone(cloneID).getSize() var clusterSize = this.m.clone(cloneID).getSize()
var clusterReads = this.m.clone(cloneID).getReads() var clusterReads = this.m.clone(cloneID).getReads()
for (var i = 0; i < this.m.clones[cloneID].cluster.length; i++) { for (var i = 0; i < this.m.clusters[cloneID].length; i++) {
(function (i) { (function (i) {
var id = this.m.clones[cloneID].cluster[i] var id = this.m.clusters[cloneID][i]
var div_clone = document.createElement('div'); var div_clone = document.createElement('div');
div_clone.id = "_" + id; div_clone.id = "_" + id;
div_clone.id2 = id; div_clone.id2 = id;
...@@ -403,7 +403,7 @@ List.prototype = { ...@@ -403,7 +403,7 @@ List.prototype = {
var div = this.index[list[i]]; var div = this.index[list[i]];
if ((this.m.clone(list[i]).isActive() && this.m.clones[list[i]].cluster.length != 0) || this.m.clone(list[i]).window == "other") { if ((this.m.clone(list[i]).isActive() && this.m.clusters[list[i]].length != 0) || this.m.clone(list[i]).window == "other") {
div.innerHTML = ''; div.innerHTML = '';
...@@ -589,7 +589,7 @@ List.prototype = { ...@@ -589,7 +589,7 @@ List.prototype = {
showCluster: function (cloneID) { showCluster: function (cloneID) {
var self = this var self = this
this.m.clones[cloneID].split = true this.m.clone(cloneID).split = true
$("#cluster" + cloneID) $("#cluster" + cloneID)
.show(50, function () { .show(50, function () {
self.m.updateElem([cloneID]) self.m.updateElem([cloneID])
...@@ -598,7 +598,7 @@ List.prototype = { ...@@ -598,7 +598,7 @@ List.prototype = {
hideCluster: function (cloneID) { hideCluster: function (cloneID) {
var self = this var self = this
this.m.clones[cloneID].split = false this.m.clone(cloneID).split = false
$("#cluster" + cloneID) $("#cluster" + cloneID)
.hide(50, function () { .hide(50, function () {
self.m.updateElem([cloneID]) self.m.updateElem([cloneID])
......
This diff is collapsed.
...@@ -42,7 +42,7 @@ PDF.prototype = { ...@@ -42,7 +42,7 @@ PDF.prototype = {
if (this.list.length == 0) { if (this.list.length == 0) {
var flag = 5; var flag = 5;
for (var i = 0; i < this.m.n_windows; i++) { for (var i = 0; i < this.m.n_windows; i++) {
if (this.m.clones[i].cluster.length != 0 && flag != 0) { if (this.m.clusters[i].length != 0 && flag != 0) {
this.list.push(i); this.list.push(i);
flag--; flag--;
} }
...@@ -127,7 +127,7 @@ PDF.prototype = { ...@@ -127,7 +127,7 @@ PDF.prototype = {
this.doc.text(this.marge + 5, this.y + 5, this.m.dataFileName); this.doc.text(this.marge + 5, this.y + 5, this.m.dataFileName);
// todo: fill again with reliable data :) // todo: fill again with reliable data :)
// this.doc.text(this.marge + 5, this.y + 10, 'run: 2013-10-03'); // this.doc.text(this.marge + 5, this.y + 10, 'run: 2013-10-03');
this.doc.text(this.marge + 5, this.y + 15, 'analysis: ' + m.timestamp[0].split(' ')[0]); this.doc.text(this.marge + 5, this.y + 15, 'analysis: ' + m.timestamp.split(' ')[0]);
this.doc.text(this.marge + 5, this.y + 20, 'germline: ' + m.system); this.doc.text(this.marge + 5, this.y + 20, 'germline: ' + m.system);
this.doc.rect(this.marge, this.y, 60, 23); this.doc.rect(this.marge, this.y, 60, 23);
...@@ -275,14 +275,14 @@ PDF.prototype = { ...@@ -275,14 +275,14 @@ PDF.prototype = {
this.next_row() this.next_row()
} }
this.row('total segmented', this.m.reads_segmented, 'raw'); this.row('total segmented', this.m.reads.segmented, 'raw');
if (this.m.reads_total) { if (this.m.reads_total) {
this.next_sub_row() this.next_sub_row()
var data = [] var data = []
for (var i = 0; i < this.m.samples.number; i++) { for (var i = 0; i < this.m.samples.number; i++) {
data[i] = this.m.reads_segmented[i] / this.m.reads_total[i] data[i] = this.m.reads.segmented[i] / this.m.reads_total[i]
} }
this.row('', data, '%') this.row('', data, '%')
} }
......
...@@ -819,9 +819,9 @@ ScatterPlot.prototype = { ...@@ -819,9 +819,9 @@ ScatterPlot.prototype = {
var w = this.resizeW*0.2 var w = this.resizeW*0.2
//compute hidden position for unactivated germline (to avoid firework effect) //compute hidden position for unactivated germline (to avoid firework effect)
for (var key in germline.icon){ for (var key in this.m.reads.germline){
if (key != this.m.germlineV.system){ if (key != this.m.germlineV.system){
this.systemGrid[key] = { 'x' : 1 , 'y' : 1} this.systemGrid[key] = { 'x' : 0.99 , 'y' : 0.99}
} }
} }
...@@ -1086,9 +1086,9 @@ ScatterPlot.prototype = { ...@@ -1086,9 +1086,9 @@ ScatterPlot.prototype = {
updateClone: function (cloneID) { updateClone: function (cloneID) {
if (this.m.clone(cloneID).isActive()) { if (this.m.clone(cloneID).isActive()) {
if (this.m.clones[cloneID].split) { if (this.m.clone(cloneID).split) {
for (var i = 0; i < this.m.clones[cloneID].cluster.length; i++) { for (var i = 0; i < this.m.clusters[cloneID].length; i++) {
var seqID = this.m.clones[cloneID].cluster[i] var seqID = this.m.clusters[cloneID][i]
var size = this.m.clone(seqID).getSequenceSize(); var size = this.m.clone(seqID).getSequenceSize();
//Math.pow(x,y) -> x**y //Math.pow(x,y) -> x**y
if (size != 0) size = this.resizeCoef * Math.pow((size + 0.001), (1 / 3)) / 25 if (size != 0) size = this.resizeCoef * Math.pow((size + 0.001), (1 / 3)) / 25
...@@ -1096,12 +1096,12 @@ ScatterPlot.prototype = { ...@@ -1096,12 +1096,12 @@ ScatterPlot.prototype = {
} }
} }
else { else {
for (var i = 0; i < this.m.clones[cloneID].cluster.length; i++) { for (var i = 0; i < this.m.clusters[cloneID].length; i++) {
var seqID = this.m.clones[cloneID].cluster[i] var seqID = this.m.clusters[cloneID][i]
this.nodes[seqID].r1 = 0 this.nodes[seqID].r1 = 0
} }
var size = this.m.clone(cloneID).getSize(); var size = this.m.clone(cloneID).getSize();
if (this.m.clones[cloneID].cluster.length == 0) size = this.m.clone(cloneID).getSequenceSize(); if (this.m.clusters[cloneID].length == 0) size = this.m.clone(cloneID).getSequenceSize();
if (size != 0) size = this.resizeCoef * Math.pow((size + 0.001), (1 / 3)) / 25 if (size != 0) size = this.resizeCoef * Math.pow((size + 0.001), (1 / 3)) / 25
this.nodes[cloneID].r1 = size this.nodes[cloneID].r1 = size
} }
...@@ -1110,7 +1110,6 @@ ScatterPlot.prototype = { ...@@ -1110,7 +1110,6 @@ ScatterPlot.prototype = {
else { else {
this.nodes[cloneID].r1 = 0 this.nodes[cloneID].r1 = 0
} }
var sys = this.m.clone(cloneID).getSystem() var sys = this.m.clone(cloneID).getSystem()
if (this.use_system_grid && this.m.system == "multi" if (this.use_system_grid && this.m.system == "multi"
&& typeof sys != 'undefined' && typeof sys != 'undefined'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment