use of net.sf.mzmine.datamodel.Feature in project mzmine2 by mzmine.
the class SammonsDataset method run.
@Override
public void run() {
setStatus(TaskStatus.PROCESSING);
if (selectedRows.length == 0) {
this.status = TaskStatus.ERROR;
errorMessage = "No peaks selected for Sammons plot";
return;
}
if (selectedRawDataFiles.length == 0) {
this.status = TaskStatus.ERROR;
errorMessage = "No raw data files selected for Sammons plot";
return;
}
logger.info("Computing projection plot");
// Generate matrix of raw data (input to Sammon's projection)
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 Sammon's mapping
Preprocess.scaleToUnityVariance(rawData);
Sammons sammonsProj = new Sammons(rawData);
projectionStatus = sammonsProj.getProjectionStatus();
sammonsProj.iterate(100);
if (status == TaskStatus.CANCELED)
return;
double[][] result = sammonsProj.getState();
if (status == TaskStatus.CANCELED)
return;
component1Coords = result[xAxisDimension - 1];
component2Coords = result[yAxisDimension - 1];
ProjectionPlotWindow newFrame = new ProjectionPlotWindow(peakList, this, parameters);
newFrame.setVisible(true);
setStatus(TaskStatus.FINISHED);
logger.info("Finished computing projection plot.");
}
use of net.sf.mzmine.datamodel.Feature in project mzmine2 by mzmine.
the class PeakLearnerTask method run.
/**
* @see Runnable#run()
*/
@Override
public void run() {
setStatus(TaskStatus.PROCESSING);
logger.info("Running learner task on " + peakList);
// Create a new results peakList which is added at the end
resultPeakList = new SimplePeakList(peakList + " " + suffix, peakList.getRawDataFiles());
/**
* - A PeakList is a list of Features (peak in retention time dimension with accurate m/z)<br>
* ---- contains one or multiple RawDataFiles <br>
* ---- access mean retention time, mean m/z, maximum intensity, ...<br>
* - A RawDataFile holds a full chromatographic run with all ms scans<br>
* ---- Each Scan and the underlying raw data can be accessed <br>
* ---- Scans can be filtered by MS level, polarity, ...<br>
*/
// is the data provided by peaklist enough for this task or
// do you want to work on one raw data file or on all files?
RawDataFile dataFile = peakList.getRawDataFile(0);
// get all peaks of a raw data file
// Sort peaks by ascending mz
Feature[] sortedPeaks = peakList.getPeaks(dataFile);
Arrays.sort(sortedPeaks, new PeakSorter(SortingProperty.MZ, SortingDirection.Ascending));
// Loop through all peaks
totalPeaks = sortedPeaks.length;
for (int i = 0; i < totalPeaks; i++) {
// check for cancelled state and stop
if (isCanceled())
return;
// current peak
Feature aPeak = sortedPeaks[i];
// do stuff
// ...
// add row to result feature list
PeakListRow row = peakList.getPeakRow(aPeak);
row = copyPeakRow(row);
resultPeakList.addRow(row);
// Update completion rate
processedPeaks++;
}
// add to project
addResultToProject();
logger.info("Finished on " + peakList);
setStatus(TaskStatus.FINISHED);
}
use of net.sf.mzmine.datamodel.Feature in project mzmine2 by mzmine.
the class StreamPeakListRowLearnerTask method copyPeakRow.
/**
* Create a copy of a feature list row.
*
* @param row the row to copy.
* @return the newly created copy.
*/
private static PeakListRow copyPeakRow(final PeakListRow row) {
// Copy the feature list row.
final PeakListRow newRow = new SimplePeakListRow(row.getID());
PeakUtils.copyPeakListRowProperties(row, newRow);
// Copy the peaks.
for (final Feature peak : row.getPeaks()) {
final Feature newPeak = new SimpleFeature(peak);
PeakUtils.copyPeakProperties(peak, newPeak);
newRow.addPeak(peak.getDataFile(), newPeak);
}
return newRow;
}
use of net.sf.mzmine.datamodel.Feature in project mzmine2 by mzmine.
the class ManualPeakPickerModule method runManualDetection.
public static ExitCode runManualDetection(RawDataFile[] dataFiles, PeakListRow peakListRow, PeakList peakList, PeakListTable table) {
Range<Double> mzRange = null, rtRange = null;
// Check the peaks for selected data files
for (RawDataFile dataFile : dataFiles) {
Feature peak = peakListRow.getPeak(dataFile);
if (peak == null)
continue;
if ((mzRange == null) || (rtRange == null)) {
mzRange = peak.getRawDataPointsMZRange();
rtRange = peak.getRawDataPointsRTRange();
} else {
mzRange = mzRange.span(peak.getRawDataPointsMZRange());
rtRange = rtRange.span(peak.getRawDataPointsRTRange());
}
}
// If none of the data files had a peak, check the whole row
if (mzRange == null) {
for (Feature peak : peakListRow.getPeaks()) {
if (peak == null)
continue;
if ((mzRange == null) || (rtRange == null)) {
mzRange = peak.getRawDataPointsMZRange();
rtRange = peak.getRawDataPointsRTRange();
} else {
mzRange = mzRange.span(peak.getRawDataPointsMZRange());
rtRange = rtRange.span(peak.getRawDataPointsRTRange());
}
}
}
ManualPickerParameters parameters = new ManualPickerParameters();
if (mzRange != null) {
parameters.getParameter(ManualPickerParameters.retentionTimeRange).setValue(rtRange);
parameters.getParameter(ManualPickerParameters.mzRange).setValue(mzRange);
}
ExitCode exitCode = parameters.showSetupDialog(MZmineCore.getDesktop().getMainWindow(), true);
if (exitCode != ExitCode.OK)
return exitCode;
ManualPickerTask task = new ManualPickerTask(MZmineCore.getProjectManager().getCurrentProject(), peakListRow, dataFiles, parameters, peakList, table);
MZmineCore.getTaskController().addTask(task);
return exitCode;
}
use of net.sf.mzmine.datamodel.Feature in project mzmine2 by mzmine.
the class XICManualPickerModule method runManualDetection.
// public static ExitCode runManualDetection(RawDataFile dataFile, PeakListRow peakListRow,
// PeakList peakList, PeakListTable table) {
// return runManualDetection(new RawDataFile[] {dataFile}, peakListRow, peakList, table);
// }
public static ExitCode runManualDetection(RawDataFile dataFile, PeakListRow peakListRow, PeakList peakList, PeakListTable table) {
Range<Double> mzRange = null, rtRange = null;
mzRange = Range.closed(peakListRow.getAverageMZ(), peakListRow.getAverageMZ());
rtRange = Range.closed(peakListRow.getAverageRT(), peakListRow.getAverageRT());
for (Feature peak : peakListRow.getPeaks()) {
if (peak == null)
continue;
// if the peak exists in the file, then we just use that one as a base
if (peak.getDataFile() == dataFile) {
mzRange = peak.getRawDataPointsMZRange();
rtRange = peak.getRawDataPointsRTRange();
break;
}
// if it does not exist, we set up on basis of the other peaks
if (peak != null) {
mzRange = mzRange.span(peak.getRawDataPointsMZRange());
rtRange = rtRange.span(peak.getRawDataPointsRTRange());
}
}
XICManualPickerParameters parameters = new XICManualPickerParameters();
if (mzRange != null) {
parameters.getParameter(XICManualPickerParameters.rtRange).setValue(rtRange);
parameters.getParameter(XICManualPickerParameters.mzRange).setValue(mzRange);
}
if (dataFile != null) {
RawDataFilesSelection selection = new RawDataFilesSelection();
selection.setSpecificFiles(new RawDataFile[] { dataFile });
selection.setSelectionType(RawDataFilesSelectionType.SPECIFIC_FILES);
parameters.getParameter(XICManualPickerParameters.rawDataFiles).setValue(selection);
}
ExitCode exitCode = parameters.showSetupDialog(MZmineCore.getDesktop().getMainWindow(), true);
if (exitCode != ExitCode.OK)
return exitCode;
ManualPickerParameters param = new ManualPickerParameters();
param.getParameter(ManualPickerParameters.mzRange).setValue(parameters.getParameter(XICManualPickerParameters.mzRange).getValue());
param.getParameter(ManualPickerParameters.retentionTimeRange).setValue(parameters.getParameter(XICManualPickerParameters.rtRange).getValue());
ManualPickerTask task = new ManualPickerTask(MZmineCore.getProjectManager().getCurrentProject(), peakListRow, new RawDataFile[] { dataFile }, param, peakList, table);
MZmineCore.getTaskController().addTask(task);
return exitCode;
}
Aggregations