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 = {
var n_min = 0;
var n_max = 1;
for (var i=0; i<this.m.windows.length; i++){
if (this.m.windows[i].Nlength > n_max) n_max = this.m.windows[i].Nlength;
for (var i=0; i<this.m.n_windows; i++){
if (this.m.clone(i).Nlength > n_max) n_max = this.m.clone(i).Nlength;
}
this.sizeScale = d3.scale.linear()
......@@ -149,7 +149,7 @@ Axis.prototype = {
//clone position
this.pos = function(cloneID) {
return self.sizeScale(self.m.windows[cloneID].Nlength)
return self.sizeScale(self.m.clone(cloneID).Nlength)
}
//labels
......
......@@ -375,7 +375,7 @@ Builder.prototype = {
$("#system_menu").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");
radio.type="radio";
......@@ -587,17 +587,17 @@ Builder.prototype = {
span.appendChild(document.createTextNode("edit"));
span.className = "button_right"
span.onclick = function () {
self.edit(this, "timestamp2");
self.edit(this, "timestamp");
}
div_date.appendChild(span)
parent.appendChild(div_date)
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 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 div_segmented = this.build_info_line("info_segmented", "segmented", val)
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)
/*TODO put this somewhere else
......@@ -622,7 +622,7 @@ Builder.prototype = {
var keys = 0 ;
for (var key in this.m.system_segmented) {
for (var key in this.m.reads.germline) {
if (key == "IGH" && keys > 0) {
span2.appendChild(document.createElement("br"));
......
......@@ -20,6 +20,7 @@
function Clone(data, model, hash) {
this.m = model
this.hash = hash
this.split = false
var key = Object.keys(data)
for (var i=0; i<key.length; i++ ){
this[key[i]]=data[key[i]]
......@@ -58,10 +59,8 @@ Clone.prototype = {
}, //end getCode
getSystem: function () {
if (typeof (this.system) != 'undefined') {
return this.system;
} else {
if (this.m.system != 'multi' ) return this.m.system;
if (typeof (this.germline) != 'undefined') {
return this.germline;
}
},
......@@ -71,8 +70,8 @@ Clone.prototype = {
getSize: function (time) {
time = typeof time !== 'undefined' ? time : this.m.t;
if (this.m.reads_segmented[time] == 0 ) return 0
var result = this.getReads(time) / this.m.reads_segmented[time]
if (this.m.reads.segmented[time] == 0 ) return 0
var result = this.getReads(time) / this.m.reads.segmented[time]
if (this.m.norm) {
result = this.m.normalize(result, time)
......@@ -96,8 +95,8 @@ Clone.prototype = {
getSequenceSize: function (time) {
time = typeof time !== 'undefined' ? time : this.m.t;
if (this.m.reads_segmented[time] == 0 ) return 0
var result = this.getSequenceReads(time) / this.m.reads_segmented[time]
if (this.m.reads.segmented[time] == 0 ) return 0
var result = this.getSequenceReads(time) / this.m.reads.segmented[time]
if (this.norm) {
result = this.m.normalize(result, time)
......@@ -115,8 +114,8 @@ Clone.prototype = {
time = typeof time !== 'undefined' ? time : this.m.t;
var result = 0;
for (var j = 0; j < this.m.clones[this.hash].cluster.length; j++) {
result += this.m.clone(this.m.clones[this.hash].cluster[j]).size[time];
for (var j = 0; j < this.m.clusters[this.hash].length; j++) {
result += this.m.clone(this.m.clusters[this.hash][j]).size[time];
}
return result
......@@ -241,7 +240,7 @@ Clone.prototype = {
*
* */
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 html = ""
......@@ -265,7 +264,7 @@ Clone.prototype = {
html += "<tr><td> clone name </td><td colspan='" + time_length + "'>" + this.getName() + "</td></tr>"
html += "<tr><td> clone size (n-reads (total reads) )</td>"
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>"
for (var i = 0; i < time_length; i++) {
......@@ -283,7 +282,7 @@ Clone.prototype = {
html += "<tr><td> size (n-reads (total reads) )</td>"
for (var i = 0; i < time_length; 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><td> size (%)</td>"
......
......@@ -148,8 +148,8 @@ Graph.prototype = {
this.resolution5 = []
for (i = 0; i < this.m.samples.number; i++) {
this.resolution1[i] = (1 / this.m.reads_segmented[i])
this.resolution5[i] = (5 / this.m.reads_segmented[i])
this.resolution1[i] = (1 / this.m.reads.segmented[i])
this.resolution5[i] = (5 / this.m.reads.segmented[i])
}
this.data_res.push({
......@@ -388,8 +388,8 @@ Graph.prototype = {
}
for (i = 0; i < this.m.samples.number; i++) {
this.resolution1[i] = (1 / this.m.reads_segmented[i])
this.resolution5[i] = (5 / this.m.reads_segmented[i])
this.resolution1[i] = (1 / this.m.reads.segmented[i])
this.resolution5[i] = (5 / this.m.reads.segmented[i])
}
if(this.mode=="stack"){
......@@ -399,15 +399,15 @@ Graph.prototype = {
this.data_res[1].path = this.constructPathR(this.resolution5);
for (var i = 0; i < this.m.n_windows; i++) {
for (var j = 0; j < this.m.clones[i].cluster.length; j++) {
this.data_graph[this.m.clones[i].cluster[j]].path = this.constructPath(i, false);
for (var j = 0; j < this.m.clusters[i].length; j++) {
this.data_graph[this.m.clusters[i][j]].path = this.constructPath(i, false);
}
}
for (var i = 0; i < this.m.n_windows; i++) {
var cloneID = i
for (var j = 0; j < this.m.clones[cloneID].cluster.length; j++) {
var seqID = this.m.clones[cloneID].cluster[j]
if (this.m.clones[cloneID].split) {
for (var j = 0; j < this.m.clusters[cloneID].length; j++) {
var seqID = this.m.clusters[cloneID][j]
if (this.m.clone(cloneID).split) {
this.data_graph[seqID].path = this.constructPath(seqID, true);
} else {
this.data_graph[seqID].path = this.constructPath(cloneID, false);
......@@ -423,7 +423,6 @@ Graph.prototype = {
},
updateStack: function () {
console.log("bam")
var stack = new Stack(this.m)
stack.compute();
for (var i = 0; i < this.m.n_length; i++) {
......@@ -440,9 +439,9 @@ Graph.prototype = {
}else{
for (var i = 0; i < list.length; i++) {
var cloneID = list[i]
for (var j = 0; j < this.m.clones[cloneID].cluster.length; j++) {
var seqID = this.m.clones[cloneID].cluster[j]
if (this.m.clones[cloneID].split) {
for (var j = 0; j < this.m.clusters[cloneID].length; j++) {
var seqID = this.m.clusters[cloneID][j]
if (this.m.clone(cloneID).split) {
this.data_graph[seqID].path = this.constructPath(seqID, true);
} else {
this.data_graph[seqID].path = this.constructPath(cloneID, false);
......
......@@ -232,8 +232,8 @@ List.prototype = {
var span_cluster = document.createElement('span')
span_cluster.className = "clusterBox";
if (this.m.clones[cloneID].cluster.length > 1) {
if (this.m.clones[cloneID].split) {
if (this.m.clusters[cloneID].length > 1) {
if (this.m.clone(cloneID).split) {
span_cluster.onclick = function () {
self.hideCluster(cloneID)
}
......@@ -286,17 +286,17 @@ List.prototype = {
div_cluster.id = "cluster" + cloneID;
div_cluster.id2 = cloneID;
var display = this.m.clones[cloneID].split
if (this.m.clones[cloneID].cluster.length < 2) display = false
var display = this.m.clone(cloneID).split
if (this.m.clusters[cloneID].length < 2) display = false
if (!display) div_cluster.style.display = "none";
var clusterSize = this.m.clone(cloneID).getSize()
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) {
var id = this.m.clones[cloneID].cluster[i]
var id = this.m.clusters[cloneID][i]
var div_clone = document.createElement('div');
div_clone.id = "_" + id;
div_clone.id2 = id;
......@@ -403,7 +403,7 @@ List.prototype = {
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 = '';
......@@ -589,7 +589,7 @@ List.prototype = {
showCluster: function (cloneID) {
var self = this
this.m.clones[cloneID].split = true
this.m.clone(cloneID).split = true
$("#cluster" + cloneID)
.show(50, function () {
self.m.updateElem([cloneID])
......@@ -598,7 +598,7 @@ List.prototype = {
hideCluster: function (cloneID) {
var self = this
this.m.clones[cloneID].split = false
this.m.clone(cloneID).split = false
$("#cluster" + cloneID)
.hide(50, function () {
self.m.updateElem([cloneID])
......
This diff is collapsed.
......@@ -42,7 +42,7 @@ PDF.prototype = {
if (this.list.length == 0) {
var flag = 5;
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);
flag--;
}
......@@ -127,7 +127,7 @@ PDF.prototype = {
this.doc.text(this.marge + 5, this.y + 5, this.m.dataFileName);
// 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 + 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.rect(this.marge, this.y, 60, 23);
......@@ -275,14 +275,14 @@ PDF.prototype = {
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) {
this.next_sub_row()
var data = []
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, '%')
}
......
......@@ -819,9 +819,9 @@ ScatterPlot.prototype = {
var w = this.resizeW*0.2
//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){
this.systemGrid[key] = { 'x' : 1 , 'y' : 1}
this.systemGrid[key] = { 'x' : 0.99 , 'y' : 0.99}
}
}
......@@ -1086,9 +1086,9 @@ ScatterPlot.prototype = {
updateClone: function (cloneID) {
if (this.m.clone(cloneID).isActive()) {
if (this.m.clones[cloneID].split) {
for (var i = 0; i < this.m.clones[cloneID].cluster.length; i++) {
var seqID = this.m.clones[cloneID].cluster[i]
if (this.m.clone(cloneID).split) {
for (var i = 0; i < this.m.clusters[cloneID].length; i++) {
var seqID = this.m.clusters[cloneID][i]
var size = this.m.clone(seqID).getSequenceSize();
//Math.pow(x,y) -> x**y
if (size != 0) size = this.resizeCoef * Math.pow((size + 0.001), (1 / 3)) / 25
......@@ -1096,12 +1096,12 @@ ScatterPlot.prototype = {
}
}
else {
for (var i = 0; i < this.m.clones[cloneID].cluster.length; i++) {
var seqID = this.m.clones[cloneID].cluster[i]
for (var i = 0; i < this.m.clusters[cloneID].length; i++) {
var seqID = this.m.clusters[cloneID][i]
this.nodes[seqID].r1 = 0
}
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
this.nodes[cloneID].r1 = size
}
......@@ -1110,7 +1110,6 @@ ScatterPlot.prototype = {
else {
this.nodes[cloneID].r1 = 0
}
var sys = this.m.clone(cloneID).getSystem()
if (this.use_system_grid && this.m.system == "multi"
&& 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