Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
6242 lines (4951 sloc) 231 KB
<html>
</head>
<script type='text/javascript' src='https://www.google.com/jsapi'></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.10/jquery-ui.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="https://cdn.rawgit.com/evanplaice/jquery-csv/master/src/jquery.csv.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjs/2.4.2/math.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjs/2.3.0/math.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/jstat/1.4.3/jstat.min.js"></script>
<script type="text/javascript" src="https://www.google.com/jsapi?autoload={'modules':[{'name':'visualization', 'version':'1', 'packages':['corechart']}]}"></script>
<script type='text/javascript'>
///////////Notes and Acknowledgements and License and Disclaimer/////////////
// Experiments conducted by Michael McNamara, Ian Hilgart, Diego Barragan
// Study Design by Michael McNamara, Ian Hilgart, William Redmond, Stefanie Linch
// Data Visualization by Michael McNamara, Ian Hilgart
// Study conducted at EACRI, RWF Cancer Center, Providence Portland Medical Center. March 2015.
// Code by Michael McNamara, Google, HighCharts, Trent Richardson, and many other places on the web.
////Compatible Browsers: Google Chrome.
//License Disclaimer (modified MIT):
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//THE SOFTWARE.
//The license may not give you all of the permissions necessary for your intended use.
//This software uses code developed by Google, HighCharts and others that is subject to
//additional conditions.For example, some of the components used in this software include licenses that may
//limit how you use this software. Users may copy, display, make derivatives of, and
//distribute this software to others for non-commercial purposes, but must maintain the
//copyright notice above and this permission notice in all copies.
////////////////GLOBAL STUFF////////////
var statusobject = {};
statusobject.status = "Status Info";
///Create Asynch Status Udpate////
function statusupdate() {
var currentstatus = statusobject.status;
document.getElementById("selectedpatientinfo").innerHTML = currentstatus;
};
/////STATS PLACEHOLDERS/////////////
/////STATS PLACEHOLDERS/////////////
/////STATS PLACEHOLDERS/////////////
MergedGroupsBOTHARRAYS = [];
MergedGroupsANOVA = [];
MergedGroupsTTest = [];
MergedCohortsBOTHARRAYS = [];
MergedCohortsANOVA = [];
MergedCohortsTTest = [];
MergedTreatmentsANOVA = [];
MergedTreatmentsTTest = [];
MergedTreatmentsBOTHARRAYS = [];
///Aquire Screen Size
$(function () {
var ScreenWidth = window.screen.availWidth;
var ScreenWidth = ScreenWidth * 0.9;
var ScreenHeight = window.screen.availHeight;
var ScreenHeight = ScreenHeight * 0.85;
$("#bigcontainer").width(ScreenWidth).height(ScreenHeight);
//////Toggle Buttons for Selection and Stats DIVS
/////Show or Hide Base Options
$("#hidebaseoptions").click(function(){
$("#minimizebaseoptions").toggle();
$("#maximizebaseoptions").toggle();
$("#baseoptionsdiv").toggle();
});
$("#showbaseoptions").click(function(){
$("#minimizebaseoptions").toggle();
$("#maximizebaseoptions").toggle();
$("#baseoptionsdiv").toggle();
});
/////Show or Hide Cohort Stats
$("#hidecohortstats").click(function(){
$("#minimizecohortstats").toggle();
$("#maximizecohortstats").toggle();
$("#expandedselectors").toggle();
});
$("#showcohortstats").click(function(){
$("#minimizecohortstats").toggle();
$("#maximizecohortstats").toggle();
$("#expandedselectors").toggle();
});
/////Show or Hide Treatment Stats
$("#hidetreatmentstats").click(function(){
$("#minimizetreatmentstats").toggle();
$("#maximizetreatmentstats").toggle();
$("#treatmentgroupsdiv").toggle();
});
$("#showtreatmentstats").click(function(){
$("#minimizetreatmentstats").toggle();
$("#maximizetreatmentstats").toggle();
$("#treatmentgroupsdiv").toggle();
});
//////Toggle Buttons for Selection and Stats DIVS
/////Show or Hide Drop Down DIVs (COLUMN CHART UPDATE)////
/////Show or Hide Drop Down DIVs (COLUMN CHART UPDATE)////
$("#hidecohorts").click(function(){
$("#cohortsVISIBLE").toggle();
$("#cohortsHIDDEN").toggle();
$("#cohortstatsandoptions").toggle();
});
$("#showcohorts").click(function(){
$("#cohortsVISIBLE").toggle();
$("#cohortsHIDDEN").toggle();
$("#cohortstatsandoptions").toggle();
});
/////Show or Hide Treatment Stats
$("#hidetreatments").click(function(){
$("#treatmentsVISIBLE").toggle();
$("#treatmentsHIDDEN").toggle();
$("#treatmentstatsandoptions").toggle();
});
$("#showtreatments").click(function(){
$("#treatmentsVISIBLE").toggle();
$("#treatmentsHIDDEN").toggle();
$("#treatmentstatsandoptions").toggle();
});
/////Show or Hide Group Selectors and Stats
$("#hidegroups").click(function(){
$("#groupsVISIBLE").toggle();
$("#groupsHIDDEN").toggle();
$("#groupstatsandoptions").toggle();
});
$("#showgroups").click(function(){
$("#groupsVISIBLE").toggle();
$("#groupsHIDDEN").toggle();
$("#groupstatsandoptions").toggle();
});
});
$(document).ready(function() {
statusupdate();
if(isAPIAvailable()) {
$('#files').bind('change', handleFileSelect);
}
//////////Alert if Wrong Browser Type (not using Chrome)///////////
var isChrome = !!window.chrome && !isOpera;
if (isChrome !== true)
{
alert("You should be using Google Chrome. Some features may not work properly with other browsers");
}
});
function isAPIAvailable() {
// Check for the various File API support.
if (window.File && window.FileReader && window.FileList && window.Blob) {
// Great success! All the File APIs are supported.
return true;
} else {
// source: File API availability - http://caniuse.com/#feat=fileapi
// source: <output> availability - http://html5doctor.com/the-output-element/
document.writeln('The HTML5 APIs used in this form are only available in the following browsers:<br />');
// 6.0 File API & 13.0 <output>
document.writeln(' - Google Chrome: 13.0 or later<br />');
// 3.6 File API & 6.0 <output>
document.writeln(' - Mozilla Firefox: 6.0 or later<br />');
// 10.0 File API & 10.0 <output>
document.writeln(' - Internet Explorer: Not supported (partial support expected in 10.0)<br />');
// ? File API & 5.1 <output>
document.writeln(' - Safari: Not supported<br />');
// ? File API & 9.2 <output>
document.writeln(' - Opera: Not supported');
return false;
}
}
/////Process Uploaded CSV File///////////////
function handleFileSelect(evt) {
statusobject.status = "Processing Uploaded File";
statusupdate();
var files = evt.target.files; // FileList object
var file = files[0];
// read the file metadata
var FileName = escape(file.name);
var FileType = file.type;
var FileSize = file.size;
// read the file contents
setTimeout(structureJavaScriptArray(file), 200);;
}
////Placeholder array
var newbasearray = [];
/////Read CSV file to Javascript Array
function structureJavaScriptArray(file) {
statusobject.status = "Converting File to Javascript Array";
statusupdate();
var reader = new FileReader();
reader.readAsText(file);
reader.onload = function(event){
var csv = event.target.result;
var data = $.csv.toArrays(csv);
var update = document.getElementById("update");
var newbasearray = data;
statusobject.status = "Analyzing Javascript Array";
analyzeArray(newbasearray);
};
reader.onerror = function(){ alert('Unable to read ' + file.fileName); };
}
/////////Style Arrays////////
var cancertypeshapesarray = ['circle','square','triangle','diamond','star','polygon','circle','circle','circle','circle','circle','circle'];
var cancertypeshapesarrayhtmlcodes = ['&#9679;','&#9632;','&#9650;','&#9670;','&#9733;','&#9751;','&#9679;','&#9679;','&#9679;','&#9679;','&#9679;','&#9679;'];
var treatmentcolorsarray = ['gray','fuchsia','aqua','maroon','navy','lime','teal','olive','purple','blue','red','yellow','green'];
var cancertypecolorsarray = ['blue','red','green','yellow','purple','olive','teal','lime','navy','aqua','fuchsia','maroon'];
var cancertreatpairsselectionformat = [[null,null,null]];
/////////FUNCTIONS//////////
/////////FUNCTIONS//////////
/////////FUNCTIONS//////////
/////////FUNCTIONS//////////
/////////FUNCTIONS//////////
////STATS FUNCTIONS////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////STATS FUNCTIONS////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////STATS FUNCTIONS////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////STATS FUNCTIONS////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////STATS FUNCTIONS////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////STATS FUNCTIONS////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////STATS FUNCTIONS////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////STATS FUNCTIONS////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////Welch's T Test//////
function welchttest(firstsamplemean, firstsamplestandarddeviation, firstsamplesize, secondsamplemean, secondsamplestandarddeviation, secondsamplesize ) {
var tvaluenumerator = firstsamplemean - secondsamplemean;
var firstsamplevariance = firstsamplestandarddeviation * firstsamplestandarddeviation;
var secondsamplevariance = secondsamplestandarddeviation * secondsamplestandarddeviation;
var tvaluedenominator = (firstsamplevariance / firstsamplesize ) + (secondsamplevariance / secondsamplesize );
var tvaluedenominator = math.sqrt(tvaluedenominator);
var tscore = tvaluenumerator / tvaluedenominator;
return tscore;
}
////Linear Regression Analysis////
////Linear Regression Function (from Trent Richardson)////
////Linear Regression Function (from Trent Richardson)////
////Returns
//var lr = linearRegression(known_y, known_x);
// now you have:
// lr.slope
// lr.intercept
// lr.r2
function linearRegression(y,x){
var lr = {};
var n = y.length;
var sum_x = 0;
var sum_y = 0;
var sum_xy = 0;
var sum_xx = 0;
var sum_yy = 0;
for (var i = 0; i < y.length; i++) {
sum_x += x[i];
sum_y += y[i];
sum_xy += (x[i]*y[i]);
sum_xx += (x[i]*x[i]);
sum_yy += (y[i]*y[i]);
}
lr['slope'] = (n * sum_xy - sum_x * sum_y) / (n*sum_xx - sum_x * sum_x);
lr['intercept'] = (sum_y - lr.slope * sum_x)/n;
lr['r2'] = Math.pow((n*sum_xy - sum_x*sum_y)/Math.sqrt((n*sum_xx-sum_x*sum_x)*(n*sum_yy-sum_y*sum_y)),2);
return lr;
}
//////Calculate Linear Regression, Outlier De-weighted Linear Regression and P Value From 2 paired arrays/////
//////Calculate Linear Regression, Outlier De-weighted Linear Regression and P Value From 2 paired arrays/////
function calculatelinearregressionandpvalue(XaxisOutcome, YaxisParameter, SelectedOutcome, SelectedPopulation) {
if (XaxisOutcome.length == YaxisParameter.length)
{
var CorrelationInputArray = [];
var SampleSize = XaxisOutcome.length;
if (isNaN(SampleSize) == true)
{
var SampleSize = 0;
}
var SampleSizeCoEfficient = 1;
var lr = linearRegression(YaxisParameter,XaxisOutcome);
var roundedr2 = Math.round(lr.r2 * 10000) / 10000;
var CheckIfValid = isNaN(roundedr2);
if (roundedr2 > 1 || roundedr2 < 0 || CheckIfValid == true)
{roundedr2 = 0;}
/////Calculate P Value
var tempslope = lr.slope;
if (isNaN(tempslope) == true)
{
var tempslope = 0;
}
var tempintercept = lr.intercept;
if (isNaN(tempintercept) == true)
{
var tempintercept = 0;
}
var tempPvalue = linearregressionpvalue(YaxisParameter,XaxisOutcome,tempslope,tempintercept);
if (isNaN(tempPvalue) == true || roundedr2 == 0 || roundedr2 == 1)
{
var tempPvalue = 1;
}
////Single Level Outlier Adjusted 1r2 Value
CombinedArray = [];
var combinedarraycount = 0;
while (combinedarraycount < YaxisParameter.length)
{
var YValue = YaxisParameter[combinedarraycount];
var XValue = XaxisOutcome[combinedarraycount];
CombinedArray.push([YValue, XValue]);
combinedarraycount++;
}
CombinedArray.sort(function(a,b){
// each value in this array is an array
// the 0th position has what we want to sort on
// Date objects are represented as a timestamp when converted to numbers
return a[0] - b[0];
});
CombinedArray.pop();
CombinedArray.shift();
CombinedArray.sort(function(a,b){
return a[1] - b[1];
});
CombinedArray.pop();
CombinedArray.shift();
var combinedarraycount = 0;
var AdjustedYValues = [];
var AdjustedXValues = [];
while (combinedarraycount < CombinedArray.length)
{
AdjustedYValues.push(CombinedArray[combinedarraycount][0]);
AdjustedXValues.push(CombinedArray[combinedarraycount][1]);
combinedarraycount++;
}
var OutlierAdjusted = linearRegression(AdjustedYValues,AdjustedXValues);
var OutlierAdjustedRoundedr2 = Math.round(OutlierAdjusted.r2 * 10000) / 10000;
var CheckIfValidADJUSTED = isNaN(OutlierAdjustedRoundedr2);
if (OutlierAdjustedRoundedr2 < 0 || OutlierAdjustedRoundedr2 > 1 || CheckIfValidADJUSTED == true)
{
var OutlierAdjustedRoundedr2 = 0;
}
var composite = (OutlierAdjustedRoundedr2 * 0.25) + (roundedr2 * 0.75);
var compositerounded = Math.round(composite * 10000) / 10000;
if (isNaN(compositerounded) == true)
{
var compositerounded = 0;
}
CorrelationInputArray.push(tempPvalue, roundedr2, compositerounded, tempslope, tempintercept, SampleSize);
return CorrelationInputArray;
}
}
////Define P Value of Line of Best Fit
function linearregressionpvalue(YaxisParameter, XaxisOutcome, slope, intercept) {
/////Calculate P Value
SampleYValuesMean = math.mean(YaxisParameter);
SampleYValuesMin = math.min(YaxisParameter);
SampleYValuesMax = math.max(YaxisParameter);
////Loop Value to create arrays of probabilities
var PredictedProbabilities = [];
var NullProbabilities = [];
var PValueLoopCount = 0;
while (PValueLoopCount < YaxisParameter.length)
{
var tempSampleY = YaxisParameter[PValueLoopCount];
var tempSampleX = XaxisOutcome[PValueLoopCount];
var PredictedYValue = (slope * tempSampleX) + intercept;
var PredictedYValuetoMax = SampleYValuesMax - PredictedYValue;
var PredictedYValuetoMin = PredictedYValue - SampleYValuesMin;
var MaximimumRangeForPredictedValue = math.max([PredictedYValuetoMax,PredictedYValuetoMin]);
var NullYValuetoMax = SampleYValuesMax - SampleYValuesMean;
var NullYValuetoMin = SampleYValuesMean - SampleYValuesMin;
var MaximimumRangeForNullValue = math.max([NullYValuetoMax,NullYValuetoMin]);
var RealDifferenceBetweenActualAndPredicted = math.abs(tempSampleY - PredictedYValue);
var RealDifferenceBetweenActualAndNull = math.abs(tempSampleY - SampleYValuesMean);
var ProbabilityOfProximitytoPredicted = RealDifferenceBetweenActualAndPredicted / MaximimumRangeForPredictedValue;
var ProbabilityOfProximitytoNull = RealDifferenceBetweenActualAndNull / MaximimumRangeForNullValue;
PredictedProbabilities.push(ProbabilityOfProximitytoPredicted);
NullProbabilities.push(ProbabilityOfProximitytoNull);
PValueLoopCount++;
}
/////Run T Test on the Probabilities of Predicted vs Null
var NullProbMean = math.mean(NullProbabilities);
var NullProbStandardDeviation = math.std(NullProbabilities);
var NullProbSampleSize = NullProbabilities.length;
var PredictedProbMean = math.mean(PredictedProbabilities);
var PredictedProbStandardDeviation = math.std(PredictedProbabilities);
var PredictedProbSampleSize = PredictedProbabilities.length;
var tempTscore = welchttest(PredictedProbMean, PredictedProbStandardDeviation, PredictedProbSampleSize, NullProbMean, NullProbStandardDeviation, NullProbSampleSize);
var tempTscore = math.round(tempTscore * 10000) / 10000;
var tempPvalue = jStat.ttest(tempTscore, PredictedProbSampleSize, 2);
var tempPvalue = math.round(tempPvalue * 10000000000000000) / 10000000000000000;
///Error check tempPvalue
if (isNaN(tempPvalue) == true || tempPvalue < 0 || tempPvalue > 1)
{
tempPvalue = 1;
}
return tempPvalue;
}
///////Calculate Means, STD Deviations and Intervals for Data Sets//////
function calculatemeanandintervals(tempvaluescollection) {
if (tempvaluescollection.length < 1)
{
var tempMEAN = null;
var tempLOWINTERVAL = null;
var tempHIGHINTERVAL = null;
}
if (tempvaluescollection.length == 1)
{
var tempMEAN = tempvaluescollection[0];
var tempMEAN = Math.round(tempMEAN * 100) / 100;
var tempLOWINTERVAL = null;
var tempHIGHINTERVAL = null;
}
if (tempvaluescollection.length == 2)
{
var tempMEAN = math.mean(tempvaluescollection);
var tempMEAN = Math.round(tempMEAN * 100) / 100;
var tempSTD = Math.abs(tempvaluescollection[0] - tempvaluescollection[1]);
var tempSTD = Math.round(tempSTD * 100) / 100;
var tempHIGHINTERVAL = tempMEAN + tempSTD;
var tempHIGHINTERVAL = Math.round(tempHIGHINTERVAL * 100);
var tempHIGHINTERVAL = tempHIGHINTERVAL / 100;
var tempLOWINTERVAL = tempMEAN - tempSTD;
var tempLOWINTERVAL = Math.round(tempLOWINTERVAL * 100);
var tempLOWINTERVAL = tempLOWINTERVAL / 100;
if (tempMEAN < 0)
{
if (tempHIGHINTERVAL > 0)
{
tempHIGHINTERVAL = 0;
}
}
if (tempMEAN > 0)
{
if (tempLOWINTERVAL < 0)
{
tempLOWINTERVAL = 0;
}
}
}
if (tempvaluescollection.length > 2)
{
var tempMEAN = math.mean(tempvaluescollection);
var tempMEAN = Math.round(tempMEAN * 100) / 100;
var tempSTD = math.std(tempvaluescollection);
var tempSTD = Math.round(tempSTD * 100) / 100;
var tempHIGHINTERVAL = tempMEAN + tempSTD;
var tempHIGHINTERVAL = Math.round(tempHIGHINTERVAL * 100);
var tempHIGHINTERVAL = tempHIGHINTERVAL / 100;
var tempLOWINTERVAL = tempMEAN - tempSTD;
var tempLOWINTERVAL = Math.round(tempLOWINTERVAL * 100);
var tempLOWINTERVAL = tempLOWINTERVAL / 100;
if (tempMEAN < 0)
{
if (tempHIGHINTERVAL > 0)
{
tempHIGHINTERVAL = 0;
}
}
if (tempMEAN > 0)
{
if (tempLOWINTERVAL < 0)
{
tempLOWINTERVAL = 0;
}
}
}
var meanandstdcalculations = [tempMEAN, tempSTD, tempLOWINTERVAL, tempHIGHINTERVAL];
return meanandstdcalculations;
}
//////Calculate ANOVA With Max Mean Difference and P Value//////
//////Calculate ANOVA With Max Mean Difference and P Value//////
//////Calculate ANOVA With Max Mean Difference and P Value//////
function calculateANOVAwithmaxdifference(inputarrays) {
if (inputarrays.length > 2 && isNaN(inputarrays[0][0]) == false)
{
var count = 0;
var tempmeanslist = [];
while (count < inputarrays.length)
{
var tempindividualarray = inputarrays[count];
if (tempindividualarray.length > 0)
{
var tempindividualmean = jStat.mean(tempindividualarray);
tempmeanslist.push(tempindividualmean);
}
count++;
}
var tempmaxmean = jStat.max(tempmeanslist);
var tempminmean = jStat.min(tempmeanslist);
var tempmaxdifference = tempmaxmean - tempminmean;
var tempmaxdifference = tempmaxdifference * 100;
var tempmaxdifference = Math.round(tempmaxdifference);
var tempmaxdifference = tempmaxdifference / 100;
var ANOVAFScore = jStat.anovafscore(inputarrays);
var ANOVAFScore = Math.round(ANOVAFScore * 10000) / 10000;
var ANOVAPValue = jStat.anovaftest(ANOVAFScore, 4, 4);
var ANOVAPValue = Math.round(ANOVAPValue * 1000000000000) / 1000000000000;
if (ANOVAPValue < 0 || ANOVAPValue > 1 || isNaN(ANOVAPValue) == true)
{
ANOVAPValue = 1;
}
var tempANOVAinsert = [ANOVAPValue, ANOVAFScore, tempmaxdifference];
}
else
{
var tempANOVAinsert = [null, null, null];
}
return tempANOVAinsert;
}
////Prepare and Run ANOVA Analysis on GROUPS///
////Prepare and Run ANOVA Analysis on GROUPS///
function analyzegroupsattimepointparameterANOVA(MasterTreatmentCohortArray, timepointlist, treatmentlist, groupslist, groupsparentchildlist, populationlist, outcomeslist, cancertypetreatmentpairlist) {
var concatenatedpopulationoutcomeslist = populationlist.concat(outcomeslist);
//alert(concatenatedpopulationoutcomeslist);
var finalresultarray = [["P Value", "F Score", "Max Difference", "Timepoint", "Treatment", "Parameter", "Group Parent"]];
var finalresultarrayTTest = [["P Value", "T Score","Target Population", "Reference Population", "Difference", "Target Mean", "Reference Mean", "Timepoint", "Treatment", "Parameter"]];
///individualTTestArray -> [[PValue, TScore, combinedarraylistlegend[count2], combinedarraylistlegend[count], difference, targetmean, referencemean, temptimepoint, temptreatment, tempparameter]];
var groupswithatleastthreesubsets = [];
var groupswithatleasttwosubsets = [];
var count = 0;
while (count < groupslist.length)
{
var tempparent = groupslist[count];
var parentchecker = 0;
var count2 = 0;
while (count2 < groupsparentchildlist.length)
{
var tempparentchild = groupsparentchildlist[count2];
if (tempparentchild.indexOf(tempparent) > -1)
{
parentchecker++;
}
count2++;
}
if (parentchecker > 2)
{
groupswithatleastthreesubsets.push(tempparent);
}
if (parentchecker > 1)
{
groupswithatleasttwosubsets.push(tempparent);
}
count++;
}
if (groupswithatleasttwosubsets.length > 0)
{
var count = 0;
while (count < timepointlist.length)
{
var temptimepoint = timepointlist[count];
var temptimepoint = String(temptimepoint);
var count2 = 0;
while (count2 < treatmentlist.length)
{
var temptreatment = treatmentlist[count2];
var countP = 0;
while (countP < concatenatedpopulationoutcomeslist.length)
{
var tempparameter = concatenatedpopulationoutcomeslist[countP];
var count3 = 0;
while (count3 < groupswithatleasttwosubsets.length)
{
var combinedarraylist = [];
var combinedarraylistlegend = [];
var tempgroup = groupswithatleasttwosubsets[count3];
var tempgroup = String(tempgroup);
var count4 = 0;
while (count4 < MasterTreatmentCohortArray.length)
{
var groupssubsetarraylist = [];
var tempheaderrow = MasterTreatmentCohortArray[0];
var temprow = MasterTreatmentCohortArray[count4];
var groupcheck = temprow[2].indexOf(tempgroup);
//alert(temprow[0] + " " + temptimepoint + " " + temprow[1] + " " + temptreatment + " " + groupcheck);
if (temprow[0] == temptimepoint && groupcheck > -1 && temprow[1] == "ALL")
{
var count5 = 0;
while (count5 < tempheaderrow.length)
{
var tempselectedheader = tempheaderrow[count5];
var tempselectedheader = String(tempselectedheader);
var targetheader = "Composite - " + temptreatment + ": " + tempparameter;
if (tempselectedheader == targetheader)
{
var tempALLVALUESposition = count5 + 1;
var tempALLVALUESdata = temprow[tempALLVALUESposition];
if (tempALLVALUESdata.length > 0 && isNaN(tempALLVALUESdata[0]) == false)
{
combinedarraylist.push(tempALLVALUESdata);
combinedarraylistlegend.push(temprow[2]);
}
var count5 = 999999999999;
}
count5++;
}
}
count4++;
}
if (combinedarraylist.length > 2)
{
var ANOVAanalysis = calculateANOVAwithmaxdifference(combinedarraylist);
var tempinsert = [ANOVAanalysis[0], ANOVAanalysis[1], ANOVAanalysis[2], temptimepoint, temptreatment, tempparameter, tempgroup];
finalresultarray.push(tempinsert);
}
if (combinedarraylist.length > 1)
{
var TTestanalysis = calculateTTestwithmaxdifference(combinedarraylist, combinedarraylistlegend);
///Returns Array of Arrays -> [[PValue, TScore, combinedarraylistlegend[count2], combinedarraylistlegend[count], difference, targetmean, referencemean]];
var countT = 0;
while (countT < TTestanalysis.length)
{
var individualTTestArray = TTestanalysis[countT];
individualTTestArray.push(temptimepoint, temptreatment, tempparameter);
finalresultarrayTTest.push(individualTTestArray);
///individualTTestArray -> [[PValue, TScore, combinedarraylistlegend[count2], combinedarraylistlegend[count], difference, targetmean, referencemean, temptimepoint, temptreatment, tempparameter]];
countT++;
}
}
count3++;
}
countP++;
}
count2++;
}
count++;
}
}
if (finalresultarray.length > 1)
{
finalresultarray.sort(function(a,b){
return a[0] - b[0];
});
}
else
{
finalresultarray = null;
}
if (finalresultarrayTTest.length > 1)
{
finalresultarrayTTest.sort(function(a,b){
return a[0] - b[0];
});
}
else
{
finalresultarrayTTest = null;
}
var botharrays = [finalresultarray, finalresultarrayTTest];
return botharrays;
}
////Calculate T Test and Max Differences from Array of Arrays/////
////Calculate T Test and Max Differences from Array of Arrays/////
function calculateTTestwithmaxdifference(combinedarraylist, combinedarraylistlegend) {
var relationshipsarray = [];
var count = 0;
while (count < combinedarraylist.length)
{
var referencearray = combinedarraylist[count];
var count2 = 0;
while (count2 < combinedarraylist.length)
{
var singlerelationship = [];
var targetarray = combinedarraylist[count2];
if (count !== count2)
{
var referencemean = math.mean(referencearray);
var referencemean = Math.round(referencemean * 100) / 100;
var targetmean = math.mean(targetarray);
var targetmean = Math.round(targetmean * 100) / 100;
var difference = targetmean - referencemean;
var difference = Math.round(difference * 100) / 100;
if (difference > -0.0000000000000001)
{
var referencestandarddeviation = math.std(referencearray);
var referencestandarddeviation = Math.round(referencestandarddeviation * 1000) / 1000;
var targetstandarddeviation = math.std(targetarray);
var targetstandarddeviation = Math.round(targetstandarddeviation * 1000) / 1000;
//alert(referencemean + " " + referencestandarddeviation + " " + referencearray.length + " " + targetmean + " " + targetstandarddeviation + " " + targetarray.length);
var TScore = welchttest(referencemean, referencestandarddeviation, referencearray.length, targetmean, targetstandarddeviation, targetarray.length)
var TScore = Math.round(TScore * 10000) / 10000;
var PValue = jStat.ttest(TScore, (referencearray.length - 1), 2);
var PValue = Math.round(PValue * 10000000000000000) / 10000000000000000;
//alert(PValue + " " + TScore + " " + combinedarraylistlegend[count2] + " " + combinedarraylistlegend[count] + " " + difference + " " + targetmean + " " + referencemean);
if (PValue > 0 && PValue < 1)
{
var singlerelationship = [PValue, TScore, combinedarraylistlegend[count2], combinedarraylistlegend[count], difference, targetmean, referencemean];
relationshipsarray.push(singlerelationship);
}
}
}
count2++;
}
count++;
}
//alert(relationshipsarray);
return relationshipsarray;
}
////Prepare and Run ANOVA Analysis on COHORTS///
////Prepare and Run ANOVA Analysis on COHORTS///
function analyzecohortsattimepointparameterANOVA(MasterTreatmentCohortArray, timepointlist, treatmentlist, groupslist, groupsparentchildlist, populationlist, outcomeslist, cancertypetreatmentpairlist) {
var concatenatedpopulationoutcomeslist = populationlist.concat(outcomeslist);
//alert(concatenatedpopulationoutcomeslist);
var finalresultarray = [["P Value", "F Score", "Max Difference", "Timepoint", "Treatment", "Parameter", "Group Parent"]];
var finalresultarrayTTest = [["P Value", "T Score","Target Population", "Reference Population", "Difference", "Target Mean", "Reference Mean", "Timepoint", "Treatment", "Parameter"]];
var cohortswithatleasttwosubsets = [];
var tempgroup = "ALL";
if (cancertypetreatmentpairlist.length > 2)
{
var count = 0;
while (count < timepointlist.length)
{
var temptimepoint = timepointlist[count];
var temptimepoint = String(temptimepoint);
var count2 = -1;
while (count2 < 0)
{
var temptreatment = "ALL";
var countP = 0;
while (countP < concatenatedpopulationoutcomeslist.length)
{
var tempparameter = concatenatedpopulationoutcomeslist[countP];
var combinedarraylist = [];
var combinedarraylistlegend = [];
var count3 = 0;
while (count3 < cancertypetreatmentpairlist.length)
{
var tempcohort = cancertypetreatmentpairlist[count3];
var tempcohort = String(tempcohort);
var count4 = 0;
while (count4 < MasterTreatmentCohortArray.length)
{
var tempheaderrow = MasterTreatmentCohortArray[0];
var temprow = MasterTreatmentCohortArray[count4];
if (temprow[0] == temptimepoint && temprow[1] == temptreatment && temprow[2] == "ALL")
{
var cohortarray = [];
var count5 = 0;
while (count5 < tempheaderrow.length)
{
var tempselectedheader = tempheaderrow[count5];
var tempselectedheader = String(tempselectedheader);
var headercohortcheck = tempselectedheader.indexOf(tempcohort);
var headercheck = tempselectedheader.indexOf(tempparameter);
if (headercheck > -1 && headercohortcheck > -1)
{
var tempALLVALUESposition = count5 + 1;
var tempALLVALUESdata = temprow[tempALLVALUESposition];
if (tempALLVALUESdata.length > 0 && isNaN(tempALLVALUESdata[0]) == false)
{
var cohortarray = tempALLVALUESdata;
}
var count5 = 9999999999999;
}
count5++;
}
if (cohortarray.length > 0)
{
combinedarraylist.push(cohortarray);
combinedarraylistlegend.push(tempcohort);
}
}
count4++;
}
count3++;
}
//alert(combinedarraylist);
//alert(combinedarraylistlegend);
if (combinedarraylist.length > 2)
{
var ANOVAanalysis = calculateANOVAwithmaxdifference(combinedarraylist);
var tempinsert = [ANOVAanalysis[0], ANOVAanalysis[1], ANOVAanalysis[2], temptimepoint, temptreatment, tempparameter, tempgroup];
finalresultarray.push(tempinsert);
}
if (combinedarraylist.length > 1)
{
var TTestanalysis = calculateTTestwithmaxdifference(combinedarraylist, combinedarraylistlegend);
///Returns Array of Arrays -> [[PValue, TScore, combinedarraylistlegend[count2], combinedarraylistlegend[count], difference, targetmean, referencemean]];
var countT = 0;
while (countT < TTestanalysis.length)
{
var individualTTestArray = TTestanalysis[countT];
individualTTestArray.push(temptimepoint, temptreatment, tempparameter);
finalresultarrayTTest.push(individualTTestArray);
///individualTTestArray -> [[PValue, TScore, combinedarraylistlegend[count2], combinedarraylistlegend[count], difference, targetmean, referencemean, temptimepoint, temptreatment, tempparameter]];
countT++;
}
}
countP++;
}
count2++;
}
count++;
}
}
if (finalresultarray.length > 1)
{
finalresultarray.sort(function(a,b){
return a[0] - b[0];
});
}
else
{
var finalresultarray = null;
}
if (finalresultarrayTTest.length > 1)
{
finalresultarrayTTest.sort(function(a,b){
return a[0] - b[0];
});
}
else
{
var finalresultarrayTTest = null;
}
var botharrays = [finalresultarray, finalresultarrayTTest];
return botharrays;
}
////Prepare and Run ANOVA Analysis on TREATMENT CLUSTERS///
////Prepare and Run ANOVA Analysis on TREATMENT CLUSTERS///
function analyzetreatmentsattimepointparameterANOVA(MasterTreatmentCohortArray, timepointlist, treatmentlist, groupslist, groupsparentchildlist, populationlist, outcomeslist, cancertypetreatmentpairlist) {
var concatenatedpopulationoutcomeslist = populationlist.concat(outcomeslist);
//alert(concatenatedpopulationoutcomeslist);
var finalresultarray = [["P Value", "F Score", "Max Difference", "Timepoint", "Treatment", "Parameter", "Group Parent"]];
var finalresultarrayTTest = [["P Value", "T Score","Target Population", "Reference Population", "Difference", "Target Mean", "Reference Mean", "Timepoint", "Group", "Parameter"]];
var tempgroup = "ALL";
if (treatmentlist.length > 1)
{
var count = 0;
while (count < timepointlist.length)
{
var temptimepoint = timepointlist[count];
var temptimepoint = String(temptimepoint);
var count2 = 0;
while (count2 < 1)
{
var countP = 0;
while (countP < concatenatedpopulationoutcomeslist.length)
{
var tempparameter = concatenatedpopulationoutcomeslist[countP];
var combinedarraylist = [];
var combinedarraylistlegend = [];
var count3 = 0;
while (count3 < treatmentlist.length)
{
var temptreatmentselection = treatmentlist[count3];
var temptreatmentselection = String(temptreatmentselection);
var count4 = 0;
while (count4 < MasterTreatmentCohortArray.length)
{
var tempheaderrow = MasterTreatmentCohortArray[0];
var treatmentarraylist = [];
var temprow = MasterTreatmentCohortArray[count4];
//alert(temprow[0] + " " + temptimepoint + " " + temprow[1] + " " + temptreatment + " " + groupcheck);
if (temprow[0] == temptimepoint && temprow[1] == "ALL" && temprow[2] == "ALL")
{
var count4 = 9999999999;
var count5 = 0;
while (count5 < tempheaderrow.length)
{
var tempselectedheader = tempheaderrow[count5];
var tempselectedheader = String(tempselectedheader);
var targetheader = "Composite - " + temptreatmentselection + ": " + tempparameter;
if (targetheader == tempselectedheader)
{
var tempALLVALUESposition = count5 + 1;
var tempALLVALUESdata = temprow[tempALLVALUESposition];
if (tempALLVALUESdata.length > 0 && isNaN(tempALLVALUESdata[0]) == false)
{
var count6 = 0;
while (count6 < tempALLVALUESdata.length)
{
treatmentarraylist.push(tempALLVALUESdata[count6]);
count6++;
}
}
var count5 = 9999999;
}
count5++;
}
}
if (treatmentarraylist.length > 0)
{
combinedarraylist.push(treatmentarraylist);
combinedarraylistlegend.push(temptreatmentselection);
}
count4++;
}
count3++;
}
if (combinedarraylist.length > 2)
{
var ANOVAanalysis = calculateANOVAwithmaxdifference(combinedarraylist);
var tempinsert = [ANOVAanalysis[0], ANOVAanalysis[1], ANOVAanalysis[2], temptimepoint, "ALL", tempparameter, "ALL"];
finalresultarray.push(tempinsert);
}
if (combinedarraylist.length > 1)
{
var TTestanalysis = calculateTTestwithmaxdifference(combinedarraylist, combinedarraylistlegend);
///Returns Array of Arrays -> [[PValue, TScore, combinedarraylistlegend[count2], combinedarraylistlegend[count], difference, targetmean, referencemean]];
var countT = 0;
while (countT < TTestanalysis.length)
{
var individualTTestArray = TTestanalysis[countT];
individualTTestArray.push(temptimepoint, "Total", tempparameter);
finalresultarrayTTest.push(individualTTestArray);
///individualTTestArray -> [[PValue, TScore, combinedarraylistlegend[count2], combinedarraylistlegend[count], difference, targetmean, referencemean, temptimepoint, group, tempparameter]];
countT++;
}
}
countP++;
}
count2++;
}
count++;
}
}
if (finalresultarray.length > 1)
{
finalresultarray.sort(function(a,b){
return a[0] - b[0];
});
}
else
{
var finalresultarray = null;
}
if (finalresultarrayTTest.length > 1)
{
finalresultarrayTTest.sort(function(a,b){
return a[0] - b[0];
});
}
else
{
var finalresultarrayTTest = null;
}
var botharrays = [finalresultarray, finalresultarrayTTest];
return botharrays;
}
/////Functions for parsing data from raw array (newbasearray)///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////Functions for parsing data from raw array (newbasearray)///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////Functions for parsing data from raw array (newbasearray)///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////Functions for parsing data from raw array (newbasearray)///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///Determine Timepoint Postion///
function determinetimepointposition(newbasearray) {
var count = 0;
var timepointposition = -1;
while (count < newbasearray.length)
{
var checker = newbasearray[0][count];
if (checker == "Timepoint")
{
var timepointposition = count;
count++;
}
else { count++;}
}
if (timepointposition < 0)
{
alert("Timepoint Position Not Found");
}
return timepointposition;
}
///Create Sorted Timepoint List with Experimental vs Baseline Differentials///
function createsortedtimepointlistwithdifferentials(newbasearray, timepointposition) {
var timepointlist = [];
var count = 1;
while (count < newbasearray.length)
{
var checker = newbasearray[count][timepointposition];
var checker = Number(checker);
var ValueInIndex = timepointlist.indexOf(checker);
if (ValueInIndex < 0 )
{
timepointlist.push(checker);
}
count++;
}
timepointlist.sort(function(a, b){return a-b});
/////Create Differential TimepointList (Experimental Timepoint vs Baseline)
var tempcomparisonlist = [];
if (timepointlist[0] == 0 && timepointlist.length > 1)
{
var count = 1;
while (count < timepointlist.length)
{
var temptimepointcomparison = timepointlist[count] + " vs " + 0;
tempcomparisonlist.push(temptimepointcomparison);
count++;
}
}
if (tempcomparisonlist.length > 0)
{
var count = 0;
while (count < tempcomparisonlist.length)
{
var tempcomparisoninsert = tempcomparisonlist[count];
timepointlist.push(tempcomparisoninsert);
count++;
}
}
return timepointlist;
}
///Determine Patient Position///
function determinepatientposition(newbasearray) {
var count = 0;
var patientposition = -1;
while (count < newbasearray[0].length)
{
var checker = newbasearray[0][count];
if (checker == "PatientID")
{
var patientposition = count;
}
count++;
}
if (patientposition < 0)
{
alert("Patient Position Not Found");
}
return patientposition;
}
///Create Sorted Patient List///
function createsortedpatientlist(newbasearray, patientposition) {
var patientlist = [];
var count = 1;
while (count < newbasearray.length)
{
var checker = newbasearray[count][patientposition];
var ValueInIndex = patientlist.indexOf(checker);
if (ValueInIndex < 0 && checker.length > 0 && checker !== null && checker !== "null")
{
patientlist.push(checker);
}
count++;
}
patientlist.sort();
return patientlist;
}
////Create Sorted Population List Array/////
function createsortedpopulationlistarray(newbasearray) {
var populationlist = [];
var populationlistindex = [];
var sortedpopulationlistarray = [];
var count = 0;
while (count < newbasearray[0].length)
{
var checker = newbasearray[0][count];
var n = checker.indexOf(":");
if (n > -1)
{
var CheckForNonNullValues = -1;
var count2 = 1;
while (count2 < newbasearray.length)
{
if (newbasearray[count2][count].length > 0 && newbasearray[count2][count] !== "null" && newbasearray[count2][count] !== null)
{
CheckForNonNullValues++;
}
count2++;
}
if (CheckForNonNullValues > 0)
{
var selectedpopulation = checker;
var selectedpopulation = selectedpopulation + ".";
var ValueInIndex = populationlist.indexOf(selectedpopulation);
if (ValueInIndex < 0)
{
populationlist.push(selectedpopulation);
populationlistindex.push(count);
sortedpopulationlistarray.push([selectedpopulation, count]);
}
}
}
count++;
}
sortedpopulationlistarray.sort();
var populationlist = [];
var populationlistindex = [];
var count = 0;
while (count < sortedpopulationlistarray.length)
{
populationlist.push(sortedpopulationlistarray[count][0]);
populationlistindex.push(sortedpopulationlistarray[count][1]);
count++;
}
var allthreepopulationarrays = [populationlist, populationlistindex, sortedpopulationlistarray]
return allthreepopulationarrays;
}
///Create Sorted Outcomes List///
function createsortedoutcomeslistarray(newbasearray) {
var outcomeslist = [];
var outcomeslistindex = [];
var sortedoutcomeslist = [];
var count = 0;
while (count < newbasearray[0].length)
{
var checker = newbasearray[0][count].indexOf("Outcomes -");
if (checker > -1)
{
var CheckForNonNullValues = -1;
var UniqueValuesList = [];
var UniqueValuesCount = 0;
var count2 = 1;
while (count2 < newbasearray.length)
{
if (newbasearray[count2][count].length > 0 && newbasearray[count2][count] !== "null" && newbasearray[count2][count] !== null)
{
CheckForNonNullValues++;
var tempvalue = newbasearray[count2][count];
var checkforuniquevalue = UniqueValuesList.indexOf(tempvalue);
if (checkforuniquevalue < 0)
{
UniqueValuesList.push(tempvalue);
UniqueValuesCount++;
}
}
count2++;
}
if (CheckForNonNullValues > 1 && UniqueValuesCount > 1)
{
var selectedmarker = newbasearray[0][count];
var ValueInIndex = outcomeslist.indexOf(selectedmarker);
if (ValueInIndex < 0 )
{
outcomeslist.push(selectedmarker);
outcomeslistindex.push(count);
sortedoutcomeslist.push([selectedmarker, count]);
}
}
}
count++;
}
sortedoutcomeslist.sort();
var allthreeoutcomesarrays = [outcomeslist, outcomeslistindex, sortedoutcomeslist];
return allthreeoutcomesarrays;
}
///Create Sorted Groups List///
function createsortedgroupslistarray(newbasearray) {
var groupslist = [];
var groupslistindex = [];
var sortedgroupslist = [];
var groupchildlist = [];
var groupparentchildlist = [];
var count = 0;
while (count < newbasearray[0].length)
{
var checker = newbasearray[0][count].indexOf("Group -");
if (checker > -1)
{
var CheckForNonNullValues = 0;
var count2 = 1;
var tempchildlist = [];
var tempparentchildlist = [];
while (count2 < newbasearray.length)
{
if (newbasearray[count2][count].length > 0 && newbasearray[count2][count] !== "null" && newbasearray[count2][count] !== null)
{
CheckForNonNullValues++;
var tempchildvalue = newbasearray[count2][count];
if (tempchildlist.indexOf(tempchildvalue) == -1)
{
tempchildlist.push(tempchildvalue);
}
}
count2++;
}
if (CheckForNonNullValues > 5)
{
var selectedmarker = newbasearray[0][count];
var ValueInIndex = groupslist.indexOf(selectedmarker);
if (ValueInIndex < 0 )
{
groupslist.push(selectedmarker);
groupslistindex.push(count);
sortedgroupslist.push([selectedmarker, count]);
groupchildlist.push(tempchildlist);
var count6 = 0;
while (count6 < tempchildlist.length)
{
var tempchildvalue2 = tempchildlist[count6];
var tempparentchildvalue = newbasearray[0][count] + ": " + tempchildvalue2;
groupparentchildlist.push(tempparentchildvalue);
count6++;
}
}
}
}
count++;
}
sortedgroupslist.sort();
var allgroupsarrays = [groupslist, groupslistindex, sortedgroupslist, groupparentchildlist];
return allgroupsarrays;
}
///Determine CancerType Position////
function determinecancertypeposition(newbasearray) {
var count = 0;
var cancertypeposition = -1;
while (count < newbasearray[0].length)
{
var checker = newbasearray[0][count];
if (checker == "CancerType")
{
var cancertypeposition = count;
}
count++;
}
if (cancertypeposition < 0)
{
alert("Cancer Type Position Not Found");
}
return cancertypeposition;
}
///Create Sorted Cancer Type List///
function createsortedcancertypelist(newbasearray, cancertypeposition) {
var cancertypelist = [];
var count = 1;
while (count < newbasearray.length)
{
var checker = newbasearray[count][cancertypeposition];
var ValueInIndex = cancertypelist.indexOf(checker);
if (ValueInIndex < 0 )
{
cancertypelist.push(checker);
}
count++;
}
cancertypelist.sort();
return cancertypelist;
}
///Determine Treatment Position///
function determinetreatmentposition(newbasearray) {
var count = 0;
var treatmentposition = -1;
while (count < newbasearray[0].length)
{
var checker = newbasearray[0][count];
if (checker == "Treatment")
{
var treatmentposition = count;
}
count++;
}
if (treatmentposition < 0)
{
alert("Treatment Position Not Found");
}
return treatmentposition;
}
///Create Sorted List of Treatments///
function createsortedtreatmentlist(newbasearray, treatmentposition) {
var treatmentlist = [];
var count = 1;
while (count < newbasearray.length)
{
var checker = newbasearray[count][treatmentposition];
var ValueInIndex = treatmentlist.indexOf(checker);
if (ValueInIndex < 0 )
{
treatmentlist.push(checker);
}
count++;
}
treatmentlist.sort();
return treatmentlist;
}
///Create CancerType-Treatment Pair List (Cohorts)///
function createcancertypetreatmentpairlist(newbasearray, cancertypeposition, treatmentposition) {
var cancertypetreatmentpairlist = [];
var count = 1;
while (count < newbasearray.length)
{
var checker1 = newbasearray[count][cancertypeposition];
var checker2 = newbasearray[count][treatmentposition];
var mergedcancertypetreatmentpair = checker1 + " - " + checker2;
var ValueInIndex = cancertypetreatmentpairlist.indexOf(mergedcancertypetreatmentpair);
if (ValueInIndex < 0 )
{
cancertypetreatmentpairlist.push(mergedcancertypetreatmentpair);
}
count++;
}
cancertypetreatmentpairlist.sort();
return cancertypetreatmentpairlist;
}
///Create Timepoint-Parameter Pairs List///
function createtimepointparameterpairslist(timepointlist, populationlist) {
var timepointparameterpairslist = [];
var populationlistcount = 0;
while (populationlistcount < populationlist.length)
{
var selectedpopulation = populationlist[populationlistcount];
var timepointlistcount = 0;
while (timepointlistcount < timepointlist.length)
{
var selectedtimepoint = timepointlist[timepointlistcount];
var HeaderToInsert = selectedtimepoint + ": " + selectedpopulation;
timepointparameterpairslist.push(HeaderToInsert);
timepointlistcount++;
}
populationlistcount++;
}
return timepointparameterpairslist;
}
//////Create Stable Duplicate of an Array
function createstableduplicatearray(array) {
var duplicatearray = [];
var count = 0;
while (count < array.length)
{
duplicatearray.push(array[count]);
count++;
}
return duplicatearray;
}
///////Construct List of Cohort-Outcome/Population Pairs Array Headers (Timepoint-Parameter) List///////////
///////Construct List of Cohort-Outcome/Population Pairs Array Headers (Timepoint-Parameter) List///////////
function createcohortpopulationoutcomepairlist(cancertypetreatmentpairlist, outcomeslist, populationlist, treatmentlist) {
var cohortpopulationoutcomepairs = [];
var count1 = 0;
while (count1 < populationlist.length)
{
var count2 = 0;
while (count2 < cancertypetreatmentpairlist.length)
{
var tempvalue = cancertypetreatmentpairlist[count2] + ": " + populationlist[count1];
cohortpopulationoutcomepairs.push(tempvalue);
count2++;
}
var count3 = 0;
while (count3 < treatmentlist.length)
{
var tempvalue = "Composite - " + treatmentlist[count3] + ": " + populationlist[count1];
cohortpopulationoutcomepairs.push(tempvalue);
count3++;
}
count1++;
}
while (count1 < outcomeslist.length)
{
var count2 = 0;
while (count2 < cancertypetreatmentpairlist.length)
{
var tempvalue = cancertypetreatmentpairlist[count2] + ": " + outcomeslist[count1];
cohortpopulationoutcomepairs.push(tempvalue);
count2++;
}
var count3 = 0;
while (count3 < treatmentlist.length)
{
var tempvalue = "Composite - " + treatmentlist[count3] + ": " + outcomeslist[count1];
cohortpopulationoutcomepairs.push(tempvalue);
count3++;
}
count1++;
}
return cohortpopulationoutcomepairs;
}
/////////////Create Composite Treatment-Population/Outcomes List for COLUMN CHART/////
/////////////Create Composite Treatment-Population/Outcomes List for COLUMN CHART/////
function createcompositetreatmentpopulationoutcomeslistforCOLUMNCHART(treatmentlist, populationlist, outcomeslist) {
var compositetreatmentpopulationlist = [];
var count = 0;
while (count < treatmentlist.length)
{
var temptreatment = treatmentlist[count];
var count2 = 0;
while (count2 < populationlist.length)
{
var temppopulation = populationlist[count2];
var tempcomposite = "Composite - " + temptreatment + ": " + temppopulation;
compositetreatmentpopulationlist.push(tempcomposite);
count2++;
}
var count2 = 0;
while (count2 < outcomeslist.length)
{
var tempoutcome = outcomeslist[count2];
var tempcomposite = "Composite - " + temptreatment + ": " + tempoutcome;
compositetreatmentpopulationlist.push(tempcomposite);
count2++;
}
count++;
}
//alert(compositetreatmentpopulationlist);
return compositetreatmentpopulationlist;
}
/////Create Appended (CancerType and Composite) Treatment Pair List//////////
/////Create Appended (CancerType and Composite) Treatment Pair List//////////
function createappendedcancertypewithcompositetreatmentpairlist(cancertypetreatmentpairlist, treatmentlist) {
var appendedcancertypetreatmentpairlist = [];
var count = 0;
while (count < cancertypetreatmentpairlist.length)
{
appendedcancertypetreatmentpairlist.push(cancertypetreatmentpairlist[count]);
count++;
}
var count = 0;
while (count < treatmentlist.length)
{
appendedcancertypetreatmentpairlist.push("Composite - " + treatmentlist[count]);
count++;
}
//alert(appendedcancertypetreatmentpairlist);
return appendedcancertypetreatmentpairlist;
}
////////////Functions for Constructing Master Outcomes Array (Outcomes Analysis)/////////////////////////////////////////////
////////////Functions for Constructing Master Outcomes Array (Outcomes Analysis)/////////////////////////////////////////////
////////////Functions for Constructing Master Outcomes Array (Outcomes Analysis)/////////////////////////////////////////////
////////////Functions for Constructing Master Outcomes Array (Outcomes Analysis)/////////////////////////////////////////////
////////////Functions for Constructing Master Outcomes Array (Outcomes Analysis)/////////////////////////////////////////////
////////////Functions for Constructing Master Outcomes Array (Outcomes Analysis)/////////////////////////////////////////////
/////Construct Outcomes Array Headers/////
function constructoutcomesarrayheaders(outcomeslist, groupslist, timepointparameterpairslist) {
var outcomesarrayheaders = [];
outcomesarrayheaders.push("PatientID");
outcomesarrayheaders.push("CancerType");
outcomesarrayheaders.push("Treatment");
outcomesarrayheaders.push("CancerTreatPair");
outcomesarrayheaders.push("Style1");
outcomesarrayheaders.push("Style2");
var count = 0;
while (count < outcomeslist.length)
{
var tempvalue = outcomeslist[count];
outcomesarrayheaders.push(tempvalue);
count++;
}
var count = 0;
while (count < groupslist.length)
{
var tempvalue = groupslist[count];
outcomesarrayheaders.push(tempvalue);
count++;
}
var count = 0;
while (count < timepointparameterpairslist.length)
{
var tempvalue = timepointparameterpairslist[count];
outcomesarrayheaders.push(tempvalue);
count++;
}
return outcomesarrayheaders;
}
////Determine CancerType-Treatment Pair Position
function determinecancertypetreatmentpairposition(MasterOutcomesArray) {
var count = 0;
while (count < MasterOutcomesArray[0].length)
{
if (MasterOutcomesArray[0][count] == "CancerTreatPair")
{
var position = count;
count = 999999999999999999999;
}
count++;
}
return position;
}
////Determine Style Position 1
function determinestyleposition1(MasterOutcomesArray) {
var count = 0;
while (count < MasterOutcomesArray[0].length)
{
if (MasterOutcomesArray[0][count] == "Style1")
{
var position = count;
count = 999999999999999999999;
}
count++;
}
return position;
}
////Determine Style Position 2
function determinestyleposition2(MasterOutcomesArray) {
var count = 0;
while (count < MasterOutcomesArray[0].length)
{
if (MasterOutcomesArray[0][count] == "Style2")
{
var position = count;
count = 999999999999999999999;
}
count++;
}
return position;
}
////Determine Initial Outcome Position in Array////
function determinefirstoutcomeposition(MasterOutcomesArray) {
var headerloopcount = 0;
var outcomesindexcheck = -1;
while (headerloopcount < MasterOutcomesArray[0].length)
{
var selectedheadervalue = MasterOutcomesArray[0][headerloopcount];
var outcomesindexcheck = selectedheadervalue.indexOf("Outcomes");
if (outcomesindexcheck > -1)
{
var firstoutcomeposition = headerloopcount;
headerloopcount = 9999999999999999999999;
}
headerloopcount++;
}
return firstoutcomeposition;
}
////Determine Initial Population Position in Array///
function determinefirstpopulationposition(MasterOutcomesArray) {
var headerloopcount = 0;
var populationindexcheck = -1;
while (headerloopcount < MasterOutcomesArray[0].length)
{
var selectedheadervalue = MasterOutcomesArray[0][headerloopcount];
var populationindexcheck = selectedheadervalue.indexOf(":");
if (populationindexcheck > -1)
{
var firstpopulationposition = headerloopcount;
headerloopcount = 9999999999999999999999;
}
headerloopcount++;
}
return firstpopulationposition;
}
////////CancerType-Treatment Pair Row Array///////////
function createcancertypetreatpairrowsarray(MasterOutcomesArray, cancertypetreatmentpairlist, cancertreatpairposition) {
var cancertypetreatpairrowsarray = [];
var count = 0;
while (count < cancertypetreatmentpairlist.length)
{
var selectedpair = cancertypetreatmentpairlist[count];
var adjustedrowlist = [];
var unadjustedrowlist = [];
var count2 = 0;
while (count2 < MasterOutcomesArray.length)
{
var masterarrayselection = MasterOutcomesArray[count2][cancertreatpairposition];
if (masterarrayselection == selectedpair)
{
adjustedrowlist.push((count2 - 1));
unadjustedrowlist.push((count2));
}
count2++;
}
var mergedinsert = [selectedpair,adjustedrowlist,unadjustedrowlist];
cancertypetreatpairrowsarray.push(mergedinsert);
count++;
}
return cancertypetreatpairrowsarray;
}
////////Groups Parent-Child Selection Construction and Rows Array///////////
function creategroupsparentchildselectionandrowsarray(MasterOutcomesArray) {
var groupsubsetuniquelist = [];
var groupsubsetrowarray = [];
var unadjustedgroupsubsetrowarray = [];
var headerloopcount = 0;
while (headerloopcount < MasterOutcomesArray[0].length)
{
var groupsindexcheck = -1;
var selectedheadervalue = MasterOutcomesArray[0][headerloopcount];
var groupsindexcheck = selectedheadervalue.indexOf("Group -");
if (groupsindexcheck > -1)
{
var selectedgroup = selectedheadervalue;
var selectedgroupposition = headerloopcount;
var masterloopcount = 1;
while (masterloopcount < MasterOutcomesArray.length)
{
var selectedgroupsubsetvalue = MasterOutcomesArray[masterloopcount][selectedgroupposition];
var groupparentchildpair = selectedgroup + ": " + selectedgroupsubsetvalue;
var groupparentchildpairuniquecheck = groupsubsetuniquelist.indexOf(groupparentchildpair);
if (groupparentchildpairuniquecheck < 0)
{
groupsubsetuniquelist.push(groupparentchildpair);
var freshrowarray = [];
groupsubsetrowarray.push(freshrowarray);
}
///Assign Row Values to groupparentchildpair
var arraypositionofselection = groupsubsetuniquelist.indexOf(groupparentchildpair);
groupsubsetrowarray[arraypositionofselection].push(masterloopcount);
masterloopcount++;
}
}
headerloopcount++;
}
var AllArrays = [groupsubsetuniquelist, groupsubsetrowarray, unadjustedgroupsubsetrowarray];
return AllArrays;
}
//////Construct Single Array with Group-Subset Pairs and Row Arrays/////
function createmergedgroupsubsetpairnamesandrowsarray(groupsubsetuniquelist, groupsubsetrowarray) {
var mergedgroupsubsetpairnamesandrows = [];
var count = 0;
while (count < groupsubsetuniquelist.length)
{
var tempgroupsubsetpair = groupsubsetuniquelist[count];
var tempgroupsubsetpairrowsarray = groupsubsetrowarray[count];
mergedgroupsubsetpairnamesandrows.push([tempgroupsubsetpair,tempgroupsubsetpairrowsarray]);
count++;
}
return mergedgroupsubsetpairnamesandrows;
}
////////Construct Single Array with Cohort-Group Pairs and Row Arrays//////
function createmergedcohortgrouppairsandrowsarray(cancertypetreatpairrowsarray, mergedgroupsubsetpairnamesandrows) {
var cohortgrouppairsandrows = [];
var count = 0;
while (count < cancertypetreatpairrowsarray.length)
{
var tempcohortname = cancertypetreatpairrowsarray[count][0];
var tempcohortrows = cancertypetreatpairrowsarray[count][2];
var count2 = 0;
while (count2 < mergedgroupsubsetpairnamesandrows.length)
{
var tempgroupname = mergedgroupsubsetpairnamesandrows[count2][0];
var tempgrouprows = mergedgroupsubsetpairnamesandrows[count2][1];
var tempmergedrows = [];
var count3 = 0;
while (count3 < tempcohortrows.length)
{
var rowtocheck = tempcohortrows[count3];
var uniquechecker = tempgrouprows.indexOf(rowtocheck);
if (uniquechecker > -1)
{
tempmergedrows.push(rowtocheck);
}
count3++;
}
if (tempmergedrows.length > 4)
{
cohortgrouppairsandrows.push([tempcohortname,tempgroupname,tempmergedrows]);
}
count2++;
}
count++;
}
return cohortgrouppairsandrows;
}
/////Create Simple Treatment Colors List for Outcomes Array/////
/////Create Simple Treatment Colors List for Outcomes Array/////
function createsimpletreatmentcolorslist(cancertypetreatmentpairlist, treatmentcolorsarray, treatmentlist, cancertypeshapesarrayhtmlcodes, cancertypelist, cancertypecolorsarray) {
var SimpleCohortColorsArray = [];
var count = 0;
while (count < cancertypetreatmentpairlist.length)
{
var selectedpair = cancertypetreatmentpairlist[count];
var positionofspacer = selectedpair.indexOf(" - ");
var selectedcancertype = selectedpair.substring(0,positionofspacer);
var positionofselectedcancertype = cancertypelist.indexOf(selectedcancertype);
if (positionofselectedcancertype < 0)
{
positionofselectedcancertype = cancertypelist.length;
}
var selectedtreatment = selectedpair.substring((positionofspacer + 3),selectedpair.length);
var positionofselectedtreatment = treatmentlist.indexOf(selectedtreatment);
var correspondingcolor = treatmentcolorsarray[positionofselectedtreatment];
var shapeplaceholder = cancertypeshapesarrayhtmlcodes[positionofselectedcancertype];
var cancertypecolor = cancertypecolorsarray[positionofselectedcancertype];
if (selectedcancertype == "Composite")
{
var cancertypecolor = "Black";
}
SimpleCohortColorsArray.push([selectedpair, shapeplaceholder, correspondingcolor, cancertypecolor]);
count++;
}
return SimpleCohortColorsArray;
}
///////Create Master Outcomes Array/////
///////Create Master Outcomes Array/////
///////Create Master Outcomes Array/////
function createMasterOutcomesArray(newbasearray, cancertypeshapesarray, cancertypeshapesarrayhtmlcodes, treatmentcolorsarray, cancertreatpairsselectionformat, timepointposition, timepointlist, patientposition, patientlist, populationlist, populationlistindex, outcomeslist, outcomeslistindex, groupslist, groupslistindex, cancertypeposition, cancertypelist, treatmentposition, treatmentlist, cancertypetreatmentpairlist, timepointparameterpairslist, outcomesarrayheaders) {
var MasterOutcomesArray = [];
var AllRowsArray = [];
MasterOutcomesArray.push(outcomesarrayheaders);
////Loop through unique patient list
var patientcount = 0;
while (patientcount < patientlist.length)
{
var outcomesarraydatarow = [];
var selectedpatient = patientlist[patientcount];
outcomesarraydatarow.push(selectedpatient);
////Loop through Outcomes Array Headers
var headerloopcount = 0;
while (headerloopcount < MasterOutcomesArray[0].length)
{
///Define the Selected Column Header
var selectedheadervalue = MasterOutcomesArray[0][headerloopcount];
var outcomesindexcheck = -1;
var populationindexcheck = -1;
var groupsindexcheck = -1;
var cancertypecheck = -1;
var treatmentcheck = -1;
var cancertreatpaircheck = -1;
var stylecheck1 = -1;
var stylecheck2 = -1;
var comparisontimepointcheck = -1;
var outcomesindexcheck = selectedheadervalue.indexOf("Outcomes");
var populationindexcheck = selectedheadervalue.indexOf(":");
var groupsindexcheck = selectedheadervalue.indexOf("Group -");
var cancertypecheck = selectedheadervalue.indexOf("CancerType");
var treatmentcheck = selectedheadervalue.indexOf("Treatment");
var cancertreatpaircheck = selectedheadervalue.indexOf("CancerTreatPair");
var stylecheck1 = selectedheadervalue.indexOf("Style1");
var stylecheck2 = selectedheadervalue.indexOf("Style2");
var comparisontimepointcheck = selectedheadervalue.indexOf(" vs ");
///Actions For Each Header Type
if (outcomesindexcheck > -1)
{
var selectedoutcome = MasterOutcomesArray[0][headerloopcount];
var selectedoutcomeposition1 = outcomeslist.indexOf(selectedoutcome);
var selectedoutcomeposition2 = outcomeslistindex[selectedoutcomeposition1];
///Loop Through newbasearray to Find Rows With Both Selected Patient and Selected Outcome
var masterloopcount = 0;
var selectedoutcomevalue = null;
while (masterloopcount < newbasearray.length)
{
if (newbasearray[masterloopcount][patientposition] == selectedpatient)
{
var selectedoutcomevalue = newbasearray[masterloopcount][selectedoutcomeposition2];
var placeholderoutcomesposition = masterloopcount;
var masterloopcount = 999999999999999999;
}
masterloopcount++;
}
if (selectedoutcomevalue == "null" || selectedoutcomevalue == null || selectedoutcomevalue == "" || selectedoutcomevalue == "NULL")
{
if (selectedoutcomevalue !== 0)
{
var selectedoutcomevalue = null;
}
else {selectedoutcomevalue = 0;}
}
else
{
var selectedoutcomevalue = Number(selectedoutcomevalue);
}
outcomesarraydatarow.push(selectedoutcomevalue);
}
if (groupsindexcheck > -1)
{
var selectedgroup = MasterOutcomesArray[0][headerloopcount];
var selectedgroupposition1 = groupslist.indexOf(selectedgroup);
var selectedgroupposition2 = groupslistindex[selectedgroupposition1];
var masterloopcount = 0;
var selectedgroupvalue = null;
while (masterloopcount < newbasearray.length)
{
if (newbasearray[masterloopcount][patientposition] == selectedpatient)
{
var selectedgroupvalue = newbasearray[masterloopcount][selectedgroupposition2];
var masterloopcount = 999999999999999999;
}
masterloopcount++;
}
if (selectedgroupvalue == "null" || selectedgroupvalue == null || selectedgroupvalue == "" || selectedgroupvalue == "NULL")
{
if (selectedgroupvalue !== 0)
{
var selectedgroupvalue = "Undefined";
}
}
var selectedgroupvaluetype = typeof selectedgroupvalue;
if (selectedgroupvaluetype == "number")
{
var selectedgroupvalue = selectedgroupvalue.toString();
}
outcomesarraydatarow.push(selectedgroupvalue);
}
///Single Timepoint Values
if (populationindexcheck > -1 && comparisontimepointcheck == -1)
{
var selectedvaluepair = outcomesarrayheaders[headerloopcount];
var colonposition = selectedvaluepair.indexOf(":");
var selectedtimepoint1 = selectedvaluepair.substring(0, colonposition);
var selectedpopulation1 = selectedvaluepair.substring((colonposition + 2), selectedvaluepair.length);
var selectedpopulationposition1 = populationlist.indexOf(selectedpopulation1);
var selectedpopulationposition2 = populationlistindex[selectedpopulationposition1];
var masterloopcount = 0;
var selectedpopulationvalue = null;
while (masterloopcount < newbasearray.length)
{
if (newbasearray[masterloopcount][patientposition] == selectedpatient && newbasearray[masterloopcount][timepointposition] == selectedtimepoint1)
{
var selectedpopulationvalue = newbasearray[masterloopcount][selectedpopulationposition2];
var placeholderpopulationposition = masterloopcount;
var masterloopcount = 999999999999999999;
}
masterloopcount++;
}
if (selectedpopulationvalue == "null" || selectedpopulationvalue == null || selectedpopulationvalue == "" || selectedpopulationvalue == "NULL")
{
if (selectedpopulationvalue !== 0)
{
var selectedpopulationvalue = null;
}
else {selectedpopulationvalue = 0;}
}
else
{
var selectedpopulationvalue = Number(selectedpopulationvalue);
}
outcomesarraydatarow.push(selectedpopulationvalue);
}
/////////Comparative Timepoint Values
if (populationindexcheck > -1 && comparisontimepointcheck > -1)
{
var selectedvaluepair = outcomesarrayheaders[headerloopcount];
var colonposition = selectedvaluepair.indexOf(":");
var selectedtimepoint1 = selectedvaluepair.substring(0, colonposition);
var vsposition = comparisontimepointcheck;
var firsttimepoint = selectedtimepoint1.substring(0, vsposition);
var secondtimepoint = selectedtimepoint1.substring((vsposition + 4), selectedtimepoint1.length);
var selectedpopulation1 = selectedvaluepair.substring((colonposition + 2), selectedvaluepair.length);
var selectedpopulationposition1 = populationlist.indexOf(selectedpopulation1);
var selectedpopulationposition2 = populationlistindex[selectedpopulationposition1];
////Define Reference (Baseline) Parameter Value
var masterloopcount = 0;
var selectedpopulationvalueREFERENCE = null;
while (masterloopcount < newbasearray.length)
{
if (newbasearray[masterloopcount][patientposition] == selectedpatient && newbasearray[masterloopcount][timepointposition] == secondtimepoint)
{
var selectedpopulationvalueREFERENCE = newbasearray[masterloopcount][selectedpopulationposition2];
var placeholderpopulationpositionREFERENCE = masterloopcount;
var masterloopcount = 999999999999999999;
}
masterloopcount++;
}
if (selectedpopulationvalueREFERENCE == "null" || selectedpopulationvalueREFERENCE == null || selectedpopulationvalueREFERENCE == "" || selectedpopulationvalueREFERENCE == "NULL")
{
if (selectedpopulationvalueREFERENCE !== 0)
{
var selectedpopulationvalueREFERENCE = null;
}
else {selectedpopulationvalueREFERENCE = 0;}
}
else
{
var selectedpopulationvalueREFERENCE = Number(selectedpopulationvalueREFERENCE);
}
////Define Target (Experimental) Parameter Value
var masterloopcount = 0;
var selectedpopulationvalueTARGET = null;
while (masterloopcount < newbasearray.length)
{
if (newbasearray[masterloopcount][patientposition] == selectedpatient && newbasearray[masterloopcount][timepointposition] == firsttimepoint)
{
var selectedpopulationvalueTARGET = newbasearray[masterloopcount][selectedpopulationposition2];
var placeholderpopulationpositionTARGET = masterloopcount;
var masterloopcount = 999999999999999999;
}
masterloopcount++;
}
if (selectedpopulationvalueTARGET == "null" || selectedpopulationvalueTARGET == null || selectedpopulationvalueTARGET == "" || selectedpopulationvalueTARGET == "NULL")
{
if (selectedpopulationvalueTARGET !== 0)
{
var selectedpopulationvalueTARGET = null;
}
else {selectedpopulationvalueTARGET = 0;}
}
else
{
var selectedpopulationvalueTARGET = Number(selectedpopulationvalueTARGET);
}
if (selectedpopulationvalueTARGET > -999999999 && selectedpopulationvalueTARGET !== null && selectedpopulationvalueREFERENCE > -99999999 && selectedpopulationvalueREFERENCE !== null)
{
var selectedpopulationvalueRESOLVED = selectedpopulationvalueTARGET - selectedpopulationvalueREFERENCE;
}
else
{
var selectedpopulationvalueRESOLVED = null;
}
outcomesarraydatarow.push(selectedpopulationvalueRESOLVED);
}
////Process Cancer Type
if (cancertypecheck > -1)
{
var masterloopcount = 0;
var selectedpopulationvalue = null;
while (masterloopcount < newbasearray.length)
{
if (newbasearray[masterloopcount][patientposition] == selectedpatient)
{
var selectedpopulationvalue = newbasearray[masterloopcount][cancertypeposition];
var masterloopcount = 999999999999999999;
}
masterloopcount++;
}
if (selectedpopulationvalue == "null" || selectedpopulationvalue == null || selectedpopulationvalue == "" || selectedpopulationvalue == "NULL")
{
if (selectedpopulationvalue !== 0)
{
var selectedpopulationvalue = "Undefined";
}
}
var selectedpopulationvaluetype = typeof selectedpopulationvalue;
if (selectedpopulationvaluetype !== "string")
{
var selectedpopulationvalue = selectedpopulationvalue.toString();
}
outcomesarraydatarow.push(selectedpopulationvalue);
}
///Process Treatment Type
if (treatmentcheck > -1)
{
var masterloopcount = 0;
var selectedpopulationvalue = null;
while (masterloopcount < newbasearray.length)
{
if (newbasearray[masterloopcount][patientposition] == selectedpatient)
{
var selectedpopulationvalue = newbasearray[masterloopcount][treatmentposition];
var masterloopcount = 999999999999999999;
}
masterloopcount++;
}
if (selectedpopulationvalue == "null" || selectedpopulationvalue == null || selectedpopulationvalue == "" || selectedpopulationvalue == "NULL")
{
if (selectedpopulationvalue !== 0)
{
var selectedpopulationvalue = "Undefined";
}
}
var selectedpopulationvaluetype = typeof selectedpopulationvalue;
if (selectedpopulationvaluetype !== "string")
{
var selectedpopulationvalue = selectedpopulationvalue.toString();
}
outcomesarraydatarow.push(selectedpopulationvalue);
}
if (cancertreatpaircheck > -1)
{
var cancertreatpairposition = headerloopcount;
var masterloopcount = 0;
var selectedpopulationvalue = null;
while (masterloopcount < newbasearray.length)
{
if (newbasearray[masterloopcount][patientposition] == selectedpatient)
{
var selectedpopulationvalue1 = newbasearray[masterloopcount][cancertypeposition];
if (selectedpopulationvalue1 == "null" || selectedpopulationvalue1 == null || selectedpopulationvalue1 == "" || selectedpopulationvalue1 == "NULL")
{
if (selectedpopulationvalue1 !== 0)
{
var selectedpopulationvalue1 = "Undefined";
}
}
var selectedpopulationvalue1type = typeof selectedpopulationvalue1;
if (selectedpopulationvalue1type !== "string")
{
var selectedpopulationvalue1 = selectedpopulationvalue1.toString();
}
var selectedpopulationvalue2 = newbasearray[masterloopcount][treatmentposition];
if (selectedpopulationvalue2 == "null" || selectedpopulationvalue2 == null || selectedpopulationvalue2 == "" || selectedpopulationvalue2 == "NULL")
{
if (selectedpopulationvalue2 !== 0)
{
var selectedpopulationvalue2 = "Undefined";
}
}
var selectedpopulationvalue2type = typeof selectedpopulationvalue2;
if (selectedpopulationvalue2type !== "string")
{
var selectedpopulationvalue2 = selectedpopulationvalue2.toString();
}
var mergedcancertypetreatmentpair = selectedpopulationvalue1 + " - " + selectedpopulationvalue2;
var masterloopcount = 999999999999999999;
}
masterloopcount++;
}
outcomesarraydatarow.push(mergedcancertypetreatmentpair);
}
if (stylecheck1 > -1)
{
var styleposition1 = headerloopcount;
var masterloopcount = 0;
var colorstyleinsert = null;
while (masterloopcount < newbasearray.length)
{
if (newbasearray[masterloopcount][patientposition] == selectedpatient)
{
var cancertypevalue = newbasearray[masterloopcount][cancertypeposition];
var cancertypeshapeposition = cancertypelist.indexOf(cancertypevalue);
var selectedshape = cancertypeshapesarray[cancertypeshapeposition];
var treatmentvalue = newbasearray[masterloopcount][treatmentposition];
var treatmentcolorposition = treatmentlist.indexOf(treatmentvalue);
var selectedcolor = treatmentcolorsarray[treatmentcolorposition];
var colorstyleinsert = 'point { size: 14; shape-type: ' + selectedshape + '; stroke-color: ' + selectedcolor + '; stroke-width: 3 }';
//////Creating Array for Symbol and Color Identification in Selection Menus
var mergedpairidentifier = cancertypevalue + " - " + treatmentvalue;
var selectedshapehtmlcode = cancertypeshapesarrayhtmlcodes[cancertypeshapeposition];
var singleformatarray = [mergedpairidentifier,selectedshapehtmlcode,selectedcolor];
var countX = 0;
var checkerX = 0;
while (countX < cancertreatpairsselectionformat.length)
{
if (cancertreatpairsselectionformat[countX][0] == singleformatarray[0])
{
var checkerX = 9999999;
var countX = 9999999;
}
countX++;
}
if (checkerX < 1)
{
cancertreatpairsselectionformat.push(singleformatarray);
}
var masterloopcount = 999999999999999999;
}
masterloopcount++;
}
outcomesarraydatarow.push(colorstyleinsert);
}
if (stylecheck2 > -1)
{
var styleposition2 = headerloopcount;
var masterloopcount = 0;
var colorstyleinsert = null;
while (masterloopcount < newbasearray.length)
{
if (newbasearray[masterloopcount][patientposition] == selectedpatient)
{
var cancertypevalue = newbasearray[masterloopcount][cancertypeposition];
var cancertypeshapeposition = cancertypelist.indexOf(cancertypevalue);
var selectedshape = cancertypeshapesarray[cancertypeshapeposition];
var treatmentvalue = newbasearray[masterloopcount][treatmentposition];
var treatmentcolorposition = treatmentlist.indexOf(treatmentvalue);
var selectedcolor = treatmentcolorsarray[treatmentcolorposition];
var colorstyleinsert = 'point { size: 9; shape-type: ' + selectedshape + '; stroke-color: ' + selectedcolor + '; stroke-width: 2';
//////Creating Array for Symbol and Color Identification in Selection Menus
var mergedpairidentifier = cancertypevalue + " - " + treatmentvalue;
var selectedshapehtmlcode = cancertypeshapesarrayhtmlcodes[cancertypeshapeposition];
var singleformatarray = [mergedpairidentifier,selectedshapehtmlcode,selectedcolor];
var countX = 0;
var checkerX = 0;
while (countX < cancertreatpairsselectionformat.length)
{
if (cancertreatpairsselectionformat[countX][0] == singleformatarray[0])
{
var checkerX = 999999;
var countX = 999999;
}
countX++;
}
if (checkerX < 1)
{
cancertreatpairsselectionformat.push(singleformatarray);
}
var masterloopcount = 999999999999999999;
}
masterloopcount++;
}
outcomesarraydatarow.push(colorstyleinsert);
}
headerloopcount++;
}
MasterOutcomesArray.push(outcomesarraydatarow);
AllRowsArray.push(patientcount);
patientcount++;
}
var AllArrays = [MasterOutcomesArray, AllRowsArray, cancertreatpairsselectionformat];
return AllArrays;
}
////Function to Construct Master Treatment-Cohort Array for COLUMN CHART/////////////////////
////Function to Construct Master Treatment-Cohort Array for COLUMN CHART/////////////////////
////Function to Construct Master Treatment-Cohort Array for COLUMN CHART/////////////////////
function createmastertreatmentcohortarray(newbasearray, MasterTreatmentCohortArrayHeaders, timepointlist, timepointposition, patientposition, treatmentlist, treatmentposition, groupsparentchildlist, populationlist, populationlistindex, outcomeslist, outcomeslistindex, groupslist, groupslistindex, cancertypeposition, NEWCancerTypeTreatmentShapeColorFormats) {
var MasterTreatmentCohortArray = [];
var MasterTreatmentCohortArrayGOOGLE = [];
MasterTreatmentCohortArray.push(MasterTreatmentCohortArrayHeaders);
MasterTreatmentCohortArrayGOOGLE.push(MasterTreatmentCohortArrayHeaders);
var MasterTreatmentCohortArrayInsertRow = [];
var MasterTreatmentCohortArrayInsertRowGOOGLE = [];
var count = 0;
while (count < timepointlist.length)
{
temptimepoint = timepointlist[count];
////Temporary Suspension of Treatment Sublist
var countx = -1;
while (countx < 0)
{
if (countx < 0)
{
var temptreatment = "ALL";
}
else
{
var temptreatment = treatmentlist[countx];
}
var count2 = -1;
while (count2 < groupsparentchildlist.length)
{
if (count2 < 0)
{
var tempgroup = "ALL";
var tempgroupselector = "-";
}
else
{
var tempgroup = groupsparentchildlist[count2];
var tempcolonposition = tempgroup.indexOf(":");
var tempgroupselector = tempgroup.substring(0, tempcolonposition);
var tempgroupchild = tempgroup.substring((tempcolonposition + 2), tempgroup.length);
var selectedgroupindex = groupslist.indexOf(tempgroupselector);
var selectedgroupposition = groupslistindex[selectedgroupindex];
}
var count3 = 0;
var MasterTreatmentCohortArrayInsertRow = [];
var MasterTreatmentCohortArrayInsertRowGOOGLE = [];
while (count3 < MasterTreatmentCohortArrayHeaders.length)
{
//alert(MasterTreatmentCohortArrayHeaders);
var selectedheader = MasterTreatmentCohortArrayHeaders[count3];
if (selectedheader == "Treatment")
{
var temptreatment2 = String(temptreatment);
MasterTreatmentCohortArrayInsertRow.push(temptreatment2);
MasterTreatmentCohortArrayInsertRowGOOGLE.push(temptreatment2);
}
if (selectedheader == "Group Subset")
{
var tempgroup2 = String(tempgroup);
MasterTreatmentCohortArrayInsertRow.push(tempgroup2);
MasterTreatmentCohortArrayInsertRowGOOGLE.push(tempgroup2);
}
//////Create Timepoint SubHeaders//////
if (selectedheader == "Timepoint")
{
var temptimepoint2 = String(temptimepoint);
MasterTreatmentCohortArrayInsertRow.push(temptimepoint2);
if (tempgroup !== "ALL" && temptreatment == "ALL")
{
var temptimepoint3 = "Day " + temptimepoint2 + " {" + tempgroup + "}";
}
if (tempgroup == "ALL" && temptreatment == "ALL")
{
var temptimepoint3 = "Day " + temptimepoint2 + " {Total}";
//alert(temptimepoint3);
}
MasterTreatmentCohortArrayInsertRowGOOGLE.push(temptimepoint3);
}
var headerparametercheck = selectedheader.indexOf(":");
if (headerparametercheck > -1)
{
//alert(selectedheader);
var firstcolonposition = selectedheader.indexOf(":");
var selectedcohort = selectedheader.substring(0, firstcolonposition);
var dashposition = selectedcohort.indexOf(" - ");
var selectedcancertypevalue = selectedcohort.substring(0, dashposition);
var selectedtreatmentvalue = selectedcohort.substring((dashposition + 3), selectedcohort.length);
var selectedpopulation = selectedheader.substring((firstcolonposition + 2), selectedheader.length);
var temppopulationindex = populationlist.indexOf(selectedpopulation);
if (temppopulationindex < 0)
{
var temppopulationindex = outcomeslist.indexOf(selectedpopulation);
var temppopulationposition = outcomeslistindex[temppopulationindex];
if (temppopulationposition < 0)
{
alert("Can not locate this population: " + selectedpopulation);
}
}
else
{
var temppopulationposition = populationlistindex[temppopulationindex];
}
//alert(temppopulationindex);
//alert(temppopulationposition);
var headervalueinnewbasearray = newbasearray[0][temppopulationposition];
//alert(headervalueinnewbasearray);
///Check for Comparison Timepoint///
var istimepointcomparison = false;
var comparisoncheck = temptimepoint2.indexOf(" vs ");
//alert(temptimepoint2);
if (comparisoncheck > 0)
{
var experimentaltimepoint = temptimepoint2.substring(0, comparisoncheck);
var referencetimepoint = temptimepoint2.substring((comparisoncheck + 4), comparisoncheck.length);
var istimepointcomparison = true;
}
var tempvaluescollection = [];
if (istimepointcomparison == false)
{
var tempvaluescollection = [];
var count4 = 1;
while (count4 < newbasearray.length)
{
var checktimepoint = newbasearray[count4][timepointposition];
var checktimepoint = String(checktimepoint);
var checktreatment = newbasearray[count4][treatmentposition];
var checkcancertype = newbasearray[count4][cancertypeposition];
if (tempgroup !== "ALL")
{
var checkgroup = newbasearray[count4][selectedgroupposition];
}
if (tempgroup == "ALL" && temptreatment !== "ALL")
{
if (checktimepoint == temptimepoint2 && checktreatment == temptreatment && (checkcancertype == selectedcancertypevalue || selectedcancertypevalue == "Composite") && selectedtreatmentvalue == checktreatment)
{
var tempparametervalue = newbasearray[count4][temppopulationposition];
if (tempparametervalue !== null && tempparametervalue !== "NULL" && tempparametervalue.length > 0)
{
var tempparametervalue = Number(tempparametervalue);
if (isNaN(tempparametervalue) == false)
{
tempvaluescollection.push(tempparametervalue);
}
}
}
}
if (tempgroup !== "ALL" && temptreatment == "ALL")
{
if (checktimepoint == temptimepoint2 && checkgroup == tempgroupchild && (checkcancertype == selectedcancertypevalue || selectedcancertypevalue == "Composite") && selectedtreatmentvalue == checktreatment)
{
var tempparametervalue = newbasearray[count4][temppopulationposition];
if (tempparametervalue !== null && tempparametervalue !== "NULL" && tempparametervalue.length > 0)
{
var tempparametervalue = Number(tempparametervalue);
if (isNaN(tempparametervalue) == false)
{
tempvaluescollection.push(tempparametervalue);
}
}
}
}
if (tempgroup !== "ALL" && temptreatment !== "ALL")
{
if (checktimepoint == temptimepoint2 && checktreatment == temptreatment && (checkcancertype == selectedcancertypevalue || selectedcancertypevalue == "Composite") && checkgroup == tempgroupchild && selectedtreatmentvalue == checktreatment)
{
var tempparametervalue = newbasearray[count4][temppopulationposition];
//alert("Parameter: " + selectedpopulation + "Parameter Value: " + tempparametervalue + " Timepoint: " + temptimepoint + " Cancer Type: " + selectedcancertypevalue + " Group: " + tempgroup + " Treatment: " + temptreatment + " Values: " + tempvaluescollection);
if (tempparametervalue !== null && tempparametervalue !== "NULL" && tempparametervalue.length > 0)
{
var tempparametervalue = Number(tempparametervalue);
if (isNaN(tempparametervalue) == false)
{
tempvaluescollection.push(tempparametervalue);
}
}
}
}
if (tempgroup == "ALL" && temptreatment == "ALL")
{
if (checktimepoint == temptimepoint2 && (checkcancertype == selectedcancertypevalue || selectedcancertypevalue == "Composite") && selectedtreatmentvalue == checktreatment)
{
var tempparametervalue = newbasearray[count4][temppopulationposition];
if (tempparametervalue !== null && tempparametervalue !== "NULL" && tempparametervalue.length > 0)
{
var tempparametervalue = Number(tempparametervalue);
if (isNaN(tempparametervalue) == false)
{
tempvaluescollection.push(tempparametervalue);
}
}
}
}
count4++;
}
}
if (istimepointcomparison == true)
{
var tempvaluescollection = [];
if (tempgroup == "ALL" && temptreatment !== "ALL")
{
//alert('tempgroup == "ALL" && temptreatment !== "ALL"');
var count6 = 0;
while (count6 < newbasearray.length)
{
var checktimepoint = newbasearray[count6][timepointposition];
var checktimepoint = String(checktimepoint);
var checkpatientID = newbasearray[count6][patientposition];
var checktreatment = newbasearray[count6][treatmentposition];
var checkcancertype = newbasearray[count6][cancertypeposition];
if (tempgroup !== "ALL")
{
var checkgroup = newbasearray[count6][selectedgroupposition];
}
if (checktimepoint == referencetimepoint && checktreatment == temptreatment && (checkcancertype == selectedcancertypevalue || selectedcancertypevalue == "Composite") && selectedtreatmentvalue == checktreatment)
{
var tempparametervalueREFERENCE = newbasearray[count6][temppopulationposition];
if (tempparametervalueREFERENCE !== null && tempparametervalueREFERENCE !== "NULL" && tempparametervalueREFERENCE.length > 0)
{
var count7 = 0;
while (count7 < newbasearray.length)
{
var checktimepoint2 = newbasearray[count7][timepointposition];
var checktimepoint2 = String(checktimepoint2);
var checkpatientID2 = newbasearray[count7][patientposition];
var checktreatment2 = newbasearray[count7][treatmentposition];
var checkcancertype2 = newbasearray[count7][cancertypeposition];
if (tempgroup !== "ALL")
{
var checkgroup2 = newbasearray[count7][selectedgroupposition];
}
if (checkpatientID == checkpatientID2 && checktimepoint2 == experimentaltimepoint && checktreatment2 == temptreatment && (checkcancertype2 == selectedcancertypevalue || selectedcancertypevalue == "Composite") && selectedtreatmentvalue == checktreatment2)
{
var tempparametervalueEXPERIMENTAL = newbasearray[count7][temppopulationposition];
if (tempparametervalueEXPERIMENTAL !== null && tempparametervalueEXPERIMENTAL !== "NULL" && tempparametervalueEXPERIMENTAL.length > 0)
{
var tempparametervalueREFERENCE = Number(tempparametervalueREFERENCE);
var tempparametervalueEXPERIMENTAL = Number(tempparametervalueEXPERIMENTAL);
var tempparametervalueDIFFERENTIAL = tempparametervalueEXPERIMENTAL - tempparametervalueREFERENCE;
var tempparametervalueDIFFERENTIAL = Math.round(tempparametervalueDIFFERENTIAL * 100);
var tempparametervalueDIFFERENTIAL = tempparametervalueDIFFERENTIAL / 100;
if (isNaN(tempparametervalueDIFFERENTIAL) == false)
{
tempvaluescollection.push(tempparametervalueDIFFERENTIAL);
}
}
}
count7++;
}
}
}
count6++;
}
}
if (tempgroup !== "ALL" && temptreatment == "ALL")
{
//alert('tempgroup !== "ALL" && temptreatment == "ALL"');
var count6 = 0;
while (count6 < newbasearray.length)
{
var checktimepoint = newbasearray[count6][timepointposition];
var checktimepoint = String(checktimepoint);
var checkpatientID = newbasearray[count6][patientposition];
var checktreatment = newbasearray[count6][treatmentposition];
var checkcancertype = newbasearray[count6][cancertypeposition];
if (tempgroup !== "ALL")
{
var checkgroup = newbasearray[0][selectedgroupposition] + ": " + newbasearray[count6][selectedgroupposition];
}
if (checktimepoint == referencetimepoint && checkgroup == tempgroup && (checkcancertype == selectedcancertypevalue || selectedcancertypevalue == "Composite") && selectedtreatmentvalue == checktreatment)
{
var tempparametervalueREFERENCE = newbasearray[count6][temppopulationposition];
if (tempparametervalueREFERENCE !== null && tempparametervalueREFERENCE !== "NULL" && tempparametervalueREFERENCE.length > 0)
{
var count7 = 0;
while (count7 < newbasearray.length)
{
var checktimepoint2 = newbasearray[count7][timepointposition];
var checktimepoint2 = String(checktimepoint2);
var checkpatientID2 = newbasearray[count7][patientposition];
var checktreatment2 = newbasearray[count7][treatmentposition];
var checkcancertype2 = newbasearray[count7][cancertypeposition];
if (tempgroup !== "ALL")
{
var checkgroup2 = newbasearray[0][selectedgroupposition] + ": " + newbasearray[count7][selectedgroupposition];
}
if (checktimepoint2 == experimentaltimepoint && checkgroup2 == tempgroup && (checkcancertype2 == selectedcancertypevalue || selectedcancertypevalue == "Composite") && selectedtreatmentvalue == checktreatment2)
{
var tempparametervalueEXPERIMENTAL = newbasearray[count7][temppopulationposition];
if (tempparametervalueEXPERIMENTAL !== null && tempparametervalueEXPERIMENTAL !== "NULL" && tempparametervalueEXPERIMENTAL.length > 0)
{
var tempparametervalueREFERENCE = Number(tempparametervalueREFERENCE);
var tempparametervalueEXPERIMENTAL = Number(tempparametervalueEXPERIMENTAL);
var tempparametervalueDIFFERENTIAL = tempparametervalueEXPERIMENTAL - tempparametervalueREFERENCE;
var tempparametervalueDIFFERENTIAL = Math.round(tempparametervalueDIFFERENTIAL * 100);
var tempparametervalueDIFFERENTIAL = tempparametervalueDIFFERENTIAL / 100;
if (isNaN(tempparametervalueDIFFERENTIAL) == false)
{
tempvaluescollection.push(tempparametervalueDIFFERENTIAL);
}
}
}
count7++;
}
}
}
count6++;
}
}
if (tempgroup !== "ALL" && temptreatment !== "ALL")
{
//alert('tempgroup !== "ALL" && temptreatment !== "ALL"');
var count6 = 0;
while (count6 < newbasearray.length)
{
var checktimepoint = newbasearray[count6][timepointposition];
var checktimepoint = String(checktimepoint);
var checkpatientID = newbasearray[count6][patientposition];
var checktreatment = newbasearray[count6][treatmentposition];
var checkcancertype = newbasearray[count6][cancertypeposition];
if (tempgroup !== "ALL")
{
var checkgroup = newbasearray[count6][selectedgroupposition];
}
if (checktimepoint == referencetimepoint && checktreatment == temptreatment && (checkcancertype == selectedcancertypevalue || selectedcancertypevalue == "Composite") && checkgroup == tempgroup && selectedtreatmentvalue == checktreatment)
{
var tempparametervalueREFERENCE = newbasearray[count6][temppopulationposition];
if (tempparametervalueREFERENCE !== null && tempparametervalueREFERENCE !== "NULL" && tempparametervalueREFERENCE.length > 0)
{
var count7 = 0;
while (count7 < newbasearray.length)
{
var checktimepoint2 = newbasearray[count7][timepointposition];
var checktimepoint2 = String(checktimepoint2);
var checkpatientID2 = newbasearray[count7][patientposition];
var checktreatment2 = newbasearray[count7][treatmentposition];
var checkcancertype2 = newbasearray[count7][cancertypeposition];
if (tempgroup !== "ALL")
{
var checkgroup2 = newbasearray[count7][selectedgroupposition];
}
if (checkpatientID == checkpatientID2 && checktimepoint2 == experimentaltimepoint && checktreatment2 == temptreatment && (checkcancertype2 == selectedcancertypevalue || selectedcancertypevalue == "Composite") && checkgroup2 == tempgroup && selectedtreatmentvalue == checktreatment2)
{
var tempparametervalueEXPERIMENTAL = newbasearray[count7][temppopulationposition];
if (tempparametervalueEXPERIMENTAL !== null && tempparametervalueEXPERIMENTAL !== "NULL" && tempparametervalueEXPERIMENTAL.length > 0)
{
var tempparametervalueREFERENCE = Number(tempparametervalueREFERENCE);
var tempparametervalueEXPERIMENTAL = Number(tempparametervalueEXPERIMENTAL);
var tempparametervalueDIFFERENTIAL = tempparametervalueEXPERIMENTAL - tempparametervalueREFERENCE;
var tempparametervalueDIFFERENTIAL = Math.round(tempparametervalueDIFFERENTIAL * 100);
var tempparametervalueDIFFERENTIAL = tempparametervalueDIFFERENTIAL / 100;
if (isNaN(tempparametervalueDIFFERENTIAL) == false)
{
tempvaluescollection.push(tempparametervalueDIFFERENTIAL);
}
}
}
count7++;
}
}
}
count6++;
}
}
if (tempgroup == "ALL" && temptreatment == "ALL")
{
var count6 = 0;
while (count6 < newbasearray.length)
{
var checktimepoint = newbasearray[count6][timepointposition];
var checkpatientID = newbasearray[count6][patientposition];
var checktimepoint = String(checktimepoint);
var checktreatment = newbasearray[count6][treatmentposition];
var checkcancertype = newbasearray[count6][cancertypeposition];
if (tempgroup !== "ALL")
{
var checkgroup = newbasearray[count6][selectedgroupposition];
}
if (checktimepoint == referencetimepoint && (checkcancertype == selectedcancertypevalue || selectedcancertypevalue == "Composite") && selectedtreatmentvalue == checktreatment)
{
var tempparametervalueREFERENCE = newbasearray[count6][temppopulationposition];
if (tempparametervalueREFERENCE !== null && tempparametervalueREFERENCE !== "NULL" && tempparametervalueREFERENCE.length > 0)
{
var count7 = 0;
while (count7 < newbasearray.length)
{
var checktimepoint2 = newbasearray[count7][timepointposition];
var checktimepoint2 = String(checktimepoint2);
var checkpatientID2 = newbasearray[count7][patientposition];
var checktreatment2 = newbasearray[count7][treatmentposition];
var checkcancertype2 = newbasearray[count7][cancertypeposition];
if (tempgroup !== "ALL")
{
var checkgroup2 = newbasearray[count7][selectedgroupposition];
}
if (checkpatientID == checkpatientID2 && checktimepoint2 == experimentaltimepoint && (checkcancertype2 == selectedcancertypevalue || selectedcancertypevalue == "Composite") && selectedtreatmentvalue == checktreatment2)
{
var tempparametervalueEXPERIMENTAL = newbasearray[count7][temppopulationposition];
if (tempparametervalueEXPERIMENTAL !== null && tempparametervalueEXPERIMENTAL !== "NULL" && tempparametervalueEXPERIMENTAL.length > 0)
{
var tempparametervalueREFERENCE = Number(tempparametervalueREFERENCE);
var tempparametervalueEXPERIMENTAL = Number(tempparametervalueEXPERIMENTAL);
var tempparametervalueDIFFERENTIAL = tempparametervalueEXPERIMENTAL - tempparametervalueREFERENCE;
var tempparametervalueDIFFERENTIAL = Math.round(tempparametervalueDIFFERENTIAL * 100);
var tempparametervalueDIFFERENTIAL = tempparametervalueDIFFERENTIAL / 100;
if (isNaN(tempparametervalueDIFFERENTIAL) == false)
{
tempvaluescollection.push(tempparametervalueDIFFERENTIAL);
}
}
}
count7++;
}
}
}
count6++;
}
}
}
var tempmeansandintervals = calculatemeanandintervals(tempvaluescollection);
var InsertMeanValue = tempmeansandintervals[0];
var InsertSTD = tempmeansandintervals[1];
var InsertLowInterval = tempmeansandintervals[2];
var InsertHighInterval = tempmeansandintervals[3];
var InsertAllValues = tempvaluescollection;
var InsertStyle = "";
var selectedtreatmentcolor = "Black";
var selectedcancertypeshape = "";
var colorcount = 0;
while (colorcount < NEWCancerTypeTreatmentShapeColorFormats.length)
{
var cohortselection = NEWCancerTypeTreatmentShapeColorFormats[colorcount][0];
if (cohortselection == selectedcohort)
{
var selectedtreatmentcolor = NEWCancerTypeTreatmentShapeColorFormats[colorcount][2];
var selectedcancertypeshape = NEWCancerTypeTreatmentShapeColorFormats[colorcount][1];
var selectedcancertypecolor = NEWCancerTypeTreatmentShapeColorFormats[colorcount][3];
var colorcount = 9999999999999;
}
colorcount++;
}
//var InsertStyle = "color: gold; opacity: 0.8; stroke-color: " + selectedtreatmentcolor + "; stroke-width: 4";
var InsertStyle = "color: " + selectedcancertypecolor + "; opacity: 0.8; stroke-color: " + selectedtreatmentcolor + "; stroke-width: 4";
var InsertAnnotation = selectedpopulation;
var InsertMoreInfo = selectedcancertypecolor;
MasterTreatmentCohortArrayInsertRow.push(InsertMeanValue, InsertAllValues, InsertLowInterval, InsertHighInterval, InsertStyle, InsertAnnotation, InsertMoreInfo);
MasterTreatmentCohortArrayInsertRowGOOGLE.push(InsertMeanValue, InsertAnnotation, InsertLowInterval, InsertHighInterval, InsertStyle, InsertAnnotation, InsertMoreInfo);
//alert("Parameter: " + selectedpopulation + " Timepoint: " + temptimepoint + " Cancer Type: " + selectedcancertypevalue + " Group: " + tempgroup + " Treatment: " + temptreatment + " Values: " + tempvaluescollection);
}
count3++;
}
/////Add Spacer Column//////
MasterTreatmentCohortArrayInsertRow.push(0, [0], 0, 0, "opacity: 0.1", "", "");
MasterTreatmentCohortArrayInsertRowGOOGLE.push(0, "", 0, 0, "opacity: 0.1", "", "");
MasterTreatmentCohortArray.push(MasterTreatmentCohortArrayInsertRow);
//alert(MasterTreatmentCohortArrayInsertRow);
MasterTreatmentCohortArrayGOOGLE.push(MasterTreatmentCohortArrayInsertRowGOOGLE);
count2++;
}
countx++;
}
count++;
}
var BothMasterArrays = [MasterTreatmentCohortArray, MasterTreatmentCohortArrayGOOGLE];
return BothMasterArrays;
}
////Functions to Define Selections///////////////////////////////////////////////////////////////////////////////////
////Functions to Define Selections///////////////////////////////////////////////////////////////////////////////////
////Functions to Define Selections///////////////////////////////////////////////////////////////////////////////////
////Functions to Define Selections///////////////////////////////////////////////////////////////////////////////////
////Functions to Define Selections///////////////////////////////////////////////////////////////////////////////////
///Determine which outcomes are selected////////
///Determine which outcomes are selected////////
function determineselectedoutcomes(outcomeslist) {
count = 0;
var checkedoutcomes = [];
while (count < outcomeslist.length)
{
var tempvalue1 = outcomeslist[count];
var tempvalue2 = document.getElementById(tempvalue1);
if (tempvalue2.checked){checkedoutcomes.push(tempvalue1);}
count++;
};
if (checkedoutcomes.length < 1) {alert("You have not selected an outcome. You will see the default selection (" + outcomeslist[0] +")");};
return checkedoutcomes;
}
////Determine Selected Timepoints////////////
////Determine Selected Timepoints////////////
function determineselectedtimepoints(timepointlist) {
count = 0;
var checkedtimepoints = [];
while (count < timepointlist.length)
{
var tempvalue1 = timepointlist[count];
var tempvalue2 = document.getElementById(tempvalue1);
if (tempvalue2.checked){checkedtimepoints.push(tempvalue1);}
count++;
var tempvalue3 = document.getElementById('SelectAllTimepoints');
if (tempvalue3.checked)
{
checkedtimepoints = timepointlist;
count = 9999999999999;
}
}
if (checkedtimepoints.length < 1)
{
alert("You must select at least one timepoint. You will see the defualt timepoint (Day " + timepointlist[0] + ")");
checkedtimepoints.push(timepointlist[0]);
}
return checkedtimepoints;
}
////Determine Which Parameters Are Selected for OUTCOMES ANALYSIS///
////Determine Which Parameters Are Selected for OUTCOMES ANALYSIS///
function determineselectedparameters(populationlist) {
count = 0;
var checkedparameters = [];
while (count < populationlist.length)
{
var tempvalue1 = populationlist[count];
var tempvalue2 = document.getElementById(tempvalue1);
if (tempvalue2.checked){checkedparameters.push(tempvalue1);}
count++;
var tempvalue3 = document.getElementById('SelectAllParameters');
if (tempvalue3.checked)
{
checkedparameters = populationlist;
count = 9999999999999;
}
};
if (checkedparameters.length < 1)
{
alert("You must select at least one parameter. You will see the default (" + populationlist[0] + ")");
checkedparameters.push(populationlist[0]);
};
return checkedparameters;
}
////Determine Which Parameters Are Selected for COLUMN CHART///
////Determine Which Parameters Are Selected for COLUMN CHART///
function determineselectedparametersCOLUMN(populationlist, outcomeslist) {
count = 0;
var checkedparameters = [];
while (count < populationlist.length)
{
var tempvalue1 = populationlist[count];
var tempvalue2 = document.getElementById(tempvalue1);
if (tempvalue2.checked){checkedparameters.push(tempvalue1);}
count++;
var tempvalue3 = document.getElementById('SelectAllParameters');
if (tempvalue3.checked)
{
checkedparameters = populationlist;
count = 9999999999999;
}
};
count = 0;
while (count < outcomeslist.length)
{
var tempvalue1 = outcomeslist[count];
var tempvalue2 = document.getElementById(tempvalue1);
if (tempvalue2.checked){checkedparameters.push(tempvalue1);}
count++;
}
if (checkedparameters.length < 1)
{
alert("You must select at least one parameter. You will see the default (" + populationlist[0] + ")");
checkedparameters.push(populationlist[0]);
};
return checkedparameters;
}
////Determine Which Cohorts Are Selected for OUTCOMES CHART/////
////Determine Which Cohorts Are Selected for OUTCOMES CHART/////
function determineselectedcohorts(cancertypetreatpairrowsarray, AllRowsArray) {
count = 0;
var checkedcohorts = [];
while (count < cancertypetreatpairrowsarray.length)
{
var tempvalue1 = cancertypetreatpairrowsarray[count][0];
var tempvalue2 = document.getElementById(tempvalue1);
if (tempvalue2.checked)
{
var subsetrows = cancertypetreatpairrowsarray[count][1];
var countZ = 0;
while (countZ < subsetrows.length)
{
checkedcohorts.push(subsetrows[countZ]);
countZ++;
}
}
count++;
var tempvalue3 = document.getElementById('SelectAllcancertreatpairs');
if (tempvalue3.checked)
{
checkedcohorts = AllRowsArray;
count = 9999999999999;
}
};
if (checkedcohorts.length < 1)
{
alert("You must select at least one cohort. You will now see the default (all cohorts).");
checkedcohorts = AllRowsArray;
};
return checkedcohorts;
}
/////Determine Which Groups Are Selected for OUTCOMES CHART/////
/////Determine Which Groups Are Selected for OUTCOMES CHART/////
function determineselectedgroups(AllGroupSubsetArrays) {
var groupsubsetuniquelist = AllGroupSubsetArrays[0];
var groupsubsetrowarray = AllGroupSubsetArrays[1];
var count = 0;
var checkedgroups = [];
var checkedgroupsnames = [];
var parentgroupnames = [];
var tempvalue3 = document.getElementById('SelectAllGroups');
if (tempvalue3.checked)
{
var count = 0;
while (count < groupsubsetuniquelist.length)
{
var tempvalue1 = groupsubsetuniquelist[count];
var subsetrows = [];
var subsetrows = groupsubsetrowarray[count];
checkedgroups.push(subsetrows);
checkedgroupsnames.push(tempvalue1);
var parentgroupvaluedelimiter = tempvalue1.indexOf(":");
var parentgroupvalue = tempvalue1.substring(0,parentgroupvaluedelimiter);
parentgroupnames.push(parentgroupvalue);
count++;
}
}
else
{
var count = 0;
while (count < groupsubsetuniquelist.length)
{
var tempvalue1 = groupsubsetuniquelist[count];
var tempvalue2 = document.getElementById(tempvalue1);
if (tempvalue2.checked)
{
var subsetrows = [];
var subsetrows = groupsubsetrowarray[count];
checkedgroups.push(subsetrows);
checkedgroupsnames.push(tempvalue1);
var parentgroupvaluedelimiter = tempvalue1.indexOf(":");
var parentgroupvalue = tempvalue1.substring(0,parentgroupvaluedelimiter);
parentgroupnames.push(parentgroupvalue);
}
count++;
}
}
if (checkedgroups.length < 1)
{
alert("You must select at least one groups. You will now see the default (all groups).");
var count = 0;
while (count < groupsubsetuniquelist.length)
{
var tempvalue1 = groupsubsetuniquelist[count];
var subsetrows = [];
var subsetrows = groupsubsetrowarray[count];
checkedgroups.push(subsetrows);
checkedgroupsnames.push(tempvalue1);
var parentgroupvaluedelimiter = tempvalue1.indexOf(":");
var parentgroupvalue = tempvalue1.substring(0,parentgroupvaluedelimiter);
parentgroupnames.push(parentgroupvalue);
count++;
}
}
var groupselectionarrays = [checkedgroups, checkedgroupsnames, parentgroupnames];
return groupselectionarrays;
}