public void getDriftProfileFromRawDataMZ_967_Test1() { Run run = TestUtilities.GetStandardUIMFRun(); UIMFRun uimfRun = (UIMFRun)run; DriftTimeProfileExtractor profileExtractor = new DriftTimeProfileExtractor(); FrameSet frameset = new FrameSet(804, 803, 805); uimfRun.CurrentFrameSet = frameset; double targetMZ = 967.26; ScanSetCollectionCreator ssc = new ScanSetCollectionCreator(run, 200, 350, 9, 1); ssc.Create(); //XYData xydata = profileExtractor.ExtractProfileFromRawData(uimfRun, frameset, run.ScanSetCollection, targetMZ, 30d); createPeaks(run); XYData xydata = profileExtractor.ExtractProfileFromPeakData(uimfRun, frameset, run.ScanSetCollection, targetMZ, 30d); TestUtilities.DisplayXYValues(xydata); }
public void WriteXics(string path, List <UMCLight> features) { using (TextWriter writer = File.CreateText(path)) { foreach (UMCLight feature in features) { foreach (int charge in feature.ChargeStateChromatograms.Keys) { writer.WriteLine("id\t{0}\tcharge\t{1}", feature.ID, charge); writer.WriteLine("mz\tfit scan\tfit intensity\tregular scan\tregular intensity"); Chromatogram gram = feature.ChargeStateChromatograms[charge]; int i = 0; for (i = 0; i < gram.Points.Count; i++) { //(XYData point in gram.FitPoints) XYData fitPoint = gram.FitPoints[i]; XYData regPoint = gram.Points[i]; writer.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}", gram.Mz, fitPoint.X, fitPoint.Y, regPoint.X, regPoint.Y); } for (; i < gram.FitPoints.Count; i++) { //(XYData point in gram.FitPoints) XYData fitPoint = gram.FitPoints[i]; writer.WriteLine("{0}\t{1}\t{2}", gram.Mz, fitPoint.X, fitPoint.Y); } } } } }
public void getDriftProfileMZ_796_Test1() //** { Run run = TestUtilities.GetStandardUIMFRun(); UIMFRun uimfRun = (UIMFRun)run; DriftTimeProfileExtractor profileExtractor = new DriftTimeProfileExtractor(); FrameSet frameset = new FrameSet(616, 615, 617); uimfRun.CurrentFrameSet = frameset; double targetMZ = 1004.1987; ScanSetCollectionCreator ssc = new ScanSetCollectionCreator(run, 200, 350, 1, 1); ssc.Create(); XYData xydata = profileExtractor.ExtractProfileFromRawData(uimfRun, frameset, run.ScanSetCollection, targetMZ, 30d); TestUtilities.DisplayXYValues(xydata); Console.WriteLine("-------------------------------------------------------------------------------------"); createPeaks(run); xydata = profileExtractor.ExtractProfileFromPeakData(uimfRun, frameset, run.ScanSetCollection, targetMZ, 30d); TestUtilities.DisplayXYValues(xydata); }
public override XYData GetMassSpectrum(ScanSet scanset) { double[] xvals; double[] yvals; if (scanset.PrimaryScanNumber > MaxLCScan) { throw new ArgumentOutOfRangeException("Cannot get mass spectrum. Exceeded max scan (which = " + MaxLCScan + ")"); } if (scanset.PrimaryScanNumber < MinLCScan) { throw new ArgumentOutOfRangeException("Cannot get mass spectrum. Exceeded min scan (which = " + MinLCScan + ")"); } _reader.GetSpectrum(scanset.PrimaryScanNumber, out xvals, out yvals); var xydata = new XYData { Xvalues = xvals, Yvalues = yvals }; return(xydata); }
//C++ engine calibration settings #region Constructors public BrukerV2Run() { XYData = new XYData(); MSFileType = Globals.MSFileType.Bruker_V2; IsDataThresholded = false; ContainsMSMSData = false; }
protected XYData GetCorrelatedChromPeakXYData(Run run, int startScan, int stopScan, XYData basePeakChromXYData, double correlatedMZValue) { var xydata = PeakChromGen.GenerateChromatogram(run, startScan, stopScan, correlatedMZValue, ChromTolerance, ChromToleranceUnit); XYData chromPeakXYData; if (xydata == null || xydata.Xvalues.Length == 0) { chromPeakXYData = new XYData(); chromPeakXYData.Xvalues = basePeakChromXYData.Xvalues; chromPeakXYData.Yvalues = new double[basePeakChromXYData.Xvalues.Length]; } else { chromPeakXYData = Smoother.Smooth(xydata); } var chromDataIsOK = chromPeakXYData != null && chromPeakXYData.Xvalues != null && chromPeakXYData.Xvalues.Length > 3; if (chromDataIsOK) { chromPeakXYData = chromPeakXYData.TrimData(startScan, stopScan); } return(chromPeakXYData); }
public override XYData GetMassSpectrum(ScanSet scanset, double minMZ, double maxMZ) { Check.Require(scanset != null, "Can't get mass spectrum; inputted set of scans is null"); Check.Require(scanset.IndexValues.Count > 0, "Can't get mass spectrum; no scan numbers inputted"); var totScans = this.GetNumMSScans(); var xvals = new double[0]; var yvals = new double[0]; if (scanset.IndexValues.Count == 1) //this is the case of only wanting one MS spectrum { //TODO: Old DeconTools reference!! this.RawData.GetSpectrum(scanset.IndexValues[0], ref xvals, ref yvals, false); } else { throw new NotImplementedException("Summing is not yet supported for ICR2LS_MS Data files."); //this.rawData.GetSummedSpectra(scanset.getLowestScanNumber(), scanset.getHighestScanNumber(), minMZ, maxMZ, ref xvals, ref yvals); } var xydata = new XYData(); xydata.Xvalues = xvals; xydata.Yvalues = yvals; xydata = xydata.TrimData(minMZ, maxMZ); return(xydata); }
/// <summary> /// Constructor /// </summary> /// <param name="thermoRawFilePath"></param> /// <param name="loadTuneInfo"></param> public XCaliburRun2(string thermoRawFilePath, bool loadTuneInfo = false) { Check.Require(File.Exists(thermoRawFilePath), "Run not initialized. File not found: " + thermoRawFilePath); DatasetFileOrDirectoryPath = thermoRawFilePath; var baseFilename = Path.GetFileName(DatasetFileOrDirectoryPath); if (baseFilename == null) { throw new FileNotFoundException("Unable to determine the filename for " + thermoRawFilePath); } DatasetName = baseFilename.Substring(0, baseFilename.LastIndexOf('.')); DatasetDirectoryPath = Path.GetDirectoryName(thermoRawFilePath); var options = new ThermoReaderOptions { LoadMSMethodInfo = false, LoadMSTuneInfo = loadTuneInfo }; mRawFileReader = new XRawFileIO(DatasetFileOrDirectoryPath, options); IsDataThresholded = true; IsMsAbundanceReportedAsAverage = true; MSFileType = Globals.MSFileType.Thermo_Raw; ContainsMSMSData = true; XYData = new XYData(); ParentScanList = new Dictionary <int, int>(); MinLCScan = 1; MaxLCScan = GetNumMSScans(); }
public SipperQuantifierOld() { IsChromatogramCorrelationPerformed = true; MaximumFitScoreForFurtherProcessing = 0.50; MinimumRatioAreaForFurtherProcessing = 5; MinimumRSquaredValForQuant = 0.75; MinimumRelativeIntensityForChromCorr = 0.0001; ChromToleranceInPPM = 25; const int numPointsInSmoother = 5; _chromatogramCorrelatorTask = new ChromatogramCorrelator(numPointsInSmoother, MinimumRelativeIntensityForChromCorr, (int)ChromToleranceInPPM); ChromatogramRSquaredVals = new List <double>(); RatioLogVals = new XYData(); RatioVals = new XYData(); _labelingDistributionCalculator = new LabelingDistributionCalculator(); _partialLabelingQuantifier = new PartialLabelingQuantifier("C", 12, 13); _partialLabelingQuantifier.MaxLabelAmount = 15; _partialLabelingQuantifier.StepAmountForIterator = 0.25; }
public void test1() { Run run = new XCaliburRun(xcaliburTestfile); MassTag mt = TestUtilities.GetMassTagStandard(1); PeakImporterFromText peakImporter = new DeconTools.Backend.Data.PeakImporterFromText(xcaliburPeakDataFile); peakImporter.ImportPeaks(run.ResultCollection.MSPeakResultList); run.CurrentMassTag = mt; Task theorFeatureGen = new TomTheorFeatureGenerator(); theorFeatureGen.Execute(run.ResultCollection); int numPeaksForExtractingChrom = 3; int toleranceInPPM = 25; IsotopicProfileMultiChromatogramExtractor multiChromExtractor = new IsotopicProfileMultiChromatogramExtractor( numPeaksForExtractingChrom, toleranceInPPM); List <int> ms1Levels = run.GetMSLevelScanValues(); Dictionary <MSPeak, XYData> chromDataForIsotopicProfile = multiChromExtractor.GetChromatogramsForIsotopicProfilePeaks(run.ResultCollection.MSPeakResultList, run.CurrentMassTag.IsotopicProfile, true, ms1Levels); multiChromExtractor.SmoothChromatograms(chromDataForIsotopicProfile, new DeconTools.Backend.ProcessingTasks.Smoothers.DeconToolsSavitzkyGolaySmoother(11, 11, 2)); XYData xydata1 = chromDataForIsotopicProfile.Values.First(); XYData xydata2 = chromDataForIsotopicProfile.Values.ElementAt(1); XYData xydata3 = chromDataForIsotopicProfile.Values.ElementAt(2); TestUtilities.DisplayXYValues(xydata3); }
public void getTheorIsotopicProfileXYDataTest1() { MassTag mt = new MassTag(); mt.ID = 56488; mt.MonoIsotopicMass = 2275.1694779; mt.PeptideSequence = "TTPSIIAYTDDETIVGQPAKR"; mt.NETVal = 0.3520239f; mt.CreatePeptideObject(); mt.ChargeState = 2; Run run = new XCaliburRun(); ResultCollection rc = new ResultCollection(run); rc.Run.CurrentMassTag = mt; Task theorGen = new TomTheorFeatureGenerator(); theorGen.Execute(rc); mt.CalculateMassesForIsotopicProfile(mt.ChargeState); TestUtilities.DisplayIsotopicProfileData(mt.IsotopicProfile); XYData xydata = TheorXYDataCalculationUtilities.Get_Theoretical_IsotopicProfileXYData(mt.IsotopicProfile, 0.02); TestUtilities.DisplayXYValues(xydata); }
public static XYData GetTheorPeakData(double centerXValue, double peakHeight, double peakWidth, int numPointsPerPeak) { var xydata = new XYData(); var one_over_sqrt_of_2_pi = 0.3989423; var sigma = peakWidth / 2.35; // width@half-height = 2.35σ (Gaussian peak theory) var sixsigma = 3 * peakWidth; var mz_per_point = sixsigma / (double)(numPointsPerPeak - 1); var startPoint = 0 - (numPointsPerPeak - 1) / 2; var stopPoint = 0 + (numPointsPerPeak - 1) / 2; xydata.Xvalues = new double[numPointsPerPeak]; xydata.Yvalues = new double[numPointsPerPeak]; var counter = 0; for (var i = startPoint; i <= stopPoint; i++) { var mz = centerXValue + mz_per_point * (i); var intens = (1 / sigma) * one_over_sqrt_of_2_pi * Math.Exp(-1 * ((mz - centerXValue) * (mz - centerXValue)) / (2 * sigma * sigma)); xydata.Xvalues[counter] = mz; xydata.Yvalues[counter] = intens; counter++; } xydata.NormalizeYData(); for (var i = 0; i < xydata.Yvalues.Length; i++) { xydata.Yvalues[i] = xydata.Yvalues[i] * peakHeight; } return(xydata); }
public static XYData NormalizeXYData(XYData xyData) { var normalized = new XYData { Xvalues = xyData.Xvalues, Yvalues = xyData.Yvalues }; var maxYValue = double.MinValue; foreach (var currentVal in normalized.Yvalues) { if (currentVal > maxYValue) { maxYValue = currentVal; } } for (var i = 0; i < normalized.Yvalues.Length; i++) { normalized.Yvalues[i] = normalized.Yvalues[i] / maxYValue; } return(normalized); }
public MzRun() { IsDataThresholded = true; //TODO: this should not be hardcoded, but should be put in parameter file. This property is used by the peak detector MSFileType = Globals.MSFileType.Thermo_Raw; ContainsMSMSData = true; XYData = new XYData(); }
private void OutputMassSpectrum(string outputFolder, XYData massSpectrumXYData, TargetBase target, SipperLcmsTargetedResult sipperLcmsTargetedResult) { var msGraphGenerator = new MSGraphControl(); msGraphGenerator.SymbolType = SymbolType.None; if (massSpectrumXYData == null) { massSpectrumXYData = new XYData(); massSpectrumXYData.Xvalues = new double[] { 0, 1, 2, 3, 4, 5 }; massSpectrumXYData.Yvalues = new double[] { 0, 1, 2, 3, 4, 5 }; } msGraphGenerator.GenerateGraph(massSpectrumXYData.Xvalues, massSpectrumXYData.Yvalues, target.MZ - 2, target.MZ + 6); var annotation = "fractionC13= " + sipperLcmsTargetedResult.PercentCarbonsLabelled.ToString("0.000") + "\n" + "populationFraction= " + sipperLcmsTargetedResult.PercentPeptideLabelled.ToString("0.000"); msGraphGenerator.AddAnnotationRelativeAxis(annotation, 0.45, 0.05); var outputFilename = Path.Combine(outputFolder, target.ID + "_MS.png"); msGraphGenerator.SaveGraph(outputFilename); }
public override XYData GetMassSpectrum(ScanSet scanSet, double minMZ, double maxMZ) { Check.Require(scanSet != null, "Can't get mass spectrum; inputted set of scans is null"); Check.Require(scanSet.IndexValues.Count > 0, "Can't get mass spectrum; no scan numbers inputted"); var totScans = this.GetNumMSScans(); var xvals = new double[0]; var yvals = new double[0]; //if (scanSet.IndexValues.Count == 1) //this is the case of only wanting one MS spectrum //{ // this.rawData.GetSpectrum(scanSet.IndexValues[0], ref xvals, ref yvals); //} //else //{ // int upperscan = Math.Min(scanSet.getHighestScanNumber(), this.GetNumMSScans()); // int lowerscan = Math.Max(scanSet.getLowestScanNumber(), 1); // this.rawData.GetSummedSpectra(lowerscan, upperscan, minMZ, maxMZ, ref xvals, ref yvals); //} var upperscan = Math.Min(scanSet.getHighestScanNumber(), this.GetNumMSScans()); var lowerscan = Math.Max(scanSet.getLowestScanNumber(), 1); //TODO: Old DeconTools reference!! remove this this.RawData.GetSummedSpectra(lowerscan, upperscan, minMZ, maxMZ, ref xvals, ref yvals); var xydata = new XYData(); xydata.Xvalues = xvals; xydata.Yvalues = yvals; return(xydata); }
private XYData PrepareMassAlignmentDataForLoessSmoothing(List <IqResult> iqResultsForAlignment) { var scanMassVals = new Dictionary <decimal, double>(); foreach (var iqResult in iqResultsForAlignment) { decimal lcScan; if (iqResult.ChromPeakSelected == null) { lcScan = iqResult.LcScanObs; } else { lcScan = (decimal)Math.Round(iqResult.ChromPeakSelected.XValue, 2); } var yval = iqResult.MassErrorBefore; if (!scanMassVals.ContainsKey(lcScan)) { scanMassVals.Add(lcScan, yval); } } var xyDataForInterpolator = new XYData(); xyDataForInterpolator.Xvalues = scanMassVals.Keys.Select(p => (double)p).ToArray(); xyDataForInterpolator.Yvalues = scanMassVals.Values.ToArray(); return(xyDataForInterpolator); }
public XYData GetChromatogram(int startFrame, int stopFrame, int startIMSScan, int stopIMSScan, double targetMZ, double toleranceInPPM) { var toleranceInMZ = toleranceInPPM / 1e6 * targetMZ; var lowerMZ = targetMZ - toleranceInMZ; var upperMZ = targetMZ + toleranceInMZ; var frameVals = new List <double>(); var intensityVals = new List <double>(); for (var frame = startFrame; frame <= stopFrame; frame++) { var frameSet = new ScanSet(frame); var scan = new ScanSet(startIMSScan, startIMSScan, stopIMSScan); var xyData = GetMassSpectrum(frameSet, scan, lowerMZ, upperMZ); double sumIntensities = 0; if (xyData?.Yvalues != null && xyData.Yvalues.Length > 0) { sumIntensities = xyData.Yvalues.Sum(); } frameVals.Add(frame); intensityVals.Add(sumIntensities); } var chromXYData = new XYData { Xvalues = frameVals.ToArray(), Yvalues = intensityVals.ToArray() }; return(chromXYData); }
public void DisplayComparisonFigure( string pathX, int scanX, string pathY, int scanY, double mzTolerance) { // Convert relative paths to absolute paths pathX = GetPath(pathX); pathY = GetPath(pathY); var spectrumX = GetSpectrum(pathX, scanX); var spectrumY = GetSpectrum(pathY, scanY); var path = Path.GetDirectoryName(pathX); var pathCompareImage = Path.Combine(path, string.Format("comparison-{0}-{1}.png", scanX, scanY)); spectrumX.Peaks = XYData.Bin(spectrumX.Peaks, 0, 2000, mzTolerance); spectrumY.Peaks = XYData.Bin(spectrumY.Peaks, 0, 2000, mzTolerance); DisplayComparisonPlot(spectrumX, spectrumY, mzTolerance, path = pathCompareImage); }
public float GetTIC(XYData xydata, double minMZ, double maxMZ) { if (xydata == null) { return(-1); } var xValues = xydata.Xvalues; var yValues = xydata.Yvalues; if (xValues == null || yValues == null) { return(-1); } double summedIntensities = 0; for (var i = 0; i < yValues.Length; i++) { var xValue = xValues[i]; if (xValue > minMZ && xValue < maxMZ) { summedIntensities += yValues[i]; } } return((float)summedIntensities); }
public override XYData GetMassSpectrum(DeconTools.Backend.Core.ScanSet scanset, double minMZ, double maxMZ) { //TODO: Update upon error fix.... the YAFMS library is throwing an error if I give an m/z outside it's expected range. So until that is fixed, I'll go get all the m/z values and trim them myself double[] xvals = null; float[] yvals = null; if (scanset.IndexValues.Count <= 1) { m_reader.GetSpectrum(this.SpectraID, scanset.PrimaryScanNumber, ref xvals, ref yvals); } else { xvals = new double[0]; yvals = new float[0]; this.getSummedSpectrum(scanset, ref xvals, ref yvals, minMZ, maxMZ); } var xydata = new XYData(); xydata.Xvalues = xvals; xydata.Yvalues = yvals.Select(p => (double)p).ToArray(); return(xydata); }
/// <summary> /// Fills in any missing data in the chrom data being correlated. /// This ensures base chrom data and the correlated chrom data are the same length /// </summary> /// <param name="basePeakChromXYData"></param> /// <param name="chromPeakXYData"></param> /// <returns></returns> protected XYData FillInAnyMissingValuesInChromatogram(XYData basePeakChromXYData, XYData chromPeakXYData) { if (basePeakChromXYData == null || basePeakChromXYData.Xvalues == null || basePeakChromXYData.Xvalues.Length == 0) { return(null); } var filledInData = new SortedDictionary <int, double>(); //first fill with zeros for (var i = 0; i < basePeakChromXYData.Xvalues.Length; i++) { filledInData.Add((int)basePeakChromXYData.Xvalues[i], 0); } //then fill in other values for (var i = 0; i < chromPeakXYData.Xvalues.Length; i++) { var currentScan = (int)chromPeakXYData.Xvalues[i]; if (filledInData.ContainsKey(currentScan)) { filledInData[currentScan] = chromPeakXYData.Yvalues[i]; } } var xydata = new XYData { Xvalues = basePeakChromXYData.Xvalues, Yvalues = filledInData.Values.ToArray() }; return(xydata); }
public BrukerTOF() { XYData = new XYData(); IsDataThresholded = true; MSFileType = Globals.MSFileType.Bruker; ContainsMSMSData = false; }
public override XYData GetMassSpectrum(ScanSet scanSet) { Check.Require(scanSet != null, "Can't get mass spectrum; inputted set of scans is null"); Check.Require(scanSet.IndexValues.Count > 0, "Can't get mass spectrum; no scan numbers inputted"); if (scanSet == null) { return(null); } var xydata = new XYData(); if (scanSet.IndexValues.Count == 1) //this is the case of only wanting one MS spectrum { getAgilentSpectrum(scanSet.PrimaryScanNumber); xydata.Xvalues = m_spec.XArray; xydata.Yvalues = m_spec.YArray.Select(p => (double)p).ToArray(); } else { //throw new NotImplementedException("Summing isn't supported for Agilent.D files - yet"); //this is an implementation of Anuj's summing algorithm 4-2-2012. double[] xvals = null; float[] yvals = null; double minMZ = 0; double maxMZ = 0; getSummedSpectrum(scanSet, ref xvals, ref yvals, minMZ, maxMZ); xydata.Xvalues = xvals; xydata.Yvalues = yvals.Select(p => (double)p).ToArray(); } return(xydata); }
public void getDriftProfileFromRawDataMZ_771_Test1() { Run run = TestUtilities.GetStandardUIMFRun(); UIMFRun uimfRun = (UIMFRun)run; DriftTimeProfileExtractor profileExtractor = new DriftTimeProfileExtractor(); FrameSet frameset = new FrameSet(805, 804, 806); double targetMZ1 = 746.3842; double targetMZ2 = 771.6894; ScanSetCollectionCreator ssc = new ScanSetCollectionCreator(run, 200, 350, 1, 1); ssc.Create(); System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); sw.Start(); XYData xydata = profileExtractor.ExtractProfileFromRawData(uimfRun, frameset, run.ScanSetCollection, targetMZ2, 10d); sw.Stop(); TestUtilities.DisplayXYValues(xydata); Console.WriteLine(sw.ElapsedMilliseconds); }
public SipperQuantifier() { ChromToleranceInPPM = 25; NumPointsInSmoother = 7; MinimumRelativeIntensityForChromCorr = 0.0001; _chromatogramCorrelatorTask = new ChromatogramCorrelator(NumPointsInSmoother, MinimumRelativeIntensityForChromCorr, (int)ChromToleranceInPPM); _labelingDistributionCalculator = new LabelingDistributionCalculator(); _partialLabelingQuantifier = new PartialLabelingQuantifier("C", 12, 13) { MaxLabelAmount = 15, StepAmountForIterator = 0.25, NumLeftZeroPads = 1, NumRightZeroPads = 1, IsTheoreticalTrimmedDownToObserved = true }; IsChromatogramCorrelationPerformed = true; MaximumFitScoreForFurtherProcessing = 0.50; MinimumRatioAreaForFurtherProcessing = 5; MinimumRSquaredValForQuant = 0.75; ChromatogramRSquaredVals = new List <double>(); RatioVals = new XYData(); FitScoreData = new Dictionary <decimal, double>(); }
public Dictionary <MSPeak, XYData> GetChromatogramsForIsotopicProfilePeaks(List <MSPeakResult> peakList, IsotopicProfile theorIso, bool filterOutMSMSScans, List <int> ms1LevelScanTable) { var topTheorIsoPeaks = getTopPeaks(theorIso, m_numPeaks); var chromGen = new ChromatogramGenerator(); var chromatogramsForIsotopicProfiles = new Dictionary <MSPeak, XYData>(); foreach (var peak in topTheorIsoPeaks) { var xyData = chromGen.GenerateChromatogram(peakList, peakList.First().Scan_num, peakList.Last().Scan_num, peak.XValue, m_toleranceInPPM); if (filterOutMSMSScans && ms1LevelScanTable != null) { var filteredChromVals = new Dictionary <int, double>(); for (var i = 0; i < xyData.Xvalues.Length; i++) { var currentScanVal = (int)xyData.Xvalues[i]; if (ms1LevelScanTable.Contains(currentScanVal)) { filteredChromVals.Add(currentScanVal, xyData.Yvalues[i]); } } xyData.Xvalues = XYData.ConvertIntsToDouble(filteredChromVals.Keys.ToArray()); xyData.Yvalues = filteredChromVals.Values.ToArray(); } chromatogramsForIsotopicProfiles.Add((MSPeak)peak, xyData); } return(chromatogramsForIsotopicProfiles); }
public override XYData GetMassSpectrum(ScanSet scanset) { //if (scanset.IndexValues.Count > 1) //{ // throw new NotImplementedException("Summing was attempted on YafMS data, but summing hasn't been implemented"); //} //double[] xvals = null; //float[] yvals = null; // m_reader.GetSpectrum(this.SpectraID, scanset.PrimaryScanNumber, ref xvals, ref yvals); //TODO: This simple scanset only method is not implemented in XCaliburRun double[] xvals = null; float[] yvals = null; if (scanset.IndexValues.Count <= 1) { m_reader.GetSpectrum(this.SpectraID, scanset.PrimaryScanNumber, ref xvals, ref yvals); } else { xvals = new double[0]; yvals = new float[0]; this.getSummedSpectrum(scanset, ref xvals, ref yvals); } var xydata = new XYData(); xydata.Xvalues = xvals; xydata.Yvalues = yvals.Select(p => (double)p).ToArray(); return(xydata); }
public void fitterOnHornDataTest1() { Run run = new XCaliburRun(xcaliburTestfile); ResultCollection results = new ResultCollection(run); run.CurrentScanSet = new ScanSet(6067); Task msGen = new GenericMSGenerator(1154, 1158); msGen.Execute(results); DeconToolsV2.Peaks.clsPeakProcessorParameters detectorParams = new DeconToolsV2.Peaks.clsPeakProcessorParameters(); detectorParams.PeakBackgroundRatio = 0.5; detectorParams.PeakFitType = DeconToolsV2.Peaks.PEAK_FIT_TYPE.QUADRATIC; detectorParams.SignalToNoiseThreshold = 3; detectorParams.ThresholdedData = false; Task peakDetector = new DeconToolsPeakDetector(detectorParams); peakDetector.Execute(results); DeconToolsV2.HornTransform.clsHornTransformParameters hornParameters = new DeconToolsV2.HornTransform.clsHornTransformParameters(); hornParameters.PeptideMinBackgroundRatio = 2; Task decon = new HornDeconvolutor(hornParameters); decon.Execute(results); IsosResult result1 = results.ResultList[0]; MercuryDistributionCreator distcreator = new MercuryDistributionCreator(); double resolution = result1.IsotopicProfile.GetMZofMostAbundantPeak() / result1.IsotopicProfile.GetFWHM(); distcreator.CreateDistribution(result1.IsotopicProfile.MonoIsotopicMass, result1.IsotopicProfile.ChargeState, resolution); distcreator.OffsetDistribution(result1.IsotopicProfile); XYData theorXYData = distcreator.Data; StringBuilder sb = new StringBuilder(); TestUtilities.GetXYValuesToStringBuilder(sb, theorXYData.Xvalues, theorXYData.Yvalues); Console.WriteLine(sb.ToString()); AreaFitter areafitter = new AreaFitter(theorXYData, run.XYData, 10); double fitval = areafitter.getFit(); Console.WriteLine(result1.IsotopicProfile.Score + "\t" + fitval); Console.WriteLine((result1.IsotopicProfile.Score - fitval) / result1.IsotopicProfile.Score); Assert.AreEqual(0.0209385414928986, (decimal)fitval); //TODO: fix this test... i'm getting 0.0207350903681061m }
/// <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); }
internal static void AssertXYData(XYData xyData, double[] expectedXValues, double[] expectedYValues) { Assert.AreEqual(expectedXValues.Length, xyData.XValues.Length); Assert.AreEqual(expectedYValues.Length, xyData.YValues.Length); for (int i=0; i < xyData.XValues.Length; i++) { Assert.AreEqual(expectedXValues[i], xyData.XValues[i]); Assert.AreEqual(expectedYValues[i], xyData.YValues[i]); } }
public void AddHitPercentageTrendPlot(string pilotName, string plotName, string mode, string tourTypeFilter) { Registry.Instance.GetPilotStats(pilotName).FighterScoresList.SortList("TourNumber", ListSortDirection.Ascending); XYData xy = new XYData(pilotName, plotName, mode, tourTypeFilter, null, null, Color.DarkOrange); _plots.Add(xy); // hmmm, im not 100% convinced this will add the data in the correct order?? foreach (FighterScoresDO score in Registry.Instance.GetPilotStats(pilotName).FighterScoresList) { if(score.TourType == tourTypeFilter) xy.yData.Add((double)score.VsEnemyHitPercentageScore); } }
private void CreateObservedIsotopicProfilePlot() { XYData xydata = new XYData(); if (Workflow.MassSpectrumXYData == null) { xydata.Xvalues = Workflow.MassSpectrumXYData == null ? new double[] { 400, 1500 } : Workflow.MassSpectrumXYData.Xvalues; xydata.Yvalues = Workflow.MassSpectrumXYData == null ? new double[] { 0, 0 } : Workflow.MassSpectrumXYData.Yvalues; } else { xydata.Xvalues = Workflow.MassSpectrumXYData.Xvalues; xydata.Yvalues = Workflow.MassSpectrumXYData.Yvalues; xydata = xydata.TrimData(Workflow.Result.Target.MZ - 100, Workflow.Result.Target.MZ + 100); } if (Workflow.Result.IsotopicProfile != null) { MsGraphMaxY = Workflow.Result.IsotopicProfile.getMostIntensePeak().Height; } else { MsGraphMaxY = (float)xydata.getMaxY(); } string msGraphTitle = Workflow.Result.Target.Code + "; m/z " + Workflow.Result.Target.MZ.ToString("0.0000") + "; z=" + Workflow.Result.Target.ChargeState; PlotModel plotModel = new PlotModel(msGraphTitle); plotModel.TitleFontSize = 11; plotModel.Padding = new OxyThickness(0); plotModel.PlotMargins = new OxyThickness(0); plotModel.PlotAreaBorderThickness = 0; var series = new OxyPlot.Series.LineSeries(); series.MarkerSize = 1; series.Color = OxyColors.Black; for (int i = 0; i < xydata.Xvalues.Length; i++) { series.Points.Add(new DataPoint(xydata.Xvalues[i], xydata.Yvalues[i])); } var xAxis = new LinearAxis(AxisPosition.Bottom, "m/z"); xAxis.Minimum = MsGraphMinX; xAxis.Maximum = MsGraphMaxX; var yAxis = new LinearAxis(AxisPosition.Left, "Intensity"); yAxis.Minimum = 0; yAxis.AbsoluteMinimum = 0; yAxis.Maximum = MsGraphMaxY + MsGraphMaxY * 0.05; yAxis.StringFormat = "0.0E0"; //yAxis.Maximum = maxIntensity + (maxIntensity * .05); //yAxis.AbsoluteMaximum = maxIntensity + (maxIntensity * .05); yAxis.AxisChanged += OnYAxisChange; xAxis.AxislineStyle = LineStyle.Solid; xAxis.AxislineThickness = 1; yAxis.AxislineStyle = LineStyle.Solid; yAxis.AxislineThickness = 1; plotModel.Series.Add(series); plotModel.Axes.Add(xAxis); plotModel.Axes.Add(yAxis); ObservedIsoPlot = plotModel; }
private void CreateChromCorrPlot() { ChromCorrXYData = new XYData(); ChromCorrXYData.Xvalues = Workflow.ChromCorrelationRSquaredVals == null ? new double[] { 0, 1, 2, 3, 4 } : Workflow.ChromCorrelationRSquaredVals.Xvalues; ChromCorrXYData.Yvalues = Workflow.ChromCorrelationRSquaredVals == null ? new double[] { 0, 0, 0, 0, 0 } : Workflow.ChromCorrelationRSquaredVals.Yvalues; XYData xydata = new XYData(); xydata.Xvalues = ChromCorrXYData.Xvalues; xydata.Yvalues = ChromCorrXYData.Yvalues; string graphTitle = "Isotope peak correlation data"; PlotModel plotModel = new PlotModel(graphTitle); plotModel.TitleFontSize = 10; plotModel.Padding = new OxyThickness(0); plotModel.PlotMargins = new OxyThickness(0); plotModel.PlotAreaBorderThickness = 0; var series = new OxyPlot.Series.LineSeries(); series.MarkerSize = 3; series.MarkerType = MarkerType.Square; series.MarkerStrokeThickness = 1; series.MarkerFill = OxyColors.DarkRed; series.MarkerStroke = OxyColors.Black; series.Color = OxyColors.Black; for (int i = 0; i < xydata.Xvalues.Length; i++) { series.Points.Add(new DataPoint(xydata.Xvalues[i], xydata.Yvalues[i])); } var xAxis = new LinearAxis(AxisPosition.Bottom, "isotopic peak #"); var yAxis = new LinearAxis(AxisPosition.Left, "correlation"); xAxis.AxislineStyle = LineStyle.Solid; xAxis.AxislineThickness = 1; yAxis.AxislineStyle = LineStyle.Solid; yAxis.AxislineThickness = 1; xAxis.FontSize = 8; xAxis.MajorStep = 1; xAxis.ShowMinorTicks = false; xAxis.MinorStep = 1; yAxis.FontSize = 8; yAxis.Minimum = 0; yAxis.AbsoluteMinimum = 0; yAxis.Maximum = 1.02; yAxis.AbsoluteMaximum = 1.02; yAxis.AxisChanged += OnYAxisChange; plotModel.Series.Add(series); plotModel.Axes.Add(yAxis); plotModel.Axes.Add(xAxis); ChromCorrelationPlot = plotModel; }
private void CreateMsPlotForScanByScanAnalysis(ScanSet scanSet) { XYData xydata = new XYData(); xydata.Xvalues = MassSpecXyData == null ? new double[] { 400, 1500 } : MassSpecXyData.Xvalues; xydata.Yvalues = MassSpecXyData == null ? new double[] { 0, 0 } : MassSpecXyData.Yvalues; string msGraphTitle = "Observed MS - Scan: " + scanSet; MsGraphMaxY = (float)xydata.getMaxY(MsGraphMinX, MsGraphMaxX); PlotModel plotModel = new PlotModel(msGraphTitle); plotModel.TitleFontSize = 11; plotModel.Padding = new OxyThickness(0); plotModel.PlotMargins = new OxyThickness(0); plotModel.PlotAreaBorderThickness = 0; var series = new OxyPlot.Series.LineSeries(); series.MarkerSize = 1; series.Color = OxyColors.Black; for (int i = 0; i < xydata.Xvalues.Length; i++) { series.Points.Add(new DataPoint(xydata.Xvalues[i], xydata.Yvalues[i])); } var xAxis = new LinearAxis(AxisPosition.Bottom, "m/z"); xAxis.Minimum = MsGraphMinX; xAxis.Maximum = MsGraphMaxX; var yAxis = new LinearAxis(AxisPosition.Left, "Intensity"); yAxis.Minimum = 0; yAxis.AbsoluteMinimum = 0; yAxis.Maximum = MsGraphMaxY + MsGraphMaxY * 0.05; //yAxis.Maximum = maxIntensity + (maxIntensity * .05); //yAxis.AbsoluteMaximum = maxIntensity + (maxIntensity * .05); yAxis.AxisChanged += OnYAxisChange; yAxis.StringFormat = "0.0E0"; xAxis.AxislineStyle = LineStyle.Solid; xAxis.AxislineThickness = 1; yAxis.AxislineStyle = LineStyle.Solid; yAxis.AxislineThickness = 1; plotModel.Series.Add(series); plotModel.Axes.Add(xAxis); plotModel.Axes.Add(yAxis); ObservedIsoPlot = plotModel; }
private void UpdateGraphRelatedProperties() { ChromXyData = new XYData(); ChromXyData.Xvalues = Workflow.ChromatogramXYData == null ? new double[] { 0, 1, 2, 3, 4 } : Workflow.ChromatogramXYData.Xvalues; ChromXyData.Yvalues = Workflow.ChromatogramXYData == null ? new double[] { 0, 1, 2, 3, 4 } : Workflow.ChromatogramXYData.Yvalues; //MassSpecXYData = new XYData(); //MassSpecXYData.Xvalues = Workflow.MassSpectrumXYData == null ? new double[] { 0, 1, 2, 3, 4 } : Workflow.MassSpectrumXYData.Xvalues; //MassSpecXYData.Yvalues = Workflow.MassSpectrumXYData == null ? new double[] { 0, 1, 2, 3, 4 } : Workflow.MassSpectrumXYData.Yvalues; RatioXyData = new XYData(); RatioXyData.Xvalues = Workflow.RatioVals == null ? new double[] { 0, 1, 2, 3, 4 } : Workflow.RatioVals.Xvalues; RatioXyData.Yvalues = Workflow.RatioVals == null ? new double[] { 0, 0, 0, 0, 0 } : Workflow.RatioVals.Yvalues; RatioLogsXyData = new XYData(); RatioLogsXyData.Xvalues = new double[] { 0, 1, 2, 3, 4 }; RatioLogsXyData.Yvalues = new double[] { 0, 0, 0, 0, 0 }; LabelDistributionXyData = new XYData(); if (CurrentResult != null && CurrentResult.LabelDistributionVals != null && CurrentResult.LabelDistributionVals.Length > 0) { //var xvals = ratioData.Peaklist.Select((p, i) => new { peak = p, index = i }).Select(n => (double)n.index).ToList(); LabelDistributionXyData.Xvalues = CurrentResult.LabelDistributionVals.Select((value, index) => new { index }).Select(n => (double)n.index).ToArray(); LabelDistributionXyData.Yvalues = CurrentResult.LabelDistributionVals; } else { LabelDistributionXyData.Xvalues = new double[] { 0, 1, 2, 3 }; LabelDistributionXyData.Yvalues = new double[] { 0, 0, 0, 0 }; } //if (CurrentResultInfo != null) //{ // MSGraphMinX = CurrentResultInfo.MonoMZ - 1.75; // MSGraphMaxX = CurrentResultInfo.MonoMZ + MassSpecVisibleWindowWidth; //} //else //{ // MSGraphMinX = MassSpecXYData.Xvalues.Min(); // MSGraphMaxX = MassSpecXYData.Xvalues.Max(); //} }
private void CreateChromatogramPlot() { var centerScan = Workflow.Result.Target.ScanLCTarget; ChromGraphMinX = centerScan - ChromGraphXWindowWidth / 2; ChromGraphMaxX = centerScan + ChromGraphXWindowWidth / 2; XYData xydata = new XYData(); if (Workflow.ChromatogramXYData == null) { xydata.Xvalues = Workflow.ChromatogramXYData == null ? new double[] { 1, Run.MaxLCScan } : Workflow.ChromatogramXYData.Xvalues; xydata.Yvalues = Workflow.ChromatogramXYData == null ? new double[] { 0, 0 } : Workflow.ChromatogramXYData.Yvalues; } else { xydata.Xvalues = Workflow.ChromatogramXYData.Xvalues; xydata.Yvalues = Workflow.ChromatogramXYData.Yvalues; } string graphTitle = "TargetID=" + Workflow.Result.Target.ID + "; m/z " + Workflow.Result.Target.MZ.ToString("0.0000") + "; z=" + Workflow.Result.Target.ChargeState; PlotModel plotModel = new PlotModel(graphTitle); plotModel.TitleFontSize = 11; plotModel.Padding = new OxyThickness(0); plotModel.PlotMargins = new OxyThickness(0); plotModel.PlotAreaBorderThickness = 0; var series = new OxyPlot.Series.LineSeries(); series.MarkerSize = 1; series.Color = OxyColors.Black; for (int i = 0; i < xydata.Xvalues.Length; i++) { series.Points.Add(new DataPoint(xydata.Xvalues[i], xydata.Yvalues[i])); } var xAxis = new LinearAxis(AxisPosition.Bottom, "scan"); xAxis.Minimum = ChromGraphMinX; xAxis.Maximum = ChromGraphMaxX; var yAxis = new LinearAxis(AxisPosition.Left, "Intensity"); yAxis.Minimum = 0; yAxis.AbsoluteMinimum = 0; var maxY = xydata.getMaxY(); yAxis.Maximum = maxY + maxY * 0.05; yAxis.AxisChanged += OnYAxisChange; xAxis.AxislineStyle = LineStyle.Solid; xAxis.AxislineThickness = 1; yAxis.AxislineStyle = LineStyle.Solid; yAxis.AxislineThickness = 1; plotModel.Series.Add(series); plotModel.Axes.Add(xAxis); plotModel.Axes.Add(yAxis); ChromatogramPlot = plotModel; }
public XYData GetRocCurve(List<ParameterOptimizationResult> allOptimizationResults) { int maxNumLabeled = allOptimizationResults.Select(p => p.NumLabeledPassingFilter).Max(); var rocPoints = new Dictionary<int, int>(); for (int i = 0; i < maxNumLabeled; i++) { int currentPoint = i; var parameterResultsForPoint = allOptimizationResults.Where(p => p.NumUnlabelledPassingFilter == currentPoint).ToList(); bool anyData = parameterResultsForPoint.Any(); if (anyData) { int maxTruePositives = parameterResultsForPoint.Max(p => p.NumLabeledPassingFilter); rocPoints.Add(i, maxTruePositives); } } XYData rocCurve = new XYData { Xvalues = rocPoints.Keys.Select(p => (double) p).ToArray(), Yvalues = rocPoints.Values.Select(p => (double) p).ToArray() }; return rocCurve; }
private void CreateTheorIsotopicProfilePlot() { var theorProfileAligned = Workflow.Result.Target.IsotopicProfile.CloneIsotopicProfile(); double fwhm; if (Workflow.Result.IsotopicProfile != null) { fwhm = Workflow.Result.IsotopicProfile.GetFWHM(); IsotopicProfileUtilities.AlignTwoIsotopicProfiles(Workflow.Result.IsotopicProfile, theorProfileAligned); if (Workflow.SubtractedIso != null && Workflow.SubtractedIso.Peaklist.Count > 0) { SubtractedMassSpecXYData = TheorXYDataCalculationUtilities.GetTheoreticalIsotopicProfileXYData(Workflow.SubtractedIso, fwhm); } else { SubtractedMassSpecXYData = new XYData { Xvalues = new double[] { 400, 500, 600 }, Yvalues = new double[] { 0, 0, 0 } }; } } else { fwhm = DefaultMsPeakWidth; } TheorProfileXyData = TheorXYDataCalculationUtilities.GetTheoreticalIsotopicProfileXYData(Workflow.Result.Target.IsotopicProfile, fwhm); XYData xydata = new XYData(); xydata.Xvalues = TheorProfileXyData.Xvalues; xydata.Yvalues = TheorProfileXyData.Yvalues; //scale to 100; for (int i = 0; i < xydata.Yvalues.Length; i++) { xydata.Yvalues[i] = xydata.Yvalues[i]*100; } string msGraphTitle = "Theoretical MS - m/z " + Workflow.Result.Target.MZ.ToString("0.0000") + "; z=" + Workflow.Result.Target.ChargeState; PlotModel plotModel = new PlotModel(msGraphTitle); plotModel.TitleFontSize = 11; plotModel.Padding = new OxyThickness(0); plotModel.PlotMargins = new OxyThickness(50, 0, 0, 0); plotModel.PlotAreaBorderThickness = 0; var series = new OxyPlot.Series.LineSeries(); series.MarkerSize = 1; series.Color = OxyColors.Black; for (int i = 0; i < xydata.Xvalues.Length; i++) { series.Points.Add(new DataPoint(xydata.Xvalues[i], xydata.Yvalues[i])); } var xAxis = new LinearAxis(AxisPosition.Bottom, "m/z"); xAxis.Minimum = MsGraphMinX; xAxis.Maximum = MsGraphMaxX; var yAxis = new LinearAxis(AxisPosition.Left, "Intensity"); yAxis.Minimum = 0; yAxis.AbsoluteMinimum = 0; yAxis.Maximum = 105; yAxis.AbsoluteMaximum = 105; yAxis.StringFormat = "0.0E0"; //yAxis.Maximum = maxIntensity + (maxIntensity * .05); //yAxis.AbsoluteMaximum = maxIntensity + (maxIntensity * .05); yAxis.AxisChanged += OnYAxisChange; xAxis.AxislineStyle = LineStyle.Solid; xAxis.AxislineThickness = 1; yAxis.AxislineStyle = LineStyle.Solid; yAxis.AxislineThickness = 1; plotModel.Series.Add(series); plotModel.Axes.Add(xAxis); plotModel.Axes.Add(yAxis); TheorIsoPlot = plotModel; }
public void Execute() { //Load results SipperResultFromTextImporter importer = new SipperResultFromTextImporter(_fileInputs.TargetsFilePath); _resultRepositorySource = importer.Import(); //Load Parameters WorkflowParameters.LoadParameters(_fileInputs.ParameterFilePath); //Sort by dataset var sortedDatasets = (from n in _resultRepositorySource.Results orderby n.DatasetName select n); //Set output folder //iterate over results int resultCounter = 0; foreach (SipperLcmsFeatureTargetedResultDTO result in sortedDatasets) { resultCounter++; CurrentResult = result; if (result.DatasetName != CurrentDatasetName) { if (Run != null) { Run.Close(); } InitializeRun(result.DatasetName); } SetCurrentWorkflowTarget(result); Workflow.Execute(); double fwhm; if (Workflow.Result.IsotopicProfile != null) { fwhm = Workflow.Result.IsotopicProfile.GetFWHM(); } else { fwhm = DefaultMSPeakWidth; } TheorProfileXYData = TheorXYDataCalculationUtilities.GetTheoreticalIsotopicProfileXYData(Workflow.Result.Target.IsotopicProfile, fwhm); if (resultCounter % NumResultsPerFolder == 0) { _subFolderCounter++; } OutputImages(); } }
private XYData GetMassSpectrum(int scanLcRep, int scanImsMin, int scanImsMax, int scanImsRep, double minMzForSpectrum, double maxMzForSpectrum) { double[] mzArray; int[] intensityArray; _uimfReader.GetSpectrum(1, 5, DataReader.FrameType.MS1, scanImsMin, scanImsMax, minMzForSpectrum, maxMzForSpectrum, out mzArray, out intensityArray); double[] intensityArrayAsDoubles = XYData.ConvertIntsToDouble(intensityArray); XYData massSpectrum = new XYData(); massSpectrum.SetXYValues(ref mzArray, ref intensityArrayAsDoubles); return massSpectrum; }
private void GetMassSpectrumForCurrentResult() { if (ObservedIsoPlot==null) { ObservedIsoPlot= CreateObservedIsoPlot(); } XYData xydata = new XYData(); if (CurrentResultInfo.MassSpectrumXYData == null) { xydata.Xvalues = CurrentResultInfo.MassSpectrumXYData == null ? new double[] { 400, 1500 } : CurrentResultInfo.MassSpectrumXYData.Xvalues; xydata.Yvalues = CurrentResultInfo.MassSpectrumXYData == null ? new double[] { 0, 0 } : CurrentResultInfo.MassSpectrumXYData.Yvalues; } else { xydata.Xvalues = CurrentResultInfo.MassSpectrumXYData.Xvalues; xydata.Yvalues = CurrentResultInfo.MassSpectrumXYData.Yvalues; xydata = xydata.TrimData(CurrentResultInfo.Result.Target.MZ - 2, CurrentResultInfo.Result.Target.MZ + 8); } double msGraphMaxY; if (CurrentResultInfo.Result.IsotopicProfile != null) { msGraphMaxY = CurrentResultInfo.Result.IsotopicProfile.getMostIntensePeak().Height; } else { msGraphMaxY = (float)xydata.getMaxY(); } string msGraphTitle = "TargetID= " + CurrentResultInfo.Result.Target.ID + "; m/z " + CurrentResultInfo.Result.Target.MZ.ToString("0.0000") + "; z=" + CurrentResultInfo.Result.Target.ChargeState + "; Scan= " + CurrentResultInfo.Result.ScanSet??"[No scan selected]"; ObservedIsoPlot.Series.Clear(); var series = new OxyPlot.Series.LineSeries(); series.MarkerSize = 1; series.Color = OxyColors.Black; for (int i = 0; i < xydata.Xvalues.Length; i++) { series.Points.Add(new DataPoint(xydata.Xvalues[i], xydata.Yvalues[i])); } ObservedIsoPlot.Axes[1].Maximum = msGraphMaxY + msGraphMaxY * 0.05; ObservedIsoPlot.Series.Add(series); }
private void UpdateGraphRelatedProperties() { ChromXYData = new XYData(); ChromXYData.Xvalues = Workflow.ChromatogramXYData == null ? new double[] { 0, 1, 2, 3, 4 } : Workflow.ChromatogramXYData.Xvalues; ChromXYData.Yvalues = Workflow.ChromatogramXYData == null ? new double[] { 0, 1, 2, 3, 4 } : Workflow.ChromatogramXYData.Yvalues; MassSpecXYData = new XYData(); MassSpecXYData.Xvalues = Workflow.MassSpectrumXYData == null ? new double[] { 0, 1, 2, 3, 4 } : Workflow.MassSpectrumXYData.Xvalues; MassSpecXYData.Yvalues = Workflow.MassSpectrumXYData == null ? new double[] { 0, 1, 2, 3, 4 } : Workflow.MassSpectrumXYData.Yvalues; if (CurrentResult != null) { MSGraphMinX = CurrentResult.MonoMZ - 2; MSGraphMaxX = CurrentResult.MonoMZ + 10; } else { MSGraphMinX = MassSpecXYData.Xvalues.Min(); MSGraphMaxX = MassSpecXYData.Xvalues.Max(); } if (CurrentResult != null) { ChromGraphMinX = CurrentResult.ScanLC - ChromGraphXWindowWidth / 2; ChromGraphMaxX = CurrentResult.ScanLC + ChromGraphXWindowWidth / 2; } else { ChromGraphMinX = ChromXYData.Xvalues.Min(); ChromGraphMaxX = ChromXYData.Xvalues.Max(); } }
public void SaveRocCurve(string fileName) { using (StreamWriter writer=new StreamWriter(fileName)) { string header = "numUnlabeled\tnumLabeled"; writer.WriteLine(header); XYData xydata = new XYData(); if (RocCurve==null|| RocCurve.Xvalues==null || RocCurve.Xvalues.Length==0) { xydata.Xvalues=new double[0]; xydata.Yvalues=new double[0]; } else { xydata.Xvalues = RocCurve.Xvalues; xydata.Yvalues = RocCurve.Yvalues; } for (int i = 0; i < xydata.Xvalues.Length; i++) { writer.WriteLine(xydata.Xvalues[i] + "\t" + xydata.Yvalues[i]); } } }
private XYData ZeroFillCentroidData(XYData massSpecXyData) { List<double> newXValues = new List<double>(); List<double> newYValues = new List<double>(); for (int i = 0; i < massSpecXyData.Xvalues.Length; i++) { var currentXVal = massSpecXyData.Xvalues[i]; var currentYVal = massSpecXyData.Yvalues[i]; double zeroFillDistance=0.005; double newXValBefore = currentXVal - zeroFillDistance; double newXValAfter = currentXVal + zeroFillDistance; newXValues.Add(newXValBefore); newYValues.Add(0); newXValues.Add(currentXVal); newYValues.Add(currentYVal); newXValues.Add(newXValAfter); newYValues.Add(0); } return new XYData {Xvalues = newXValues.ToArray(), Yvalues = newYValues.ToArray()}; }
protected XYData GetMassSpectrum(int scanLcRep, int scanImsRep, double minMzForSpectrum, double maxMzForSpectrum) { double[] mzArray; int[] intensityArray; this._uimfReader.GetSpectrum(scanLcRep - 1, scanLcRep + 1, DataReader.FrameType.MS1, scanImsRep - 2, scanImsRep + 2, minMzForSpectrum, maxMzForSpectrum, out mzArray, out intensityArray); double[] intensityArrayAsDoubles = XYData.ConvertIntsToDouble(intensityArray); XYData massSpectrum = new XYData(); massSpectrum.SetXYValues(ref mzArray, ref intensityArrayAsDoubles); return massSpectrum; }
private void GetMinMaxValuesForLabelDistributionGraph(XYData labelDistributionXYData, out double xMin, out double xMax, out double yMin, out double yMax) { xMin = 0.5; bool dataIsEmpty = labelDistributionXYData == null || labelDistributionXYData.Xvalues == null; bool dataIsLimited = dataIsEmpty || labelDistributionXYData.Xvalues.Length < 5; if (dataIsEmpty || dataIsLimited) { xMax = 5; } else { xMax = labelDistributionXYData.Xvalues.Last() + 0.5; } yMin = 0; if (dataIsEmpty) { yMax = 1.1; } else { bool dataIsMostlyUnlabelled = labelDistributionXYData.Yvalues.First() > 0.98; if (dataIsMostlyUnlabelled) { yMax = 1.1; } else { yMax = 0; for (int i = 1; i < labelDistributionXYData.Yvalues.Length; i++) { var currentVal = labelDistributionXYData.Yvalues[i]; if (currentVal > yMax) { yMax = currentVal + currentVal *0.10; } } } } }
protected void WriteXYDataToFile(XYData xyData, double targetMz) { double[] xValues = xyData.Xvalues; double[] yValues = xyData.Yvalues; using (StreamWriter writer = new StreamWriter("xydata" + Math.Round(targetMz, 3) + ".csv")) { for(int i = 0; i < xValues.Length; i++) { writer.WriteLine(Math.Round(xValues[i], 3) + "," + yValues[i]); } } }
public void AddRatioTrendPlot(string pilotName, string plotName, string statNameDividend, string statNameDivisor, Color lineColour, string mode, string tourTypeFilter) { XYData xy = new XYData(pilotName, plotName, mode, tourTypeFilter, statNameDividend, statNameDivisor, lineColour); _plots.Add(xy); }
private void CreateChromatogram() { bool canGenerateChrom = Run != null && Run.ResultCollection.MSPeakResultList != null && Run.ResultCollection.MSPeakResultList.Count > 0 && Peaks != null && Peaks.Count > 0 && SelectedPeak != null; if (!canGenerateChrom) return; double scanWindowWidth = 600; int lowerScan = (int)Math.Round(Math.Max(MinLcScan, CurrentLcScan - scanWindowWidth / 2)); int upperScan = (int)Math.Round(Math.Min(MaxLcScan, CurrentLcScan + scanWindowWidth / 2)); ChromXyData = _peakChromatogramGenerator.GenerateChromatogram(Run, lowerScan, upperScan, SelectedPeak.XValue, ChromToleranceInPpm); if (ChromXyData == null) { ChromXyData = new XYData(); ChromXyData.Xvalues = new double[] { lowerScan, upperScan }; ChromXyData.Yvalues = new double[] { 0, 0 }; } var maxY = (float)ChromXyData.getMaxY(); string graphTitle = "XIC for most intense peak (m/z " + SelectedPeak.XValue.ToString("0.000") + ")"; PlotModel plotModel = new PlotModel(graphTitle); plotModel.TitleFontSize = 9; plotModel.Padding = new OxyThickness(0); plotModel.PlotMargins = new OxyThickness(0); plotModel.PlotAreaBorderThickness = 0; var series = new OxyPlot.Series.LineSeries(); series.MarkerSize = 1; series.Color = OxyColors.Black; for (int i = 0; i < ChromXyData.Xvalues.Length; i++) { series.Points.Add(new DataPoint(ChromXyData.Xvalues[i], ChromXyData.Yvalues[i])); } var xAxis = new LinearAxis(AxisPosition.Bottom, "scan"); xAxis.Minimum = lowerScan; xAxis.Maximum = upperScan; var yAxis = new LinearAxis(AxisPosition.Left, "Intensity"); yAxis.Minimum = 0; yAxis.AbsoluteMinimum = 0; yAxis.Maximum = maxY + maxY * 0.05; yAxis.AxisChanged += OnYAxisChange; xAxis.AxislineStyle = LineStyle.Solid; xAxis.AxislineThickness = 1; yAxis.AxislineStyle = LineStyle.Solid; yAxis.AxislineThickness = 1; plotModel.Series.Add(series); plotModel.Axes.Add(xAxis); plotModel.Axes.Add(yAxis); ChromatogramPlot = plotModel; }
internal static XYData Generate(double[] xValues, double[] yValues) { XYData xyData = new XYData(xValues, yValues); return xyData; }
public void AddSimpleTrendPlot(string pilotName, string plotName, string statName, Color lineColour, string mode, string tourTypeFilter) { XYData xy = new XYData(pilotName, plotName, mode, tourTypeFilter, statName, null, lineColour); _plots.Add(xy); }