use of net.sf.mzmine.util.maths.CenterFunction in project mzmine2 by mzmine.
the class CenterMeasureComponent method getSelectedFunction.
public CenterFunction getSelectedFunction() {
CenterMeasure measure = (CenterMeasure) comboCenterMeasure.getSelectedItem();
Weighting trans = Weighting.NONE;
if (comboTransform != null && comboTransform.isVisible())
trans = (Weighting) comboTransform.getSelectedItem();
return new CenterFunction(measure, trans);
}
use of net.sf.mzmine.util.maths.CenterFunction in project mzmine2 by mzmine.
the class CenterMeasureParameter method loadValueFromXML.
@Override
public void loadValueFromXML(Element xmlElement) {
try {
CenterMeasure measure = CenterMeasure.valueOf(xmlElement.getAttribute("measure"));
Weighting weighting = Weighting.valueOf(xmlElement.getAttribute("weighting"));
value = new CenterFunction(measure, weighting);
} catch (Exception e) {
logger.log(Level.WARNING, "center measure cannot be loaded from xml", e);
}
}
use of net.sf.mzmine.util.maths.CenterFunction in project mzmine2 by mzmine.
the class PeakResolverSetupDialog method parametersChanged.
@Override
public void parametersChanged() {
if (preview != null && preview.isSelected()) {
final PeakListRow previewRow = (PeakListRow) comboPeak.getSelectedItem();
if (previewRow != null) {
LOG.finest("Loading new preview peak " + previewRow);
ticPlot.removeAllTICDataSets();
ticPlot.addTICDataset(new ChromatogramTICDataSet(previewRow.getPeaks()[0]));
// Auto-range to axes.
ticPlot.getXYPlot().getDomainAxis().setAutoRange(true);
ticPlot.getXYPlot().getDomainAxis().setAutoTickUnitSelection(true);
ticPlot.getXYPlot().getRangeAxis().setAutoRange(true);
ticPlot.getXYPlot().getRangeAxis().setAutoTickUnitSelection(true);
updateParameterSetFromComponents();
// If there is some illegal value, do not load the preview but
// just exit.
ArrayList<String> errors = new ArrayList<String>();
if (!parameterSet.checkParameterValues(errors)) {
LOG.fine("Illegal parameter value: " + errors);
return;
}
// Load the intensities and RTs into array.
final Feature previewPeak = previewRow.getPeaks()[0];
// Resolve peaks.
Feature[] resolvedPeaks = {};
RSessionWrapper rSession;
try {
if (peakResolver.getRequiresR()) {
// Check R availability, by trying to open the
// connection.
String[] reqPackages = peakResolver.getRequiredRPackages();
String[] reqPackagesVersions = peakResolver.getRequiredRPackagesVersions();
String callerFeatureName = peakResolver.getName();
REngineType rEngineType = peakResolver.getREngineType(parameters);
rSession = new RSessionWrapper(rEngineType, callerFeatureName, reqPackages, reqPackagesVersions);
rSession.open();
} else {
rSession = null;
}
CenterFunction mzCenterFunction = new CenterFunction(CenterMeasure.MEDIAN);
// preview doesn't show msms scans
// set it to be default searching range
resolvedPeaks = peakResolver.resolvePeaks(previewPeak, parameters, rSession, mzCenterFunction, 0, 0);
// Turn off R instance.
if (rSession != null)
rSession.close(false);
} catch (RSessionWrapperException e) {
throw new IllegalStateException(e.getMessage());
} catch (Throwable t) {
LOG.log(Level.SEVERE, "Peak deconvolution error", t);
MZmineCore.getDesktop().displayErrorMessage(this, t.toString());
}
// Add resolved peaks to TIC plot.
final int peakCount = Math.min(MAX_PEAKS, resolvedPeaks.length);
for (int i = 0; i < peakCount; i++) {
final XYDataset peakDataSet = new PeakDataSet(resolvedPeaks[i]);
ticPlot.addPeakDataset(peakDataSet);
}
// Check peak count.
if (resolvedPeaks.length > MAX_PEAKS) {
// MZmineCore.getDesktop().displayMessage(this,
// "Too many peaks detected, please adjust parameter values");
MZmineCore.getDesktop().displayMessage(this, "Too many peaks detected. Not all of the peaks might be displayed");
}
}
}
}
use of net.sf.mzmine.util.maths.CenterFunction in project mzmine2 by mzmine.
the class DeconvolutionModule method runModule.
@Override
@Nonnull
public ExitCode runModule(@Nonnull MZmineProject project, @Nonnull final ParameterSet parameters, @Nonnull final Collection<Task> tasks) {
PeakList[] peakLists = parameters.getParameter(DeconvolutionParameters.PEAK_LISTS).getValue().getMatchingPeakLists();
// function to calculate center mz
CenterFunction mzCenterFunction = parameters.getParameter(DeconvolutionParameters.MZ_CENTER_FUNCTION).getValue();
// use a LOG weighted, noise corrected, maximum weight capped function
if (mzCenterFunction.getMeasure().equals(CenterMeasure.AUTO)) {
// data point with lowest intensity
// weight = LOG(value) - LOG(noise) (maxed to maxWeight)
double noise = Arrays.stream(peakLists).flatMap(pkl -> Arrays.stream(pkl.getRows())).map(r -> r.getPeaks()[0]).mapToDouble(peak -> peak.getRawDataPointsIntensityRange().lowerEndpoint()).filter(v -> v != 0).min().orElse(0);
// maxWeight 4 corresponds to a linear range of 4 orders of magnitude
// everything higher than this will be capped to this weight
// do not overestimate influence of very high data points on mass accuracy
double maxWeight = 4;
// use a LOG weighted, noise corrected, maximum weight capped function
mzCenterFunction = new CenterFunction(CenterMeasure.AVG, Weighting.LOG10, noise, maxWeight);
}
for (final PeakList peakList : peakLists) {
tasks.add(new DeconvolutionTask(project, peakList, parameters, mzCenterFunction));
}
return ExitCode.OK;
}
Aggregations