private void DisplayTic() { if (CurrentlySelectedSpectraFile.Value == null) { return; } // display TIC over RT List <Datum> tic = new List <Datum>(); List <Datum> identifiedTic = new List <Datum>(); HashSet <double> mzs = new HashSet <double>(); int scanNum = 1; var scan = CurrentlySelectedSpectraFile.Value.GetOneBasedScanFromDynamicConnection(scanNum); while (scan != null) { if (scan.MsnOrder == 1) { // calculate TIC tic.Add(new Datum(scan.RetentionTime, scan.TotalIonCurrent)); // calculate TIC identified double identifiedScanTic = 0; if (ScanNumberToAnnotatedEnvelopes.TryGetValue(scan.OneBasedScanNumber, out var envs)) { mzs.Clear(); foreach (var env in envs) { foreach (var peak in env.PeakMzs) { if (!mzs.Contains(peak)) { mzs.Add(peak); identifiedScanTic += scan.MassSpectrum.YArray[scan.MassSpectrum.GetClosestPeakIndex(peak)]; } } } } identifiedTic.Add(new Datum(scan.RetentionTime, identifiedScanTic)); } scanNum++; scan = CurrentlySelectedSpectraFile.Value.GetOneBasedScanFromDynamicConnection(scanNum); } TicPlot = new mzPlot.LinePlot(topPlotView, tic, OxyColors.Black, 1, seriesTitle: "TIC", chartTitle: Path.GetFileName(CurrentlySelectedSpectraFile.Key), chartSubtitle: ""); if (LoadedAnnotatedSpecies.Any()) { TicPlot.AddLinePlot(identifiedTic, OxyColors.Blue, 1, seriesTitle: "Identified TIC"); } }
private void DisplayAnnotatedSpectrum(int scanNum) { if (CurrentlySelectedSpectraFile.Value == null) { return; } var scan = CurrentlySelectedSpectraFile.Value.GetOneBasedScanFromDynamicConnection(scanNum); if (scan == null) { return; } CurrentScan = scan; ClearTicChartAnnotations(); //List<MsDataScan> childScans = new List<MsDataScan>(); //for (int i = 1; i < 100; i++) //{ // if (scanNum + i > SpectraFile.NumSpectra) // { // break; // } // var nextScan = SpectraFile.GetOneBasedScan(scanNum + i); // if (nextScan.MsnOrder == CurrentScan.MsnOrder) // { // break; // } // childScans.Add(nextScan); //} List <Datum> spectrum = new List <Datum>(); for (int i = 0; i < scan.MassSpectrum.XArray.Length; i++) { spectrum.Add(new Datum(scan.MassSpectrum.XArray[i], scan.MassSpectrum.YArray[i])); } SpectrumPlot = new mzPlot.SpectrumPlot(bottomPlotView, spectrum, chartTitle: "", chartSubtitle: "RT: " + scan.RetentionTime.ToString("F3") + "; Scan #" + scan.OneBasedScanNumber + "; MS" + scan.MsnOrder); SpectrumPlot.Model.Axes.First(p => p.Position == AxisPosition.Left).AbsoluteMinimum = 0; SpectrumPlot.Model.Axes.First(p => p.Position == AxisPosition.Bottom).AbsoluteMinimum = 0; SpectrumPlot.Model.Axes.First(p => p.Position == AxisPosition.Bottom).AbsoluteMaximum = scan.MassSpectrum.Range.Maximum * 1.5; //if (scan.MsnOrder == 1) //{ var colors = SpectrumPlot.Model.DefaultColors.ToList(); int colorIndex = 0; string fileNameNoExt = Path.GetFileNameWithoutExtension(CurrentlySelectedSpectraFile.Key); if (LoadedAnnotatedSpecies != null) { foreach (var species in LoadedAnnotatedSpecies.Where(p => p.DeconvolutionFeature != null && p.DeconvolutionFeature.SpectraFileNameWithoutExtension == fileNameNoExt)) { List <Datum> peakData = new List <Datum>(); foreach (var envelope in species.DeconvolutionFeature.AnnotatedEnvelopes.Where(p => p.OneBasedScanNumber == scan.OneBasedScanNumber)) { foreach (double mz in envelope.PeakMzs) { int ind = scan.MassSpectrum.GetClosestPeakIndex(mz); peakData.Add(new Datum(scan.MassSpectrum.XArray[ind], scan.MassSpectrum.YArray[ind])); } } SpectrumPlot.AddSpectrumPlot(peakData, colors[colorIndex], 1.5); colorIndex++; if (colorIndex >= colors.Count) { colorIndex = 0; } } } //var annot = new LineAnnotation(); //annot.Color = OxyColors.Red; //annot.StrokeThickness = 1.5; //annot.X = scan.RetentionTime; //annot.Type = LineAnnotationType.Vertical; //annot.LineStyle = LineStyle.Solid; //TicPlot.Model.Annotations.Add(annot); //foreach (var childScan in childScans) //{ // if (childScan.IsolationRange != null) // { // var isolationAnnotBegin = new LineAnnotation(); // isolationAnnotBegin.Color = OxyColors.Blue; // isolationAnnotBegin.StrokeThickness = 1.5; // isolationAnnotBegin.X = childScan.IsolationRange.Minimum; // isolationAnnotBegin.Type = LineAnnotationType.Vertical; // isolationAnnotBegin.LineStyle = LineStyle.Dash; // isolationAnnotBegin.Text = "#" + childScan.OneBasedScanNumber; // isolationAnnotBegin.Tag = new DataTag(TagType.ChildScan, isolationAnnotBegin.Text); // SpectrumPlot.Model.Annotations.Add(isolationAnnotBegin); // var isolationAnnotEnd = new LineAnnotation(); // isolationAnnotEnd.Color = OxyColors.Blue; // isolationAnnotEnd.StrokeThickness = 1.5; // isolationAnnotEnd.X = childScan.IsolationRange.Maximum; // isolationAnnotEnd.Type = LineAnnotationType.Vertical; // isolationAnnotEnd.LineStyle = LineStyle.Dash; // isolationAnnotEnd.Tag = new DataTag(TagType.ChildScan, isolationAnnotBegin.Text); // SpectrumPlot.Model.Annotations.Add(isolationAnnotEnd); // } //} TicPlot.RefreshChart(); SpectrumPlot.RefreshChart(); }