Package net.sf.mzmine.data

Examples of net.sf.mzmine.data.ChromatographicPeak


        PeakUtils.copyPeakListRowProperties(row, newRow);

        // Copy the peaks.
        for (final ChromatographicPeak peak : row.getPeaks()) {

          final ChromatographicPeak newPeak = new SimpleChromatographicPeak(
              peak);
          PeakUtils.copyPeakProperties(peak, newPeak);
          newRow.addPeak(peak.getDataFile(), newPeak);
        }
View Full Code Here


      // Loop through all peaks, and collect candidates for the n:th peak
      // in the pattern
      Vector<ChromatographicPeak> goodCandidates = new Vector<ChromatographicPeak>();
      for (int ind = 0; ind < sortedPeaks.length; ind++) {

        ChromatographicPeak candidatePeak = sortedPeaks[ind];

        if (candidatePeak == null)
          continue;

        // Get properties of the candidate peak
        double candidatePeakMZ = candidatePeak.getMZ();
        double candidatePeakRT = candidatePeak.getRT();

        // Does this peak fill all requirements of a candidate?
        // - within tolerances from the expected location (M/Z and RT)
        // - not already a fitted peak (only necessary to avoid
        // conflicts when parameters are set too wide)
View Full Code Here

          assert nearestStandardRow != null;

          // Calc and store a single normalization factor
          normalizationFactors = new double[1];
          normalizationFactorWeights = new double[1];
          ChromatographicPeak standardPeak = nearestStandardRow
              .getPeak(file);
          if (peakMeasurementType == PeakMeasurementType.HEIGHT) {
            normalizationFactors[0] = standardPeak.getHeight();
          } else {
            normalizationFactors[0] = standardPeak.getArea();
          }
          logger.finest("Normalizing row #" + row.getID()
              + " using standard peak " + standardPeak
              + ", factor " + normalizationFactors[0]);
          normalizationFactorWeights[0] = 1.0f;

        }

        if (normalizationType == StandardUsageType.Weighted) {

          // Add all standards as factors, and use distance as weight
          normalizationFactors = new double[standardRows.length];
          normalizationFactorWeights = new double[standardRows.length];

          for (int standardRowIndex = 0; standardRowIndex < standardRows.length; standardRowIndex++) {
            PeakListRow standardRow = standardRows[standardRowIndex];

            double stdMZ = standardRow.getAverageMZ();
            double stdRT = standardRow.getAverageRT();
            double distance = MZvsRTBalance * Math.abs(mz - stdMZ)
                + Math.abs(rt - stdRT);

            ChromatographicPeak standardPeak = standardRow
                .getPeak(file);
            if (standardPeak == null) {
              // What to do if standard peak is not
              // available? (Currently this is ruled out by the
              // setup dialog, which shows only peaks that are
              // present in all samples)
              normalizationFactors[standardRowIndex] = 1.0;
              normalizationFactorWeights[standardRowIndex] = 0.0;
            } else {
              if (peakMeasurementType == PeakMeasurementType.HEIGHT) {
                normalizationFactors[standardRowIndex] = standardPeak
                    .getHeight();
              } else {
                normalizationFactors[standardRowIndex] = standardPeak
                    .getArea();
              }
              normalizationFactorWeights[standardRowIndex] = 1 / distance;
            }
          }

        }

        assert normalizationFactors != null;
        assert normalizationFactorWeights != null;

        // Calculate a single normalization factor as weighted average
        // of all factors
        double weightedSum = 0.0f;
        double sumOfWeights = 0.0f;
        for (int factorIndex = 0; factorIndex < normalizationFactors.length; factorIndex++) {
          weightedSum += normalizationFactors[factorIndex]
              * normalizationFactorWeights[factorIndex];
          sumOfWeights += normalizationFactorWeights[factorIndex];
        }
        double normalizationFactor = weightedSum / sumOfWeights;

        // For simple scaling of the normalized values
        normalizationFactor = normalizationFactor / 100.0f;

        logger.finest("Normalizing row #" + row.getID() + "[" + file
            + "] using factor " + normalizationFactor);

        // How to handle zero normalization factor?
        if (normalizationFactor == 0.0)
          normalizationFactor = Double.MIN_VALUE;

        // Normalize peak
        ChromatographicPeak originalPeak = row.getPeak(file);
        if (originalPeak != null) {

          SimpleChromatographicPeak normalizedPeak = new SimpleChromatographicPeak(
              originalPeak);

          PeakUtils.copyPeakProperties(originalPeak, normalizedPeak);

          double normalizedHeight = originalPeak.getHeight()
              / normalizationFactor;
          double normalizedArea = originalPeak.getArea()
              / normalizationFactor;
          normalizedPeak.setHeight(normalizedHeight);
          normalizedPeak.setArea(normalizedArea);

          normalizedRow.addPeak(file, normalizedPeak);
View Full Code Here

        // area or height of the reference peaks in each row
        for (int column = 0; column < shownDataFiles.size(); column++) {
          double value = Double.NaN;
          if (rowPeak.getPeak(shownDataFiles.get(column)) != null) {

            ChromatographicPeak peak = rowPeak
                .getPeak(shownDataFiles.get(column));
            if (area) {

              value = peak.getArea() / referenceAverage;
            } else {

              value = peak.getHeight() / referenceAverage;
            }
            if (log) {

              value = Math.log(value);
            }
View Full Code Here

                  selectedParameter,
                  shownDataFiles.get(dataColumn));
              if (rowPeak.getPeak(shownDataFiles.get(dataColumn)) != null
                  && String.valueOf(paramValue).equals(group)) {

                ChromatographicPeak peak = rowPeak
                    .getPeak(shownDataFiles.get(dataColumn));

                if (!Double.isInfinite(peak.getArea())
                    && !Double.isNaN(peak.getArea())) {

                  if (area) {

                    meanGroupStats.addValue(peak.getArea());
                  } else {

                    meanGroupStats.addValue(peak
                        .getHeight());
                  }
                }

              }
View Full Code Here

    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];
        ChromatographicPeak p = peakListRow.getPeak(rawDataFile);
        if (p != null) {
          if (useArea)
            rawData[fileIndex][rowIndex] = p.getArea();
          else
            rawData[fileIndex][rowIndex] = p.getHeight();
        }
      }
    }

    int numComponents = xAxisPC;
View Full Code Here

      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];
          ChromatographicPeak p = peakListRow.getPeak(rawDataFile);
          if (p != null) {
            if (useArea) {
              rawData[fileIndex][rowIndex] = p.getArea();
            } else {
              rawData[fileIndex][rowIndex] = p.getHeight();
            }
          }
        }
      }
    } else {
      rawData = new double[selectedRows.length][selectedRawDataFiles.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];
          ChromatographicPeak p = peakListRow.getPeak(rawDataFile);
          if (p != null) {
            if (useArea) {
              rawData[rowIndex][fileIndex] = p.getArea();
            } else {
              rawData[rowIndex][fileIndex] = p.getHeight();
            }
          }
        }
      }
    }
View Full Code Here

      PeakListRow row = alignedPeakList.getRow(rowIndex);

      // Collect available peak intensities for selected files
      Vector<Double> peakIntensities = new Vector<Double>();
      for (int fileIndex = 0; fileIndex < selectedFiles.length; fileIndex++) {
        ChromatographicPeak p = row.getPeak(selectedFiles[fileIndex]);
        if (p != null) {
          if (measurementType == PeakMeasurementType.AREA)
            peakIntensities.add(p.getArea());
          else
            peakIntensities.add(p.getHeight());
        }
      }

      // If there are at least two measurements available for this peak
      // then calc CV and include this peak in the plot
View Full Code Here

          + (weight * (normalizedStdRTs[nextStdIndex] - normalizedStdRTs[prevStdIndex]));
    }

    // Set normalized retention time to all peaks in this row
    for (RawDataFile file : originalRow.getRawDataFiles()) {
      ChromatographicPeak originalPeak = originalRow.getPeak(file);
      if (originalPeak != null) {
        SimpleChromatographicPeak normalizedPeak = new SimpleChromatographicPeak(
            originalPeak);
        PeakUtils.copyPeakProperties(originalPeak, normalizedPeak);
        normalizedPeak.setRT(normalizedRT);
View Full Code Here

    // Loop through all raw data files, and find the peak with biggest
    // height
    double maxOriginalHeight = 0.0;
    for (RawDataFile file : originalPeakList.getRawDataFiles()) {
      for (PeakListRow originalpeakListRow : originalPeakList.getRows()) {
        ChromatographicPeak p = originalpeakListRow.getPeak(file);
        if (p != null) {
          if (maxOriginalHeight <= p.getHeight())
            maxOriginalHeight = p.getHeight();
        }
      }
    }

    // Loop through all raw data files, and normalize peak values
    for (RawDataFile file : originalPeakList.getRawDataFiles()) {

      // Cancel?
      if (isCanceled()) {
        return;
      }

      // Determine normalization type and calculate normalization factor
      double normalizationFactor = 1.0;

      // - normalization by average peak intensity
      if (normalizationType == NormalizationType.AverageIntensity) {
        double intensitySum = 0;
        int intensityCount = 0;
        for (PeakListRow peakListRow : originalPeakList.getRows()) {
          ChromatographicPeak p = peakListRow.getPeak(file);
          if (p != null) {
            if (peakMeasurementType == PeakMeasurementType.HEIGHT) {
              intensitySum += p.getHeight();
            } else {
              intensitySum += p.getArea();
            }
            intensityCount++;
          }
        }
        normalizationFactor = intensitySum / (double) intensityCount;
      }

      // - normalization by average squared peak intensity
      if (normalizationType == NormalizationType.AverageSquaredIntensity) {
        double intensitySum = 0.0;
        int intensityCount = 0;
        for (PeakListRow peakListRow : originalPeakList.getRows()) {
          ChromatographicPeak p = peakListRow.getPeak(file);
          if (p != null) {
            if (peakMeasurementType == PeakMeasurementType.HEIGHT) {
              intensitySum += (p.getHeight() * p.getHeight());
            } else {
              intensitySum += (p.getArea() * p.getArea());
            }
            intensityCount++;
          }
        }
        normalizationFactor = intensitySum / (double) intensityCount;
      }

      // - normalization by maximum peak intensity
      if (normalizationType == NormalizationType.MaximumPeakHeight) {
        double maximumIntensity = 0.0;
        for (PeakListRow peakListRow : originalPeakList.getRows()) {
          ChromatographicPeak p = peakListRow.getPeak(file);
          if (p != null) {
            if (peakMeasurementType == PeakMeasurementType.HEIGHT) {
              if (maximumIntensity < p.getHeight())
                maximumIntensity = p.getHeight();
            } else {
              if (maximumIntensity < p.getArea())
                maximumIntensity = p.getArea();
            }

          }
        }
        normalizationFactor = maximumIntensity;
      }

      // - normalization by total raw signal
      if (normalizationType == NormalizationType.TotalRawSignal) {
        normalizationFactor = 0;
        for (int scanNumber : file.getScanNumbers(1)) {
          Scan scan = file.getScan(scanNumber);
          normalizationFactor += scan.getTIC();
        }
      }

      // Readjust normalization factor so that maximum height will be
      // equal to maximumOverallPeakHeightAfterNormalization after
      // normalization
      double maxNormalizedHeight = maxOriginalHeight
          / normalizationFactor;
      normalizationFactor = normalizationFactor * maxNormalizedHeight
          / maximumOverallPeakHeightAfterNormalization;

      // Normalize all peak intenisities using the normalization factor
      for (PeakListRow originalpeakListRow : originalPeakList.getRows()) {

        // Cancel?
        if (isCanceled()) {
          return;
        }

        ChromatographicPeak originalPeak = originalpeakListRow
            .getPeak(file);
        if (originalPeak != null) {

          SimpleChromatographicPeak normalizedPeak = new SimpleChromatographicPeak(
              originalPeak);
          PeakUtils.copyPeakProperties(originalPeak, normalizedPeak);

          double normalizedHeight = originalPeak.getHeight()
              / normalizationFactor;
          double normalizedArea = originalPeak.getArea()
              / normalizationFactor;
          normalizedPeak.setHeight(normalizedHeight);
          normalizedPeak.setArea(normalizedArea);

          SimplePeakListRow normalizedRow = rowMap
View Full Code Here

TOP

Related Classes of net.sf.mzmine.data.ChromatographicPeak

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.