Search in sources :

Example 1 with RetTimeClusterer

use of dulab.adap.workflow.decomposition.RetTimeClusterer in project mzmine2 by mzmine.

the class ADAP3DecompositionV2SetupDialog method retTimeCluster.

/**
 * Cluster all peaks in PeakList based on retention time
 */
private void retTimeCluster() {
    ChromatogramPeakPair chromatogramPeakPair = cboPeakLists.getItemAt(cboPeakLists.getSelectedIndex());
    if (chromatogramPeakPair == null)
        return;
    PeakList chromatogramList = chromatogramPeakPair.chromatograms;
    PeakList peakList = chromatogramPeakPair.peaks;
    if (chromatogramList == null || peakList == null)
        return;
    Double minDistance = parameterSet.getParameter(ADAP3DecompositionV2Parameters.PREF_WINDOW_WIDTH).getValue();
    if (minDistance == null || minDistance <= 0.0)
        return;
    // Convert peakList into ranges
    List<RetTimeClusterer.Interval> ranges = Arrays.stream(peakList.getRows()).map(PeakListRow::getBestPeak).map(p -> new RetTimeClusterer.Interval(p.getRawDataPointsRTRange(), p.getMZ())).collect(Collectors.toList());
    List<BetterPeak> peaks = new ADAP3DecompositionV2Utils().getPeaks(peakList);
    // Form clusters of ranges
    List<RetTimeClusterer.Cluster> retTimeClusters = new RetTimeClusterer(minDistance).execute(peaks);
    cboClusters.removeAllItems();
    cboClusters.removeActionListener(this);
    for (RetTimeClusterer.Cluster cluster : retTimeClusters) {
        int i;
        for (i = 0; i < cboClusters.getItemCount(); ++i) {
            double retTime = cboClusters.getItemAt(i).retTime;
            if (cluster.retTime < retTime) {
                cboClusters.insertItemAt(cluster, i);
                break;
            }
        }
        if (i == cboClusters.getItemCount())
            cboClusters.addItem(cluster);
    }
    cboClusters.addActionListener(this);
    retTimeMZPlot.updateData(retTimeClusters);
    shapeCluster();
}
Also used : RetTimeClusterer(dulab.adap.workflow.decomposition.RetTimeClusterer) java.util(java.util) MZmineCore(net.sf.mzmine.main.MZmineCore) Parameter(net.sf.mzmine.parameters.Parameter) BetterComponent(dulab.adap.datamodel.BetterComponent) GUIUtils(net.sf.mzmine.util.GUIUtils) ActionEvent(java.awt.event.ActionEvent) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) PeakList(net.sf.mzmine.datamodel.PeakList) PeakListRow(net.sf.mzmine.datamodel.PeakListRow) java.awt(java.awt) List(java.util.List) ComponentSelector(dulab.adap.workflow.decomposition.ComponentSelector) ParameterSet(net.sf.mzmine.parameters.ParameterSet) BetterPeak(dulab.adap.datamodel.BetterPeak) ParameterSetupDialog(net.sf.mzmine.parameters.dialogs.ParameterSetupDialog) Nonnull(javax.annotation.Nonnull) javax.swing(javax.swing) BetterPeak(dulab.adap.datamodel.BetterPeak) PeakListRow(net.sf.mzmine.datamodel.PeakListRow) RetTimeClusterer(dulab.adap.workflow.decomposition.RetTimeClusterer) PeakList(net.sf.mzmine.datamodel.PeakList)

Aggregations

Sets (com.google.common.collect.Sets)1 BetterComponent (dulab.adap.datamodel.BetterComponent)1 BetterPeak (dulab.adap.datamodel.BetterPeak)1 ComponentSelector (dulab.adap.workflow.decomposition.ComponentSelector)1 RetTimeClusterer (dulab.adap.workflow.decomposition.RetTimeClusterer)1 java.awt (java.awt)1 ActionEvent (java.awt.event.ActionEvent)1 java.util (java.util)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Nonnull (javax.annotation.Nonnull)1 javax.swing (javax.swing)1 PeakList (net.sf.mzmine.datamodel.PeakList)1 PeakListRow (net.sf.mzmine.datamodel.PeakListRow)1 MZmineCore (net.sf.mzmine.main.MZmineCore)1 Parameter (net.sf.mzmine.parameters.Parameter)1 ParameterSet (net.sf.mzmine.parameters.ParameterSet)1 ParameterSetupDialog (net.sf.mzmine.parameters.dialogs.ParameterSetupDialog)1 GUIUtils (net.sf.mzmine.util.GUIUtils)1