Commit 7645d370 authored by Marc Duez's avatar Marc Duez
Browse files

scatterplot.js : use custom generic function instead of specific

parent 6f2e7466
......@@ -140,70 +140,7 @@ Axis.prototype = {
},
/*
*
* */
useSequenceLength: function () {
this.init()
var self = this;
var n_min = 9999;
var n_max = 1;
for (var i=0; i<this.m.clones.length; i++){
var n = this.m.clone(i).getSequenceLength();
if (n && n < n_min) n_min = n;
if (n > n_max) n_max = n;
}
this.sizeScale = d3.scale.linear()
.domain([n_min-1, n_max+1])
.range([0, 1]);
//clone position
this.pos = function(cloneID) {
return self.sizeScale(self.m.clone(cloneID).getSequenceLength())
}
//labels
var h = Math.ceil(n_max/5)
for (var i = 0; i < 5; i++) {
var pos = this.sizeScale(h*i);
var text = h*i
this.labels.push(this.label("line", pos, text));
}
},
/*
*
* */
useNlength: function () {
this.init()
var self = this;
var n_min = 0;
var n_max = 1;
for (var i=0; i<this.m.clones.length; i++){
var n = this.m.clone(i).getNlength();
if (n > n_max) n_max = n;
}
this.sizeScale = d3.scale.linear()
.domain([0, n_max+1])
.range([0, 1]);
//clone position
this.pos = function(cloneID) {
return self.sizeScale(self.m.clone(cloneID).getNlength())
}
//labels
var h = Math.ceil(n_max/5)
for (var i = 0; i < 5; i++) {
var pos = this.sizeScale(h*i);
var text = h*i
this.labels.push(this.label("line", pos, text));
}
},
custom: function(fct){
var self = this;
......
......@@ -1623,10 +1623,19 @@ ScatterPlot.prototype = {
axis.useSize()
}
if (splitMethod == "sequenceLength") {
axis.useSequenceLength()
axis.custom(function(cloneID){
var value = m.clone(cloneID).getSequenceLength()
if (typeof value != "undefined" && value != 0) return value;
return undefined;
})
}
if (splitMethod == "n") {
axis.useNlength()
axis.custom(function(cloneID){
var value = m.clone(cloneID).getNlength()
if (typeof value != "undefined" && value != 0) return value;
return undefined;
})
}
if (splitMethod == "lengthCDR3") {
axis.custom(function(cloneID){ return m.clone(cloneID).seg["cdr3"].length})
......
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