Commit 8183098a authored by Mathieu Giraud's avatar Mathieu Giraud Committed by Mikaël Salson

js/tools.js, js/model.js: m.selectCorrelated()

See #1943.
parent ce0e9752
......@@ -870,6 +870,30 @@ changeAlleleNotation: function(alleleNotation) {
}
this.updateStyle();
},
/**
* select clones correlated to a given clone
* @param {integer} - cloneID - index of the reference clone
*/
selectCorrelated: function(ref, threshold) {
if (typeof threshold === "undefined") {
threshold = 0.95
}
r = []
refReads = this.clone(ref).getReadsAllSamples(logadd1)
r.push(refReads)
for (var i=0; i<this.clones.length; i++){
var clone = this.clone(i);
var coeff = pearsonCoeff(refReads, clone.getReadsAllSamples(logadd1))
clone.select = (Math.abs(coeff) > threshold)
r.push([i, coeff, threshold, clone.select])
}
this.updateStyle(); return r;
},
/**
* put a list of clones in the selection
......
......@@ -426,3 +426,5 @@ function pearsonCoeff(l1, l2) {
return (n*sum12 - sum1*sum2) / Math.sqrt(d)
}
function logadd1(x) { return Math.log(x + 1) ; }
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