Commit 91dfdabe authored by Andrew Cohen's avatar Andrew Cohen

lineage features -- use global normalization over all rendered features

parent 99ecf219
......@@ -173,28 +173,29 @@ function drawNodeFeatures(node,t0,t1,context,height,nFrames,miniLineageCanvas,li
var featureDiv=document.getElementById('divFeatures');
// each feature will be normalized to min/max across all visible features
var fmax,fmin;
fmax=node.features[0][2];
fmin=node.features[0][2];
var bAllHidden=true;
for (var t=1;t<node.features.length;t++) {
for (var fn=0;fn<featureDiv.children.length;fn++) {
var bChecked=document.getElementById('featureShow_'+fn).checked;
if (!bChecked)
continue;
bAllHidden=false;
if (null==node.features[t][2+fn])
continue;
if (node.features[t][2+fn]>fmax)
fmax=node.features[t][2+fn];
if (node.features[t][2+fn]<fmin)
fmin=node.features[t][2+fn];
}
}
if (null===fmax || null===fmin || undefined===fmax || undefined===fmin || bAllHidden) {
return;
}
var fmax = gLineageFeatureExtrema[1];
var fmin = gLineageFeatureExtrema[0];
// fmax=node.features[0][2];
// fmin=node.features[0][2];
// var bAllHidden=true;
// for (var t=1;t<node.features.length;t++) {
// for (var fn=0;fn<featureDiv.children.length;fn++) {
// var bChecked=document.getElementById('featureShow_'+fn).checked;
// if (!bChecked)
// continue;
// bAllHidden=false;
// if (null==node.features[t][2+fn])
// continue;
// if (node.features[t][2+fn]>fmax)
// fmax=node.features[t][2+fn];
// if (node.features[t][2+fn]<fmin)
// fmin=node.features[t][2+fn];
// }
// }
// if (null===fmax || null===fmin || undefined===fmax || undefined===fmin || bAllHidden) {
// return;
// }
for (var n=0;n<featureDiv.children.length;n++) {
var bShow=document.getElementById('featureShow_'+n).checked;
......@@ -357,6 +358,21 @@ function labelTree(node,gLineageMap,miniLineageCanvas,context,nFrames)
} // labelTree
function setFeatureExtrema(node)
{
if (undefined==node.features || 0==node.features.length || undefined==CONSTANTS.cellFeatures ) {
return;
}
for (var nFeature=0;nFeature<CONSTANTS.cellFeatures.length;nFeature++) {
if (false===CONSTANTS.cellFeatures[nFeature].bShow)
continue;
for (var i=0;i<node.features.length;i++) {
gLineageFeatureExtrema[0]=Math.min(gLineageFeatureExtrema[0],node.features[i][2+nFeature]);
gLineageFeatureExtrema[1]=Math.max(gLineageFeatureExtrema[1],node.features[i][2+nFeature]);
}
}
} // setFeatureExtrema
// traverse dfs
// -- place larger subtree on left
function initTree(node,gLineageMap,root=null)
......@@ -364,6 +380,7 @@ function initTree(node,gLineageMap,root=null)
var c1depth,c2depth;
var c1,c2;
setFeatureExtrema(node);
// set root node
if (null!==root) {
gRootTrackIDs[node.trackID]=root.trackID;
......@@ -540,6 +557,7 @@ function positionLineageSidebar(canvas)
lineagePositionDiv.style.top=lineageDiv.offsetTop+lineageDiv.offsetHeight+'px';
}
var gLineageFeatureExtrema;
function buildAndDrawTrees(canvas)
{
var i;
......@@ -550,6 +568,7 @@ function buildAndDrawTrees(canvas)
// all the root nodes
var rgRoots = [];
gLineageFeatureExtrema=[Infinity,-Infinity];
// traverse each tree to find depths
gLineageMap.forEach(function(node,trackID,map) {
if (-1==node.parent) {
......
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