/usr/share/hyphy/ChartAddIns/K-Mean Clustering is in hyphy-common 2.2.7+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | /*****************************************************************************/
if (NON_EMPTY_SELECTION)
{
UPDATE_CELL_DATE = 0;
data_rows = Columns (SELECTED_CHART_ROWS);
temp = SELECTED_CHART_COLS[0];
for (count = 1; count<data_rows; count = count+1)
{
temp2 = SELECTED_CHART_COLS[count];
if (temp!=temp2)
{
break;
}
if (SELECTED_CHART_DATA[count]<SELECTED_CHART_DATA[count-1])
{
break;
}
}
if (count == data_rows)
{
/* compress the data vector to account for repeated observations */
dataPoints = Columns(SELECTED_CHART_DATA);
temp_data_vector = {2, dataPoints};
currentIndex = 0;
temp_data_vector[0][0] = SELECTED_CHART_DATA[0];
temp_data_vector[1][0] = 1;
for (nextIndex = 1; nextIndex < dataPoints; nextIndex = nextIndex + 1)
{
if (SELECTED_CHART_DATA[nextIndex]!=SELECTED_CHART_DATA[nextIndex-1])
{
currentIndex = currentIndex+1;
temp_data_vector[0][currentIndex] = SELECTED_CHART_DATA[nextIndex];
}
temp_data_vector[1][currentIndex] = temp_data_vector[1][currentIndex] + 1;
}
SELECTED_CHART_DATA = {2, currentIndex+1};
for (nextIndex = 0; nextIndex <= currentIndex; nextIndex = nextIndex + 1)
{
SELECTED_CHART_DATA[0][nextIndex] = temp_data_vector[0][nextIndex];
SELECTED_CHART_DATA[1][nextIndex] = temp_data_vector[1][nextIndex];
}
patternCount = Columns(SELECTED_CHART_DATA);
fprintf (stdout, "\n");
upTo = Max(1,10);
cMeans = {};
errMatrix = {upTo,5};
kIters = 1000;
for (cc = 0; cc < upTo; cc = cc+1)
{
km = Transpose(SELECTED_CHART_DATA) <= {{cc+1}{kIters}};
cMeans[cc+1] = km;
errMatrix[cc][0] = cc+1;
errMatrix[cc][1] = km[1][0];
errMatrix[cc][2] = 1./km[1][0];
if (cc)
{
errMatrix[cc][3] = errMatrix[cc][2]-errMatrix[cc-1][2];
errMatrix[cc][2] = 1./km[1][0];
errMatrix[cc][4] = 100*km[1][1]/kIters;
}
else
{
errMatrix[cc][4] = 100;
}
}
labels = {{"Classes", "Error", "Transformed Error", "Transformed Jumps", "Confidence"}};
promptString = "Clustering Error";
OpenWindow (CHARTWINDOW,{{promptString}
{"labels"},
{"errMatrix"},
{"Line Plot"},
{labels[0]},
{labels[3]},
{"Cluster Count"},
{""},
{"Transformed Error"},
{"0"}},
"SCREEN_WIDTH-60;SCREEN_HEIGHT-50;30;50");
}
else
{
fprintf (stdout, "Please select a single sorted column to fit a profile to.\n");
}
}
else
{
NON_EMPTY_SELECTION = -1;
}
|