public PeakChromatogramGenerator(double tolerance, Globals.ChromatogramGeneratorMode chromMode, Globals.IsotopicProfileType isotopicProfileTarget, Globals.ToleranceUnit toleranceUnit = Globals.ToleranceUnit.PPM) { Tolerance = tolerance; ChromatogramGeneratorMode = chromMode; IsotopicProfileTarget = isotopicProfileTarget; TopNPeaksLowerCutOff = 0.3; ChromWindowWidthForNonAlignedData = 0.4f; ChromWindowWidthForAlignedData = 0.1f; ToleranceUnit = toleranceUnit; _chromGen = new ChromatogramGenerator(); }
protected ChromatogramCorrelatorBase(int numPointsInSmoother, double minRelativeIntensityForChromCorr, double chromTolerance, Globals.ToleranceUnit toleranceUnit = Globals.ToleranceUnit.PPM) { SavitzkyGolaySmoothingOrder = 2; NumPointsInSmoother = numPointsInSmoother; ChromTolerance = chromTolerance; MinimumRelativeIntensityForChromCorr = minRelativeIntensityForChromCorr; ChromToleranceUnit = toleranceUnit; PeakChromGen = new PeakChromatogramGenerator(ChromTolerance, Globals.ChromatogramGeneratorMode.MOST_ABUNDANT_PEAK, Globals.IsotopicProfileType.UNLABELLED, toleranceUnit); Smoother = new SavitzkyGolaySmoother(NumPointsInSmoother, SavitzkyGolaySmoothingOrder, false); }
public XYData GenerateChromatogram(Run run, IsotopicProfile theorProfile, int lowerScan, int upperScan, double tolerance, Globals.ToleranceUnit toleranceUnit = Globals.ToleranceUnit.PPM) { if (ChromatogramGeneratorMode == Globals.ChromatogramGeneratorMode.MZ_BASED) { throw new NotSupportedException("Don't use this method for MZ_BASED chromatogram generation. Use a different overload"); } var targetMZList = GetTargetMzList(theorProfile); return(GenerateChromatogram(run, targetMZList, lowerScan, upperScan, tolerance, toleranceUnit)); }
public XYData GenerateChromatogram(Run run, List <double> targetMzList, int lowerScan, int upperScan, double tolerance, Globals.ToleranceUnit toleranceUnit = Globals.ToleranceUnit.PPM) { var midScan = (int)((lowerScan + (double)upperScan) / 2); if (run.MassIsAligned) { for (var i = 0; i < targetMzList.Count; i++) { targetMzList[i] = getAlignedMZValue(targetMzList[i], run, midScan); } } var chromValues = _chromGen.GenerateChromatogram(run.ResultCollection.GetMsPeakResultsGroupedAndMzOrdered(), lowerScan, upperScan, targetMzList, tolerance, toleranceUnit); chromValues = FilterOutDataBasedOnMsMsLevel(run, chromValues, 1, false); return(chromValues); }
public XYData GenerateChromatogram(Run run, int scanStart, int scanStop, double targetMz, double tolerance, Globals.ToleranceUnit toleranceUnit = Globals.ToleranceUnit.PPM) { var targetMzList = new List <double> { targetMz }; return(GenerateChromatogram(run, targetMzList, scanStart, scanStop, tolerance, toleranceUnit)); }
//TODO: make a ChromatogramObject that will help handle my MSPeakResults, etc. public XYData GenerateChromatogram(Dictionary <int, List <MSPeakResult> > groupedMsPeakList, int minScan, int maxScan, List <double> targetMZList, double tolerance, int chromIDToAssign, Globals.ToleranceUnit toleranceUnit = Globals.ToleranceUnit.PPM) { Check.Require(groupedMsPeakList != null && groupedMsPeakList.Count > 0, "Cannot generate chromatogram. Source msPeakList is empty or hasn't been defined."); var scanTolerance = 5; // TODO: keep an eye on this // PNNLOmics.Generic.AnonymousComparer<MSPeakResult> comparer = new PNNLOmics.Generic.AnonymousComparer<MSPeakResult>((x, y) => x.MSPeak.XValue.CompareTo(y.MSPeak.XValue)); var comparer = new MSPeakResultComparer(); var tempPeakList = new List <MSPeakResult>(); for (var i = minScan - scanTolerance; i < maxScan + scanTolerance; i++) { if (groupedMsPeakList == null || !groupedMsPeakList.TryGetValue(i, out var msPeakResultList)) { continue; } foreach (var targetMZ in targetMZList) { double lowerMZ; double upperMZ; if (toleranceUnit == Globals.ToleranceUnit.PPM) { lowerMZ = targetMZ - tolerance * targetMZ / 1e6; upperMZ = targetMZ + tolerance * targetMZ / 1e6; } else if (toleranceUnit == Globals.ToleranceUnit.MZ) { lowerMZ = targetMZ - tolerance; upperMZ = targetMZ + tolerance; } else { throw new ArgumentOutOfRangeException("Trying to create chromatogram, but the " + toleranceUnit + " unit isn't supported"); } var lowMsPeak = new MSPeak(lowerMZ); var lowMsPeakResult = new MSPeakResult { MSPeak = lowMsPeak }; var binarySearchResult = msPeakResultList.BinarySearch(lowMsPeakResult, comparer); var nearestSearchResult = binarySearchResult >= 0 ? binarySearchResult : ~binarySearchResult; for (var j = nearestSearchResult; j < msPeakResultList.Count; j++) { var msPeakResult = msPeakResultList[j]; if (msPeakResult.MSPeak.XValue <= upperMZ) { tempPeakList.Add(msPeakResult); } } } } XYData chromData = null; if (!tempPeakList.Any()) { //TODO: we want to return 0 intensity values. But need to make sure there are no downstream problems with this change. } else { chromData = GetChromDataAndFillInZerosAndAssignChromID(tempPeakList, chromIDToAssign); } return(chromData); }
/// <summary> /// Will generate a chromatogram that is in fact a combination of chromatograms based on user-supplied target m/z values. /// This is geared for producing a chromatogram for an isotopic profile, but only using narrow mass ranges /// that encompass individual peaks of an isotopic profile. /// </summary> /// <param name="groupedMsPeakList"></param> /// <param name="minScan"></param> /// <param name="maxScan"></param> /// <param name="targetMZList"></param> /// <param name="tolerance"></param> /// <param name="toleranceUnit"></param> /// <returns></returns> public XYData GenerateChromatogram(Dictionary <int, List <MSPeakResult> > groupedMsPeakList, int minScan, int maxScan, List <double> targetMZList, double tolerance, Globals.ToleranceUnit toleranceUnit = Globals.ToleranceUnit.PPM) { var defaultChromID = 0; return(GenerateChromatogram(groupedMsPeakList, minScan, maxScan, targetMZList, tolerance, defaultChromID, toleranceUnit)); }
public XYData GenerateChromatogram(List <MSPeakResult> msPeakList, int minScan, int maxScan, double targetMZ, double tolerance, int chromIDToAssign, Globals.ToleranceUnit toleranceUnit = Globals.ToleranceUnit.PPM) { var targetMZList = new List <double> { targetMZ }; return(GenerateChromatogram(msPeakList, minScan, maxScan, targetMZList, tolerance, chromIDToAssign, toleranceUnit)); }
public XYData GenerateChromatogram(List <MSPeakResult> msPeakList, int minScan, int maxScan, List <double> targetMZList, double tolerance, int chromIDToAssign, Globals.ToleranceUnit toleranceUnit = Globals.ToleranceUnit.PPM) { Check.Require(msPeakList != null && msPeakList.Count > 0, "Cannot generate chromatogram. Source msPeakList is empty or hasn't been defined."); if (msPeakList == null) { return(null); } var scanTolerance = 5; // TODO: keep an eye on this var indexOfLowerScan = GetIndexOfClosestScanValue(msPeakList, minScan, 0, msPeakList.Count - 1, scanTolerance); var indexOfUpperScan = GetIndexOfClosestScanValue(msPeakList, maxScan, 0, msPeakList.Count - 1, scanTolerance); XYData chromData = null; foreach (var targetMZ in targetMZList) { double lowerMZ; double upperMZ; if (toleranceUnit == Globals.ToleranceUnit.PPM) { lowerMZ = targetMZ - tolerance * targetMZ / 1e6; upperMZ = targetMZ + tolerance * targetMZ / 1e6; } else if (toleranceUnit == Globals.ToleranceUnit.MZ) { lowerMZ = targetMZ - tolerance; upperMZ = targetMZ + tolerance; } else { throw new ArgumentOutOfRangeException("Trying to create chromatogram, but the " + toleranceUnit + " unit isn't supported"); } var tempPeakList = new List <MSPeakResult>(); for (var i = indexOfLowerScan; i <= indexOfUpperScan; i++) { var msPeakResult = msPeakList[i]; var xValue = msPeakResult.MSPeak.XValue; if (xValue >= lowerMZ && xValue <= upperMZ) { tempPeakList.Add(msPeakResult); } } if (!tempPeakList.Any()) { //TODO: we want to return 0 intensity values. But need to make sure there are no downstream problems with this change. } else { var currentChromData = GetChromDataAndFillInZerosAndAssignChromID(tempPeakList, chromIDToAssign); chromData = AddCurrentXYDataToBaseXYData(chromData, currentChromData); } } return(chromData); }
public ChromatogramCorrelator(int numPointsInSmoother, double minRelativeIntensityForChromCorr = 0.01, double chromToleranceInPPM = 20, Globals.ToleranceUnit chromToleranceUnit = Globals.ToleranceUnit.PPM) : base(numPointsInSmoother, minRelativeIntensityForChromCorr, chromToleranceInPPM, chromToleranceUnit) { }