use of jmprojection.CDA in project mzmine2 by mzmine.
the class CDADataset method run.
@Override
public void run() {
status = TaskStatus.PROCESSING;
if (selectedRows.length == 0) {
this.status = TaskStatus.ERROR;
errorMessage = "No peaks selected for CDA plot";
return;
}
if (selectedRawDataFiles.length == 0) {
this.status = TaskStatus.ERROR;
errorMessage = "No raw data files selected for CDA plot";
return;
}
logger.info("Computing projection plot");
// Generate matrix of raw data (input to CDA)
boolean useArea = false;
if (parameters.getParameter(ProjectionPlotParameters.peakMeasurementType).getValue() == PeakMeasurementType.AREA)
useArea = true;
double[][] rawData = new double[selectedRawDataFiles.length][selectedRows.length];
for (int rowIndex = 0; rowIndex < selectedRows.length; rowIndex++) {
PeakListRow peakListRow = selectedRows[rowIndex];
for (int fileIndex = 0; fileIndex < selectedRawDataFiles.length; fileIndex++) {
RawDataFile rawDataFile = selectedRawDataFiles[fileIndex];
Feature p = peakListRow.getPeak(rawDataFile);
if (p != null) {
if (useArea)
rawData[fileIndex][rowIndex] = p.getArea();
else
rawData[fileIndex][rowIndex] = p.getHeight();
}
}
}
int numComponents = xAxisDimension;
if (yAxisDimension > numComponents)
numComponents = yAxisDimension;
// Scale data and do CDA
Preprocess.scaleToUnityVariance(rawData);
CDA cdaProj = new CDA(rawData);
cdaProj.iterate(100);
if (status == TaskStatus.CANCELED)
return;
double[][] result = cdaProj.getState();
if (status == TaskStatus.CANCELED)
return;
component1Coords = result[xAxisDimension - 1];
component2Coords = result[yAxisDimension - 1];
ProjectionPlotWindow newFrame = new ProjectionPlotWindow(peakList, this, parameters);
newFrame.setVisible(true);
status = TaskStatus.FINISHED;
logger.info("Finished computing projection plot.");
}
Aggregations