} else {
List<Integer> clusteringResult = result.getClusters();
// Report window
Desktop desktop = MZmineCore.getDesktop();
if (typeOfData == ClusteringDataType.SAMPLES) {
String[] sampleNames = new String[selectedRawDataFiles.length];
for (int i = 0; i < selectedRawDataFiles.length; i++) {
sampleNames[i] = selectedRawDataFiles[i].getName();
}
ClusteringReportWindow reportWindow = new ClusteringReportWindow(
sampleNames,
(Integer[]) clusteringResult.toArray(new Integer[0]),
"Clustering Report");
desktop.addInternalFrame(reportWindow);
} else {
String[] variableNames = new String[selectedRows.length];
for (int i = 0; i < selectedRows.length; i++) {
variableNames[i] = selectedRows[i].getID() + " - "
+ selectedRows[i].getAverageMZ() + " - "
+ selectedRows[i].getAverageRT();
if (selectedRows[i].getPeakIdentities() != null
&& selectedRows[i].getPeakIdentities().length > 0) {
variableNames[i] += " - "
+ selectedRows[i].getPeakIdentities()[0]
.getName();
}
}
ClusteringReportWindow reportWindow = new ClusteringReportWindow(
variableNames,
(Integer[]) clusteringResult.toArray(new Integer[0]),
"Clustering Report");
desktop.addInternalFrame(reportWindow);
}
// Visualization
if (typeOfData == ClusteringDataType.VARIABLES) {
for (int ind = 0; ind < selectedRows.length; ind++) {
groupsForSelectedVariables[ind] = clusteringResult.get(ind);
}
} else {
for (int ind = 0; ind < selectedRawDataFiles.length; ind++) {
groupsForSelectedRawDataFiles[ind] = clusteringResult
.get(ind);
}
}
this.finalNumberOfGroups = result.getNumberOfGroups();
parameterValuesForGroups = new Object[finalNumberOfGroups];
for (int i = 0; i < finalNumberOfGroups; i++) {
parameterValuesForGroups[i] = "Group " + i;
}
int numComponents = xAxisDimension;
if (yAxisDimension > numComponents) {
numComponents = yAxisDimension;
}
if (result.getVisualizationType() == VisualizationType.PCA) {
// Scale data and do PCA
Preprocess.scaleToUnityVariance(rawData);
PCA pcaProj = new PCA(rawData, numComponents);
projectionStatus = pcaProj.getProjectionStatus();
double[][] pcaResult = pcaProj.getState();
if (status == TaskStatus.CANCELED) {
return;
}
component1Coords = pcaResult[xAxisDimension - 1];
component2Coords = pcaResult[yAxisDimension - 1];
} else if (result.getVisualizationType() == VisualizationType.SAMMONS) {
// Scale data and do Sammon's mapping
Preprocess.scaleToUnityVariance(rawData);
Sammons sammonsProj = new Sammons(rawData);
projectionStatus = sammonsProj.getProjectionStatus();
sammonsProj.iterate(100);
double[][] sammonsResult = sammonsProj.getState();
if (status == TaskStatus.CANCELED) {
return;
}
component1Coords = sammonsResult[xAxisDimension - 1];
component2Coords = sammonsResult[yAxisDimension - 1];
}
ProjectionPlotWindow newFrame = new ProjectionPlotWindow(
desktop.getSelectedPeakLists()[0], this, parameters);
desktop.addInternalFrame(newFrame);
}
status = TaskStatus.FINISHED;
logger.info("Finished computing Clustering visualization.");
}