public void PlotSpectra(MSSpectra spectrum) { Model.Series.Clear(); var colorIterator = new ColorTypeIterator(); var charge = 0; if (spectrum.ParentFeature != null) { charge = spectrum.ParentFeature.ChargeState; } var series = new StemSeries { Title = string.Format("{0} m/z charge {1}", spectrum.PrecursorMz, charge), Color = colorIterator.GetColor(charge) }; foreach (var peak in spectrum.Peaks) { series.Points.Add(new DataPoint(peak.X, peak.Y)); } Model.Series.Add(series); }
public UmcClusterDatasetHistogram(Dictionary <int, int> histogram, string name) : base(name) { var axis = new CategoryAxis { Position = AxisPosition.Bottom, MinorStep = 1, LabelField = "Datasets", AbsoluteMinimum = 0, GapWidth = 0 }; // Count axis var linearAxis = new LinearAxis { Position = AxisPosition.Left, MaximumPadding = .15, AbsoluteMinimum = 1, Minimum = 0, MinimumPadding = 1 }; Model.IsLegendVisible = true; Model.Axes.Add(axis); Model.Axes.Add(linearAxis); // Add the data to the view model var data = new ColumnSeries { ValueField = "Value", StrokeThickness = 1, LabelFormatString = "{0}", }; var colors = new ColorTypeIterator(); foreach (var bin in histogram.OrderBy(h => h.Key)) { axis.Labels.Add(bin.Key.ToString()); int number = histogram[bin.Key]; var column = new ColumnItem(number) { Color = colors.GetColor(bin.Key) }; data.Items.Add(column); } m_xAxis = axis; Model.Series.Add(data); Model.Axes[0].MajorGridlineStyle = LineStyle.Solid; Model.Axes[1].MajorGridlineStyle = LineStyle.Solid; }
public ChargeStateViewModel(int charge, double mz, int scanStart, int scanEnd) { var iterator = new ColorTypeIterator(); var oldColor = iterator.GetColor(charge); var newColor = new Color { A = oldColor.A, R = oldColor.R, G = oldColor.G, B = oldColor.B }; ChargeColor = new SolidColorBrush(newColor); ChargeState = charge; ScanStart = scanStart; ScanEnd = scanEnd; Mz = mz; }
public void PlotSpectra(MSFeatureLight feature, IEnumerable <XYData> spectrum) { var series = new StemSeries { Color = OxyColors.Black }; var minimumMz = double.MaxValue; var maximumMz = double.MinValue; var maxAbundance = double.MinValue; if (spectrum.Count() < 1) { return; } foreach (var peak in spectrum) { minimumMz = Math.Min(peak.X, minimumMz); maximumMz = Math.Max(peak.X, maximumMz); maxAbundance = Math.Max(maxAbundance, peak.Y); series.Points.Add(new DataPoint(peak.X, peak.Y)); } var maxAbundanceTop = maxAbundance * .5; Model.Axes[0].AbsoluteMinimum = minimumMz; Model.Axes[0].AbsoluteMaximum = maximumMz; Model.Series.Add(series); // Add in the monoisotopic peak var colors = new ColorTypeIterator(); var chargeColor = colors.GetColor(feature.ChargeState); var msFeature = new StemSeries { Color = chargeColor }; msFeature.Points.Add(new DataPoint(feature.Mz, feature.Abundance)); Model.Series.Add(msFeature); // Add in the rest of the isotopes var alphaColor = OxyColor.FromAColor(100, OxyColors.Red); var charge = feature.ChargeState; var mz = feature.Mz; var abundance = Convert.ToDouble(feature.Abundance); var monoPeakAnnotation = new LineAnnotation { Type = LineAnnotationType.Vertical, X = mz, Color = alphaColor, TextColor = alphaColor, Text = string.Format("mono peak: {0} m/z", mz.ToString("F3")) }; Model.Annotations.Add(monoPeakAnnotation); var lastMz = mz; var spacing = 1.0 / charge; while (mz < maximumMz && abundance > 1) { mz = mz + (1.0 / charge); abundance *= .75; var peakAnnotation = new LineAnnotation { Type = LineAnnotationType.Vertical, X = mz, Color = alphaColor, TextColor = alphaColor, Text = string.Format("{0} m/z", mz.ToString("F3")) }; var spaceAnnotation = new LineAnnotation { Type = LineAnnotationType.Horizontal, Color = alphaColor, TextColor = alphaColor, TextHorizontalAlignment = HorizontalAlignment.Center, TextVerticalAlignment = VerticalAlignment.Top, TextPosition = new DataPoint(.5, 0), MinimumX = lastMz, MaximumX = mz, Text = string.Format("d={0}", spacing.ToString("F2")), Y = maxAbundance * .75 }; maxAbundance *= .75; lastMz = mz; Model.Annotations.Add(spaceAnnotation); Model.Annotations.Add(peakAnnotation); } if (feature.GetParentFeature() != null) { var features = feature.GetParentFeature().Features; foreach (var subFeature in features) { var msms = subFeature.MSnSpectra.Where(x => x.PrecursorMz > minimumMz && x.PrecursorMz < maximumMz); foreach (var fragmentation in msms) { var spaceAnnotation = new LineAnnotation { Type = LineAnnotationType.Vertical, Color = OxyColors.Gray, TextColor = OxyColors.Gray, FontWeight = 3, TextVerticalAlignment = VerticalAlignment.Top, TextPosition = new DataPoint(1, 0), StrokeThickness = 2, Text = string.Format("msms {0} - scan {1}", fragmentation.PrecursorMz.ToString("F2"), fragmentation.Scan), X = fragmentation.PrecursorMz }; Model.Annotations.Add(spaceAnnotation); var lowerMz = new LineAnnotation { Type = LineAnnotationType.Horizontal, Color = OxyColors.LightGray, TextColor = OxyColors.LightGray, FontWeight = 3, TextVerticalAlignment = VerticalAlignment.Top, TextPosition = new DataPoint(1, 0), StrokeThickness = 2, Y = maxAbundanceTop, Text = string.Format("{0} m/z", MsmsDistanceLower.ToString("F2")), MinimumX = fragmentation.PrecursorMz - MsmsDistanceLower, MaximumX = fragmentation.PrecursorMz }; var upperMz = new LineAnnotation { Type = LineAnnotationType.Horizontal, Color = OxyColors.LightGray, TextColor = OxyColors.LightGray, FontWeight = 3, TextVerticalAlignment = VerticalAlignment.Top, TextPosition = new DataPoint(1, 0), StrokeThickness = 2, Text = string.Format("{0} m/z", MsmsDistanceUpper.ToString("F2")), Y = maxAbundanceTop, MinimumX = fragmentation.PrecursorMz, MaximumX = fragmentation.PrecursorMz + MsmsDistanceUpper }; Model.Annotations.Add(upperMz); Model.Annotations.Add(lowerMz); } } } }
/// <summary> /// Plots the UMC's /// </summary> /// <param name="features"></param> private void PlotFeatures(IEnumerable <UMCLight> features) { var markerIterator = new MarkerTypeIterator(); m_colorIterator = new ColorTypeIterator(); var i = 0; m_scanAnnotation = new LineAnnotation { X = 0, TextColor = OxyColors.Gray, Text = "0", TextOrientation = AnnotationTextOrientation.Vertical, LineStyle = LineStyle.Dash, Type = LineAnnotationType.Vertical, }; Model.Annotations.Add(m_scanAnnotation); foreach (var feature in features) { var chargeMap = feature.CreateChargeMap(); foreach (var charge in chargeMap.Keys) { var msFeatures = chargeMap[charge]; msFeatures = msFeatures.OrderBy(x => x.Scan).ToList(); var mz = msFeatures[0].Mz; var newSeries = new LineSeries { Color = m_colorIterator.GetColor(charge), MarkerFill = m_colorIterator.GetColor(charge), MarkerSize = 3, MarkerStroke = OxyColors.White, MarkerStrokeThickness = 1.5, MarkerType = markerIterator.GetMarker(i++), Title = string.Format("{0} m/z - Charge {1}", mz.ToString("F3"), charge) }; double abundance = 0; MSFeatureLight bestFeature = null; foreach (var msFeature in msFeatures) { if (abundance < msFeature.Abundance) { bestFeature = msFeature; abundance = msFeature.Abundance; } foreach (var msms in msFeature.MSnSpectra) { var peptideSequence = ""; if (msms.Peptides.Count > 0) { peptideSequence = msms.Peptides[0].Sequence; } var msmsAnnotation = new LineAnnotation { Type = LineAnnotationType.Vertical, X = msms.Scan, Y = msFeature.Abundance, StrokeThickness = 2, Color = m_colorIterator.GetColor(msFeature.ChargeState), TextColor = m_colorIterator.GetColor(msFeature.ChargeState), Text = string.Format("{2} - {0} m/z {1}", msms.PrecursorMz.ToString("F3"), peptideSequence, msms.CollisionType) }; Model.Annotations.Add(msmsAnnotation); } newSeries.Points.Add(new DataPoint(msFeature.Scan, msFeature.Abundance)); } newSeries.Tag = charge; if (bestFeature != null) { ScanAnnotationX = bestFeature.Scan; SelectedCharge = charge; } Model.Series.Add(newSeries); } } }