/// <summary> /// Finds the XIC based on the m/z and scan parameters. /// </summary> /// <param name="mz"></param> /// <param name="scan"></param> /// <returns></returns> public List <XYData> FindXic(double mz, int scan, bool shouldSmooth) { LcmsFeatureTarget target = new LcmsFeatureTarget(); target.ID = 0; target.MZ = mz; target.ScanLCTarget = scan; target.ElutionTimeUnit = Globals.ElutionTimeUnit.ScanNum; m_run.CurrentMassTag = target; var result = m_run.ResultCollection.GetTargetedResult(m_run.CurrentMassTag); double chromPeakGeneratorTolInPPM = MzPpmWindow; Globals.ChromatogramGeneratorMode chromGeneratorMode = Globals.ChromatogramGeneratorMode.MZ_BASED; var chromGen = new PeakChromatogramGenerator(chromPeakGeneratorTolInPPM, chromGeneratorMode); chromGen.NETWindowWidthForNonAlignedData = Convert.ToSingle(NetWindow); int pointsToSmooth = 5; var chromSmoother = new SavitzkyGolaySmoother(pointsToSmooth, 2); double chromPeakDetectorPeakBR = 1; double chromPeakDetectorSigNoise = 1; var chromPeakDetector = new ChromPeakDetector(chromPeakDetectorPeakBR, chromPeakDetectorSigNoise); ChromPeakSelectorParameters chromPeakSelectorParameters = new ChromPeakSelectorParameters(); var chromPeakSelector = new BasicChromPeakSelector(chromPeakSelectorParameters); //this generates an extracted ion chromatogram // Since we are not using the built in generator, chromGen.Execute(m_run.ResultCollection); //this smooths the data - very important step! if (shouldSmooth) { chromSmoother.Execute(m_run.ResultCollection); } //this detects peaks within an extracted ion chromatogram chromPeakDetector.Execute(m_run.ResultCollection); //this selects the peak chromPeakSelector.Parameters.PeakSelectorMode = Globals.PeakSelectorMode.ClosestToTarget; chromPeakSelector.Execute(m_run.ResultCollection); //Here's the chromatogram data... List <XYData> data = new List <XYData>(); for (int i = 0; i < m_run.XYData.Xvalues.Length; i++) { XYData datum = new XYData(m_run.XYData.Xvalues[i], m_run.XYData.Yvalues[i]); data.Add(datum); } return(data); }
public void smootherTest1() { Run run = new MSScanFromTextFileRun(FileRefs.RawDataMSFiles.TextFileMS_std1); Task msgen = new GenericMSGenerator(); msgen.Execute(run.ResultCollection); var peakdetector = new DeconToolsPeakDetectorV2(3, 3, Globals.PeakFitType.QUADRATIC, true); peakdetector.Execute(run.ResultCollection); Assert.AreEqual(84, run.PeakList.Count); Task smoother = new SavitzkyGolaySmoother(7, 2, false); smoother.Execute(run.ResultCollection); peakdetector.Execute(run.ResultCollection); Assert.AreEqual(46, run.PeakList.Count); }
public void Test1() { var testFile = @"D:\Data\Orbitrap\BrianIQTesting\QC_Shew_11_02_pt5-b_6Jun11_Sphinx_11-03-27.RAW"; var peaksTestFile = @"D:\Data\Orbitrap\BrianIQTesting\QC_Shew_11_02_pt5-b_6Jun11_Sphinx_11-03-27_peaks.txt"; var run = RunUtilities.CreateAndLoadPeaks(testFile, peaksTestFile); var target = new LcmsFeatureTarget(); target.ID = 0; target.MZ = 715.39214; target.ScanLCTarget = 7343; target.ElutionTimeUnit = Globals.ElutionTimeUnit.ScanNum; run.CurrentMassTag = target; var result = run.ResultCollection.GetTargetedResult(run.CurrentMassTag); double chromPeakGeneratorTolInPPM = 20; var chromGeneratorMode = Globals.ChromatogramGeneratorMode.MZ_BASED; var chromGen = new PeakChromatogramGenerator(chromPeakGeneratorTolInPPM, chromGeneratorMode); // If we want to use the Execute Command //BLL .1 and .5 NET windows work. .02 NET window does not BR and SN was set to 1 however) chromGen.ChromWindowWidthForNonAlignedData = .02F; var pointsToSmooth = 5; var chromSmoother = new SavitzkyGolaySmoother(pointsToSmooth, 2); //BLL We also tried to set the BR and SIG NOISE to 0. This did not work var chromPeakDetectorPeakBR = 0.5; var chromPeakDetectorSigNoise = 0.5; var chromPeakDetector = new ChromPeakDetector(chromPeakDetectorPeakBR, chromPeakDetectorSigNoise); var chromPeakSelectorParameters = new ChromPeakSelectorParameters(); chromPeakSelectorParameters.PeakSelectorMode = Globals.PeakSelectorMode.ClosestToTarget; var chromPeakSelector = new BasicChromPeakSelector(chromPeakSelectorParameters); var smartChromPeakParameters = new SmartChromPeakSelectorParameters(); var smartChromPeakSelector = new SmartChromPeakSelector(smartChromPeakParameters); //this generates an extracted ion chromatogram // Since we are not using the built in generator, chromGen.Execute(run.ResultCollection); //this smooths the data - very important step! //BLL. This didnt work for me when we first started, instead of using the NET window above. //chromGen.GenerateChromatogram(run, // target.ScanLCTarget - 300, // target.ScanLCTarget + 300, // target.MZ, // chromPeakGeneratorTolInPPM); chromSmoother.Execute(run.ResultCollection); //this detects peaks within an extracted ion chromatogram chromPeakDetector.Execute(run.ResultCollection); //this selects the peak chromPeakSelector.Execute(run.ResultCollection); //smartChromPeakSelector.Execute(run.ResultCollection); //TestUtilities.DisplayXYValues(run.XYData); TestUtilities.DisplayPeaks(run.PeakList); Console.WriteLine("Number of peaks detected = " + run.PeakList.Count); Console.WriteLine("Selected peak= " + result.ChromPeakSelected); }
/// <summary> /// Finds the XIC based on the m/z and scan parameters. /// </summary> /// <param name="mz"></param> /// <param name="scan"></param> /// <returns></returns> public List<PNNLOmics.Data.XYData> FindXic(double mz, int scan, bool shouldSmooth) { LcmsFeatureTarget target = new LcmsFeatureTarget(); target.ID = 0; target.MZ = mz; target.ScanLCTarget = scan; target.ElutionTimeUnit = Globals.ElutionTimeUnit.ScanNum; m_run.CurrentMassTag = target; var result = m_run.ResultCollection.GetTargetedResult(m_run.CurrentMassTag); double chromPeakGeneratorTolInPPM = MzPpmWindow; Globals.ChromatogramGeneratorMode chromGeneratorMode = Globals.ChromatogramGeneratorMode.MZ_BASED; var chromGen = new PeakChromatogramGenerator( chromPeakGeneratorTolInPPM, chromGeneratorMode); chromGen.NETWindowWidthForNonAlignedData = Convert.ToSingle(NetWindow); int pointsToSmooth = 5; var chromSmoother = new SavitzkyGolaySmoother(pointsToSmooth, 2); double chromPeakDetectorPeakBR = 1; double chromPeakDetectorSigNoise = 1; var chromPeakDetector = new ChromPeakDetector( chromPeakDetectorPeakBR, chromPeakDetectorSigNoise); ChromPeakSelectorParameters chromPeakSelectorParameters = new ChromPeakSelectorParameters(); var chromPeakSelector = new BasicChromPeakSelector(chromPeakSelectorParameters); //this generates an extracted ion chromatogram // Since we are not using the built in generator, chromGen.Execute(m_run.ResultCollection); //this smooths the data - very important step! if (shouldSmooth) { chromSmoother.Execute(m_run.ResultCollection); } //this detects peaks within an extracted ion chromatogram chromPeakDetector.Execute(m_run.ResultCollection); //this selects the peak chromPeakSelector.Parameters.PeakSelectorMode = Globals.PeakSelectorMode.ClosestToTarget; chromPeakSelector.Execute(m_run.ResultCollection); //Here's the chromatogram data... List<PNNLOmics.Data.XYData> data = new List<PNNLOmics.Data.XYData>(); for (int i = 0; i < m_run.XYData.Xvalues.Length; i++) { PNNLOmics.Data.XYData datum = new PNNLOmics.Data.XYData(m_run.XYData.Xvalues[i], m_run.XYData.Yvalues[i]); data.Add(datum); } return data; }
public void OptimizePeakDetectionSettings() { string testDatasetPath = @"D:\Data\From_Vlad\Bruker\2013_01_29_ALZ_CTRL_5_0p5_1_01_228.d"; int[] scanList = new int[] { 200 }; Run run = new RunFactory().CreateRun(testDatasetPath); var peakDetector = new DeconToolsPeakDetector(); peakDetector.PeakToBackgroundRatio = 7; peakDetector.SignalToNoiseThreshold = 5; peakDetector.IsDataThresholded = false; var msgen = MSGeneratorFactory.CreateMSGenerator(run.MSFileType); var decon = new HornDeconvolutor(); decon.MaxFitAllowed = 0.6; double[] peakBRList = new double[] { 5, 7, 9, 11, 15, 21 }; double[] sigNoiseList = new double[] { 2, 3, 4, 5 }; var smoother = new SavitzkyGolaySmoother(5, 2); foreach (var scan in scanList) { ScanSet scanSet = new ScanSet(scan); run.CurrentScanSet = scanSet; msgen.Execute(run.ResultCollection); foreach (var peakBRVal in peakBRList) { foreach (var sigNoiseVal in sigNoiseList) { run.ResultCollection.IsosResultBin.Clear(); smoother.Execute(run.ResultCollection); peakDetector.PeakToBackgroundRatio = peakBRVal; peakDetector.SignalToNoiseThreshold = sigNoiseVal; peakDetector.Execute(run.ResultCollection); decon.Execute(run.ResultCollection); int numFeatures = run.ResultCollection.IsosResultBin.Count; int numPeaks = run.PeakList.Count; int numHQFeatures = run.ResultCollection.IsosResultBin.Count(p => p.IsotopicProfile.Score < 0.25); double ratioFeaturesToPeaks = (double)numHQFeatures / numPeaks; Console.WriteLine(scan + "\t" + peakBRVal + "\t" + sigNoiseVal + "\t" + numPeaks + "\t" + numFeatures + "\t" + numHQFeatures + "\t" + ratioFeaturesToPeaks.ToString("0.000")); } } } }