From a23e8791f3a3d5c1d96b6dedbe72d2748b190252 Mon Sep 17 00:00:00 2001 From: Angelos Chatzimparmpas Date: Fri, 8 Mar 2019 16:13:17 +0100 Subject: [PATCH] Fixed pcp order Former-commit-id: a5c4c12a965ed9903e13979a4fe9830bce595186 --- index.html | 2 +- js/tsne_vis.js | 114 +++++++++++++++++++++++++++++++++++-------------- 2 files changed, 82 insertions(+), 34 deletions(-) diff --git a/index.html b/index.html index 13981d7..bb5c4cb 100755 --- a/index.html +++ b/index.html @@ -126,7 +126,7 @@
-

Schema Investigation (Coefficient of Determination)

+

Correl. Schema Investigation

diff --git a/js/tsne_vis.js b/js/tsne_vis.js index 4d1ae0b..b7f7003 100755 --- a/js/tsne_vis.js +++ b/js/tsne_vis.js @@ -1699,7 +1699,8 @@ function CalculateCorrel(flagForSchema){ // Calculate the correlation is a funct if (isNaN(pearsonCorrelation(tempData, 0, 1))) { } else{ SignStore.push([temp, pearsonCorrelation(tempData, 0, 1)]); // Keep the sign - correlationResults.push([Object.keys(dataFeatures[0])[temp] + " (" + temp + ")", Math.abs(pearsonCorrelation(tempData, 0, 1))*Math.abs(pearsonCorrelation(tempData, 0, 1)),temp]); // Find the pearson correlations + correlationResults.push([Object.keys(dataFeatures[0])[temp] + " (" + temp + ")", Math.abs(pearsonCorrelation(tempData, 0, 1)),temp]); // Find the pearson correlations + //correlationResults.push([Object.keys(dataFeatures[0])[temp] + " (" + temp + ")", Math.pow(pearsonCorrelation(tempData, 0, 1),2),temp]); // Find the pearson correlations (MAYBE!) } } } @@ -1725,7 +1726,7 @@ function CalculateCorrel(flagForSchema){ // Calculate the correlation is a funct correlationResultsFinal = []; for (var i=0; i 0){ // If points > 10 then do not draw! If points = 0 then do not draw! var wrapData = []; @@ -2561,7 +2564,7 @@ if (points.length) { // If points exist (at least 1 point) .style("font", "14px"); } else { - +*/ var wrapData2 = []; for (var i=0; i b[CategoryReplaced]) { return 1; } + return 0; + }) + + function sortByFrequency(array) { + var frequency = {}; + var CategoryReplaced = Category.replace("*",""); + array.forEach(function(value) { frequency[value[CategoryReplaced]] = 0; }); + + var uniques = array.filter(function(value) { + return ++frequency[value[CategoryReplaced]] == 1; + }); + var result = uniques.map(function(value) { + return frequency[value[CategoryReplaced]]; + }); + return result; + } + + var lessmore = sortByFrequency(wrapData2); + if (lessmore[0] < lessmore[1]){ + wrapData2.reverse(); + } var AllPointsWrapData2 = []; for (var i=0; i b[CategoryReplaced]) { return 1; } + return 0; + }) + + if (all_labels[0] == undefined){ var colorScaleCat = d3.scaleOrdinal().domain(["No Category"]).range(["#C0C0C0"]); } @@ -2627,21 +2663,32 @@ if (points.length) { // If points exist (at least 1 point) } var colorScaleCat = d3.scaleOrdinal().domain(all_labels).range(ColorsCategorical); } - - parcoords - .data(AllPointsWrapData2) - .alpha(0.95) - .composite("darken") - .margin({ top: 20, left: 0, bottom: 10, right: -5 }) - .mode("default") - .color(function(d){if(format[0] == "diabetes"){if(d[Category] == "Negative"){return colorScaleCat("Positive");}else{return colorScaleCat("Negative");}} else{return colorScaleCat(d[Category]);}}) - .render() - .highlight(wrapData2) - .createAxes(); - - parcoords.svg.selectAll("text") - .style("font", "14px"); - } + if (AllPointsWrapData2.length == wrapData2.length){ + parcoords + .data(AllPointsWrapData2) + .alpha(0.35) + .composite("darken") + .margin({ top: 20, left: 0, bottom: 10, right: -5 }) + .mode("default") + .color(function(d){if(format[0] == "diabetes"){if(d[Category.replace("*","")] == "Negative"){return colorScaleCat("Positive");}else{return colorScaleCat("Negative");}} else{return colorScaleCat(d[Category.replace("*","")]);}}) + .render() + .createAxes(); + + parcoords.svg.selectAll("text") + .style("font", "14px"); + } else{ + parcoords + .data(AllPointsWrapData2) + .composite("darken") + .margin({ top: 20, left: 0, bottom: 10, right: -5 }) + .mode("default") + .color(function(d){if(format[0] == "diabetes"){if(d[Category.replace("*","")] == "Negative"){return colorScaleCat("Positive");}else{return colorScaleCat("Negative");}} else{return colorScaleCat(d[Category.replace("*","")]);}}) + .render() + .highlight(wrapData2) + .createAxes(); + } + + //} var ColSizeSelector = document.getElementById("param-neighborHood").value; // This is the mapping of the color/size in beta/KLD @@ -2812,7 +2859,7 @@ if (points.length) { // If points exist (at least 1 point) limitdist = parseFloat(limitdist).toFixed(1); var legendScale2 = d3.scaleLinear() - .domain(d3.range(0, abbreviateNumber(parseInt(maxSize2)), calcStepSize2)) + .domain(d3.range(0, parseInt(maxSize2), calcStepSize2)) .range([5*limitdist/2,12*limitdist/2]); @@ -2820,7 +2867,7 @@ if (points.length) { // If points exist (at least 1 point) svg.append("g") .attr("class", "legendSize") - .attr("transform", "translate(10,20)"); + .attr("transform", "translate(10,10)"); var SizeRange2 = []; SizeRange2.push(0); @@ -2926,9 +2973,10 @@ if (points.length) { // If points exist (at least 1 point) pointsGeometry.vertices.push(vertex); pointsGeometry.name = points[i].id; geometry.vertices.push(vertex); - if(points[i].pcp == true){ + /*if(points[i].pcp == true){ var color = new THREE.Color(colorScl(points[i].id)); - } else if (points[i].DimON != null) { + }*/ + if (points[i].DimON != null) { let temp = points[i].DimON.match(/\d+/)[0]; var maxDim = (d3.max(points,function(d){ if(d.schemaInv == true){return d[temp]}; })); var minDim = (d3.min(points,function(d){ if(d.schemaInv == true){return d[temp]}; }));