Ejemplo n.º 1
0
        public override void UpdateGraph(bool selectionChanged)
        {
            GraphObjList.Clear();
            CurveList.Clear();
            Legend.IsVisible = false;

            if (!DetectionPlotData.GetDataCache().TryGet(
                    GraphSummary.DocumentUIContainer.DocumentUI, Settings.QValueCutoff, this.DataCallback,
                    out _detectionData))
            {
                return;
            }
            AddLabels();

            BarSettings.Type          = BarType.SortedOverlay;
            BarSettings.MinClusterGap = 0.3f;

            //draw bars
            var countPoints = new PointPairList(Enumerable.Range(0, _detectionData.ReplicateCount)
                                                .Select(i => new PointPair(i, TargetData.Histogram[i] / YScale)).ToList());

            CurveList.Insert(0, MakeBarItem(countPoints, Color.FromArgb(180, 220, 255)));

            //axes formatting
            XAxis.Scale.Max = _detectionData.ReplicateCount + 1;

            YAxis.Scale.Max = TargetData.Histogram.Max() / YScale * 1.15;
        }
Ejemplo n.º 2
0
        public void doPlot(IEnumerable <Position> positions)
        {
            CurveList.Clear();
            var infos     = Objects.list(Objects.convert(positions, position => researcher.positionInfo(position)));
            var totalBars = (int)Objects.max(Objects.convert(infos, pnls => (double)pnls.count()));

            debug("total bars: " + totalBars);
            var unconditional = new List <double>(Objects.nCopies(totalBars, 0.0));
            var conditional   = new List <double>(Objects.nCopies(totalBars, 0.0));
            var count         = new List <int>(Objects.nCopies(totalBars, 0));

            Objects.each(infos, pnls => Objects.zeroTo(totalBars, barNum => {
                unconditional[barNum] += pnls.pnl(barNum);
                conditional[barNum]   += toEnd ? pnls.pnlFrom(barNum) : pnls.pnlTo(barNum);
                if (barNum < pnls.count())
                {
                    count[barNum]++;
                }
                debug("barNum = " + barNum + ", pnls.count() - 1 = " + (pnls.count() - 1) + ", count[barNum] = " + count[barNum]);
            }));
            debug("unconditional: " + Objects.toShortString(unconditional));
            debug("conditional: " + Objects.toShortString(conditional));
            debug("count: " + Objects.toShortString(count));
            if (isAverage)
            {
                Objects.eachIt(count, (i, c) => unconditional[i] /= c);
                Objects.eachIt(count, (i, c) => conditional[i]   /= toEnd ? c : infos.Count);
                debug("aa unconditional: " + Objects.toShortString(unconditional));
                debug("aa conditional: " + Objects.toShortString(conditional));
            }

            addBars("conditional", new[] { Color.Red, Color.Lime }, points(conditional));
            addBars("unconditional", new[] { Color.DarkRed, Color.DarkGreen }, points(unconditional));
        }
Ejemplo n.º 3
0
        public override void UpdateGraph(bool selectionChanged)
        {
            SrmDocument document = GraphSummary.DocumentUIContainer.DocumentUI;
            var         windows  = ScheduleWindows;

            // No need to re-graph for a selection change
            if (ReferenceEquals(document, _documentShowing) && ArrayUtil.EqualsDeep(windows, _windowsShowing))
            {
                return;
            }

            _documentShowing = document;
            _windowsShowing  = windows;

            // TODO: Make it possible to see transition scheduling when full-scan enabled.
            YAxis.Title.Text = document.Settings.TransitionSettings.FullScan.IsEnabledMsMs
                                   ? Resources.RTScheduleGraphPane_UpdateGraph_Concurrent_Precursors
                                   : Resources.RTScheduleGraphPane_UpdateGraph_Concurrent_Transitions;

            CurveList.Clear();

            AddCurve(document, Color.Blue);
            for (int i = 0; i < windows.Length; i++)
            {
                double window = windows[i];
                // Do not show the window used by the current document twice.
                if (window == GetSchedulingWindow(document))
                {
                    continue;
                }

                var settings = document.Settings.ChangePeptidePrediction(p => p.ChangeMeasuredRTWindow(window));
                if (settings.PeptideSettings.Prediction.RetentionTime != null)
                {
                    settings = settings.ChangePeptidePrediction(p =>
                                                                p.ChangeRetentionTime(p.RetentionTime.ChangeTimeWindow(window)));
                }
                var docWindow = document.ChangeSettings(settings);

                AddCurve(docWindow, COLORS_WINDOW[(i + 1) % COLORS_WINDOW.Count]);
            }

            AxisChange();
        }
Ejemplo n.º 4
0
        /// <summary>
        ///   Forces a update of the scatter plot.
        /// </summary>
        ///
        public void UpdateGraph()
        {
            classes.Clear();

            if (scatterplot.LabelAxis == null)
            {
                // Create space for unlabelled data
                PointPairList unlabelled = new PointPairList(scatterplot.XAxis, scatterplot.YAxis);

                LineItem item = new LineItem(String.Empty, unlabelled, Color.Black, SymbolType.Diamond);

                item.Line.IsVisible          = false;
                item.Symbol.Border.IsVisible = false;
                item.Symbol.Fill             = new Fill(Color.Black);

                classes.Add(item);
            }
            else
            {
                ColorSequenceCollection colors = new ColorSequenceCollection(scatterplot.Classes.Count);

                // Create a curve item for each of the labels
                for (int i = 0; i < scatterplot.Classes.Count; i++)
                {
                    // retrieve the x,y pairs for the label
                    double[]      x    = scatterplot.Classes[i].XAxis;
                    double[]      y    = scatterplot.Classes[i].YAxis;
                    PointPairList list = new PointPairList(x, y);

                    LineItem item = new LineItem(String.Empty, list, colors[i], SymbolType.Diamond);

                    item.Line.IsVisible          = false;
                    item.Symbol.Border.IsVisible = false;
                    item.Symbol.Fill             = new Fill(colors[i]);

                    classes.Add(item);
                }

                zedGraphControl.AxisChange();
                zedGraphControl.Invalidate();
            }
        }
Ejemplo n.º 5
0
        public void HighlightIndex(int index, int curveIndex, Color color)
        {
            if (curveIndex >= mCurveList.Count)
            {
                return;
            }
            CurveItem curve         = mCurveList[curveIndex];
            int       selectedIndex = index / decimation;

            if (selectedIndex >= curve.Points.Count)
            {
                return;
            }
            PointPair p = curve.Points[selectedIndex];

            LineItem li = new LineItem("", new double[] { p.X }, new double[] { p.Y }, color, SymbolType.UserDefined, 1);

            li.Symbol = GraphSymbol.GetSymbol("Highlight", color);
            highlightList.Clear();
            highlightList.Add(li);
            DisplayCurves();
        }
Ejemplo n.º 6
0
        public override void UpdateGraph(bool selectionChanged)
        {
            if (!GraphSummary.DocumentUIContainer.DocumentUI.Settings.HasResults)
            {
                _areaCVGraphData = null;
                return;
            }

            var settings = new AreaCVGraphData.AreaCVGraphSettings(GraphSummary.Type);

            _document   = GraphSummary.DocumentUIContainer.DocumentUI;
            _percentage = !Settings.Default.AreaCVShowDecimals;
            _decimals   = _percentage ? 1 : 3;

            CurveList.Clear();

            var gotData = _cache.TryGet(_document, settings, DataCallback, out _areaCVGraphData);

            if (!gotData)
            {
                Title.Text = Resources.AreaCVHistogram2DGraphPane_UpdateGraph_Calculating____;
                return;
            }

            if (!_areaCVGraphData.IsValid)
            {
                Title.Text = Resources.AreaCVHistogram2DGraphPane_Draw_Not_enough_data;
                return;
            }

            var factor = AreaGraphController.GetAreaCVFactorToDecimal();

            Title.Text = string.Empty;

            YAxis.Title.Text = Resources.AreaCVHistogram2DGraphPane_UpdateGraph_CV + (_percentage ? @" (%)" : string.Empty);
            XAxis.Title.Text = Resources.AreaCvHistogram2DGraphPane_UpdateGraph_Log10_Mean_Area;

            XAxis.Scale.MinAuto = XAxis.Scale.MinAuto = XAxis.Scale.MaxAuto = YAxis.Scale.MaxAuto = false;
            XAxis.Scale.Min     = Math.Max(0, double.IsNaN(Settings.Default.AreaCVMinLog10Area) ? _areaCVGraphData.MinMeanArea : Settings.Default.AreaCVMinLog10Area);
            XAxis.Scale.Max     = double.IsNaN(Settings.Default.AreaCVMaxLog10Area) ? _areaCVGraphData.MaxMeanArea : Settings.Default.AreaCVMaxLog10Area;
            YAxis.Scale.Min     = 0.0;
            YAxis.Scale.Max     = double.IsNaN(Settings.Default.AreaCVMaxCV) ? _areaCVGraphData.MaxCV * factor : Settings.Default.AreaCVMaxCV;

            AxisChange();

            var points = _areaCVGraphData.Data
                         .Select(d => new HeatMapData.TaggedPoint3D(new Point3D(d.MeanArea, d.CV * factor, d.Frequency), d))
                         .ToList();

            Items = points.Count; // Because heatmaps can't be trusted to have a consistent number of points on all monitors
            var heatMapData = new HeatMapData(points);

            HeatMapGraphPane.GraphHeatMap(this, heatMapData, 17, 2, (float)(_areaCVGraphData.MinCV * factor), (float)(_areaCVGraphData.MaxCV * factor), Settings.Default.AreaCVLogScale, 0);

            var unit = _percentage ? @"%" : string.Empty;

            if (Settings.Default.AreaCVShowMedianCV)
            {
                string text = string.Format(Resources.AreaCVHistogram2DGraphPane_UpdateGraph_Median___0_, HistogramHelper.FormatDouble(_areaCVGraphData.MedianCV * factor, _decimals) + unit);
                _lineItems[0] = AddLineItem(text, XAxis.Scale.Min, XAxis.Scale.Max, _areaCVGraphData.MedianCV * factor, _areaCVGraphData.MedianCV * factor, Color.Blue);
                CurveList.Insert(0, _lineItems[0]);
            }

            if (Settings.Default.AreaCVShowCVCutoff)
            {
                string text = string.Format(Resources.AreaCVHistogramGraphPane_UpdateGraph_Below__0____1_, Settings.Default.AreaCVCVCutoff + unit,
                                            HistogramHelper.FormatDouble(_areaCVGraphData.BelowCVCutoff * factor, _decimals) +
                                            unit);
                _lineItems[1] = AddLineItem(text, XAxis.Scale.Min, XAxis.Scale.Max, Settings.Default.AreaCVCVCutoff, Settings.Default.AreaCVCVCutoff, Color.Red);
                CurveList.Insert(0, _lineItems[1]);
            }
        }
        /// <summary>
        ///   Forces a update of the scatter plot.
        /// </summary>
        /// 
        public void UpdateGraph()
        {
            zedGraphControl.GraphPane.Title.Text = scatterplot.Title;
            zedGraphControl.GraphPane.XAxis.Title.Text = Scatterplot.XAxisTitle;
            zedGraphControl.GraphPane.YAxis.Title.Text = Scatterplot.YAxisTitle;

            classes.Clear();

            if (scatterplot.Classes != null)
            {
                if (scatterplot.Classes.Count == 0)
                {
                    zedGraphControl.GraphPane.Legend.IsVisible = false;

                    // Create space for unlabelled data
                    PointPairList list = new PointPairList(scatterplot.XAxis, scatterplot.YAxis);

                    LineItem item = new LineItem(String.Empty, list, Color.Black, SymbolType.Default);

                    item.Line.IsVisible = LinesVisible;
                    item.Symbol.Border.IsVisible = false;
                    item.Symbol.Fill = new Fill(Color.Black);

                    if (SymbolSize == 0)
                        item.Symbol.IsVisible = false;
                    else item.Symbol.Size = SymbolSize;

                    classes.Add(item);
                }
                else
                {
                    zedGraphControl.GraphPane.Legend.IsVisible = true;
                    var colors = new ColorSequenceCollection(scatterplot.Classes.Count);

                    // Create a curve item for each of the labels
                    for (int i = 0; i < scatterplot.Classes.Count; i++)
                    {
                        // retrieve the x,y pairs for the label
                        double[] x = scatterplot.Classes[i].XAxis;
                        double[] y = scatterplot.Classes[i].YAxis;
                        PointPairList list = new PointPairList(x, y);

                        LineItem item = new LineItem(scatterplot.Classes[i].Text,
                            list, colors[i], SymbolType.Default);

                        item.Line.IsVisible = LinesVisible;
                        item.Symbol.Border.IsVisible = false;
                        item.Symbol.Fill = new Fill(colors[i]);

                        if (SymbolSize == 0)
                            item.Symbol.IsVisible = false;
                        else item.Symbol.Size = SymbolSize;

                        classes.Add(item);
                    }
                }


                zedGraphControl.AxisChange();
                zedGraphControl.Invalidate();


                if (!ScaleTight)
                    zedGraphControl.ZoomPane(zedGraphControl.GraphPane, 1.1, PointF.Empty, false);
                else zedGraphControl.RestoreScale(zedGraphControl.GraphPane);
            }
        }
 public void Clear()
 {
     Data = null;
     CurveList.Clear();
     GraphObjList.Clear();
 }
Ejemplo n.º 9
0
 void clear()
 {
     CurveList.Clear();
     GraphObjList.Clear();
 }
Ejemplo n.º 10
0
        public override void UpdateGraph(bool selectionChanged)
        {
            if (!GraphSummary.DocumentUIContainer.DocumentUI.Settings.HasResults)
            {
                _areaCVGraphData = null;
                return;
            }

            var settings = new AreaCVGraphData.AreaCVGraphSettings(GraphSummary.Type);

            _document = GraphSummary.DocumentUIContainer.DocumentUI;

            var factor = AreaGraphController.GetAreaCVFactorToDecimal();

            BarSettings.Type = BarType.SortedOverlay;
            BarSettings.ClusterScaleWidth = Settings.Default.AreaCVHistogramBinWidth;
            BarSettings.MinClusterGap     = 0.0f;

            _percentage = !Settings.Default.AreaCVShowDecimals;
            _decimals   = _percentage ? 1 : 3;

            GraphObjList.Clear();
            CurveList.Clear();
            _stickItems.Clear();

            var gotData = _cache.TryGet(_document, settings, DataCallback, out _areaCVGraphData);

            if (!gotData || !_areaCVGraphData.IsValid)
            {
                return;
            }

            var fontHeight = GraphSummary.CreateFontSpec(Color.Black).GetHeight(CalcScaleFactor());
            var height     = PaneHeightToYValue(fontHeight);

            var heightFactor = 1;

            if (Settings.Default.AreaCVShowMedianCV)
            {
                var stick = AddStickItem(_areaCVGraphData.MedianCV * factor, _areaCVGraphData.MedianCV * factor, 0.0, _areaCVGraphData.MaxFrequency + heightFactor++ *height, Color.Blue);
                CurveList.Add(stick);
                _stickItems.Add(stick);
            }

            if (Settings.Default.AreaCVShowCVCutoff)
            {
                var stick = AddStickItem(Settings.Default.AreaCVCVCutoff, Settings.Default.AreaCVCVCutoff, 0.0, _areaCVGraphData.MaxFrequency + heightFactor++ *height, Color.Red);
                CurveList.Add(stick);
                _stickItems.Add(stick);
            }

            var selected = HistogramHelper.GetSelectedPeptides(GraphSummary).NodePeps.OrderBy(p => p.Id.GlobalIndex).ToList();
            var comparer = Comparer <PeptideDocNode> .Create((a, b) => a.Id.GlobalIndex.CompareTo(b.Id.GlobalIndex));

            var selectedPoints  = new PointPairList();
            var selectedPoints2 = new PointPairList();
            var otherPoints     = new PointPairList();

            foreach (var d in _areaCVGraphData.Data)
            {
                int frequency;
                var x = d.CV * factor + Settings.Default.AreaCVHistogramBinWidth / 2.0f;

                var pt = new PointPair(x, d.Frequency)
                {
                    Tag = d
                };
                if (Settings.Default.ShowReplicateSelection &&
                    (frequency = d.PeptideAnnotationPairs.Count(pair => selected.BinarySearch(pair.Peptide, comparer) >= 0)) > 0)
                {
                    selectedPoints.Add(pt);
                    selectedPoints2.Add(new PointPair(x, frequency)
                    {
                        Tag = d
                    });
                }
                else
                {
                    otherPoints.Add(pt);
                }
            }

            CurveList.Insert(0, MakeBarItem(selectedPoints2, Color.Red));
            CurveList.Insert(1, MakeBarItem(selectedPoints, Color.FromArgb(Color.Red.ToArgb() & 0x7FFFFFFF)));
            CurveList.Insert(2, MakeBarItem(otherPoints, Color.FromArgb(180, 220, 255)));

            XAxis.Title.Text = Resources.AreaCVHistogramGraphPane_UpdateGraph_CV + (_percentage ? @" (%)" : string.Empty);
            YAxis.Title.Text = Resources.AreaCVHistogramGraphPane_UpdateGraph_Frequency;

            XAxis.Scale.Min     = YAxis.Scale.Min = 0;
            XAxis.Scale.MinAuto = XAxis.Scale.MaxAuto = YAxis.Scale.MinAuto = YAxis.Scale.MaxAuto = false;

            if (!double.IsNaN(Settings.Default.AreaCVMaxCV))
            {
                XAxis.Scale.Max = Settings.Default.AreaCVMaxCV;
            }
            else
            {
                XAxis.Scale.Max = _areaCVGraphData.MaxCV * factor + Settings.Default.AreaCVHistogramBinWidth;
            }

            if (!double.IsNaN(Settings.Default.AreaCVMaxFrequency))
            {
                YAxis.Scale.Max = Settings.Default.AreaCVMaxFrequency;
            }
            else
            {
                YAxis.Scale.Max = _areaCVGraphData.MaxFrequency + heightFactor * height;
            }

            AxisChange();
        }
Ejemplo n.º 11
0
        public override void UpdateGraph(bool selectionChanged)
        {
            GraphObjList.Clear();
            CurveList.Clear();
            Legend.IsVisible = false;
            if (!DetectionPlotData.GetDataCache().TryGet(
                    GraphSummary.DocumentUIContainer.DocumentUI, Settings.QValueCutoff, this.DataCallback,
                    out _detectionData))
            {
                return;
            }

            AddLabels();
            BarSettings.Type          = BarType.SortedOverlay;
            BarSettings.MinClusterGap = 0.3f;
            Legend.IsVisible          = Settings.ShowLegend;

            var emptySymbol = new Symbol(SymbolType.None, Color.Transparent);
            //draw bars
            var counts      = TargetData.TargetsCount;
            var countPoints = new PointPairList(Enumerable.Range(0, _detectionData.ReplicateCount)
                                                .Select(i => new PointPair(i, counts[i] / YScale)).ToList());

            CurveList.Insert(0, MakeBarItem(countPoints, Color.FromArgb(180, 220, 255)));
            //draw cumulative curve
            counts = TargetData.TargetsCumulative;
            var cumulativePoints = new PointPairList(Enumerable.Range(0, _detectionData.ReplicateCount)
                                                     .Select(i => new PointPair(i, counts[i] / YScale)).ToList());

            CurveList.Insert(1,
                             new LineItem(Resources.DetectionPlotPane_CumulativeLine_Name)
            {
                Points = cumulativePoints,
                Symbol = emptySymbol,
                Line   = new Line()
                {
                    Color = Color.Coral, Width = 2
                }
            });
            //draw inclusive curve
            counts = TargetData.TargetsAll;
            var allPoints = new PointPairList(Enumerable.Range(0, _detectionData.ReplicateCount)
                                              .Select(i => new PointPair(i, counts[i] / YScale)).ToList());

            CurveList.Insert(2,
                             new LineItem(Resources.DetectionPlotPane_AllRunsLine_Name)
            {
                Symbol = emptySymbol,
                Points = allPoints,
                Line   = new Line()
                {
                    Color = Color.Black, Width = 2
                }
            });

            //axes formatting
            XAxis.Scale.Max = _detectionData.ReplicateCount + 1;
            YAxis.Scale.Max = _detectionData.GetTargetData(Settings.TargetType).MaxCount / YScale * 1.15;
            if (Settings.ShowAtLeastN)
            {
                double lineY       = TargetData.getCountForMinReplicates(Settings.RepCount);
                var    atLeastLine = new Line()
                {
                    Width = 1, Color = Color.Blue, Style = DashStyle.Dash
                };
                var dummyPoints = new PointPairList(new[] { new PointPair(0, 0) });
                var line        = new LineObj(Color.Blue, 0, lineY / YScale, XAxis.Scale.Max, lineY / YScale)
                {
                    IsClippedToChartRect = true,
                    Line = atLeastLine
                };
                GraphObjList.Add(line);

                //This is a placeholder to make sure the line shows in the legend.
                CurveList.Insert(3,
                                 new LineItem(String.Format(CultureInfo.CurrentCulture,
                                                            Resources.DetectionPlotPane_AtLeastLine_Name,
                                                            Settings.RepCount, _detectionData.ReplicateCount, lineY))
                {
                    Symbol = emptySymbol,
                    Points = dummyPoints,
                    Line   = atLeastLine
                });
            }

            if (Settings.ShowSelection)
            {
                var selectedIndex = GraphSummary.StateProvider.SelectedResultsIndex;
                var lineLength    = TargetData.TargetsCount[selectedIndex] / YScale + YAxis.Scale.Max * 0.05;
                GraphObjList.Add(
                    new LineObj(Color.Black, selectedIndex + 1, 0, selectedIndex + 1, lineLength)
                {
                    IsClippedToChartRect = true,
                    Line = new Line()
                    {
                        Width = 1, Color = Color.Black, Style = DashStyle.Dash
                    }
                });
            }

            if (Settings.ShowMean)
            {
                var stats     = new Statistics(TargetData.TargetsCount.Select((x) => (double)x));
                var labelText = String.Format(CultureInfo.CurrentCulture,
                                              TextUtil.LineSeparate(new[]
                {
                    Resources.DetectionPlotPane_Label_Mean,
                    Resources.DetectionPlotPane_Label_Stddev
                }
                                                                    ),
                                              stats.Mean(), stats.StdDev());
                GraphObjList.Add(new TextObj(labelText, 0.1, YAxis.Scale.Max,
                                             CoordType.AxisXYScale, AlignH.Left, AlignV.Top)
                {
                    IsClippedToChartRect = true,
                    ZOrder   = ZOrder.E_BehindCurves,
                    FontSpec = GraphSummary.CreateFontSpec(Color.Black),
                });
            }
        }
Ejemplo n.º 12
0
 public void Clear()
 {
     CurveList.Clear();
     GraphObjList.Clear();
 }
Ejemplo n.º 13
0
        public override void SetScale(Graphics g)
        {
            if (!ShowHeatMap || _heatMapData == null)
            {
                base.SetScale(g);
                return;
            }

            CurveList.Clear();
            XAxis.Scale.SetupScaleData(this, XAxis);
            YAxis.Scale.SetupScaleData(this, YAxis);
            double cellWidth  = Math.Abs(XAxis.Scale.ReverseTransform(MinDotRadius) - XAxis.Scale.ReverseTransform(0));
            double cellHeight = Math.Abs(YAxis.Scale.ReverseTransform(MinDotRadius) - YAxis.Scale.ReverseTransform(0));

            if (cellWidth <= 0 || double.IsNaN(cellWidth) || cellHeight <= 0 || double.IsNaN(cellHeight))
            {
                return;
            }

            // Use log scale for heat intensity.
            double scale = (_heatMapColors.Length - 1) / Math.Log(_heatMapData.MaxPoint.Z);

            // Create curves for each intensity color.
            var curves = new LineItem[_heatMapColors.Length];

            for (int i = 0; i < curves.Length; i++)
            {
                var color = _heatMapColors[i];
                curves[i] = new LineItem(string.Empty)
                {
                    Line = new Line {
                        IsVisible = false
                    },
                    Symbol = new Symbol
                    {
                        Border = new Border {
                            IsVisible = false
                        },
                        Size        = (int)(MinDotRadius + i / (double)(curves.Length - 1) * (MaxDotRadius - MinDotRadius)),
                        Fill        = new Fill(color),
                        Type        = SymbolType.Circle,
                        IsAntiAlias = true
                    }
                };
                if ((i + 1) % (_heatMapColors.Length / 4) == 0)
                {
                    double intensity = Math.Pow(Math.E, i / scale);
                    curves[i].Label.Text = intensity.ToString("F0"); // Not L10N
                }
                CurveList.Insert(0, curves[i]);
            }

            // Get points within bounds of graph/filter, with density appropriate for the current display resolution.
            var points = _heatMapData.GetPoints(
                XAxis.Scale.Min,
                XAxis.Scale.Max,
                Math.Max(YAxis.Scale.Min, _yMin),
                Math.Min(YAxis.Scale.Max, _yMax),
                cellWidth,
                cellHeight);

            foreach (var heatPoint in points)
            {
                // A log scale produces a better visual display.
                int intensity = (int)(Math.Log(heatPoint.Z) * scale);
                if (intensity >= 0)
                {
                    curves[intensity].AddPoint(heatPoint.X, heatPoint.Y);
                }
            }
        }
Ejemplo n.º 14
0
        public override void UpdateGraph(bool selectionChanged)
        {
            SrmDocument document         = !_exportMethodDlg ? GraphSummary.DocumentUIContainer.DocumentUI : Program.MainWindow.DocumentUI;
            var         windows          = ScheduleWindows;
            var         brukerTemplate   = BrukerTemplateFile;
            var         brukerMetricType = BrukerMetricType;

            // No need to re-graph for a selection change
            if (ReferenceEquals(document, _documentShowing) && ArrayUtil.EqualsDeep(windows, _windowsShowing) &&
                Equals(BrukerTemplateFile, _brukerTemplate) && Equals(BrukerMetricType, _brukerMetricType))
            {
                return;
            }

            _documentShowing  = document;
            _windowsShowing   = windows;
            _brukerTemplate   = brukerTemplate;
            _brukerMetricType = brukerMetricType;

            // TODO: Make it possible to see transition scheduling when full-scan enabled.
            if (string.IsNullOrEmpty(brukerTemplate))
            {
                XAxis.Title.Text = Resources.RTScheduleGraphPane_RTScheduleGraphPane_Scheduled_Time;
                YAxis.Title.Text = document.Settings.TransitionSettings.FullScan.IsEnabledMsMs
                    ? Resources.RTScheduleGraphPane_UpdateGraph_Concurrent_Precursors
                    : Resources.RTScheduleGraphPane_UpdateGraph_Concurrent_Transitions;
            }
            else if (BrukerMetrics == null)
            {
                XAxis.Title.Text = Resources.RTScheduleGraphPane_RTScheduleGraphPane_Scheduled_Time;
                YAxis.Title.Text = Resources.RTScheduleGraphPane_UpdateGraph_Concurrent_Accumulations;
            }
            else
            {
                switch (brukerMetricType)
                {
                case SchedulingMetrics.CONCURRENT_FRAMES:
                    XAxis.Title.Text = Resources.RTScheduleGraphPane_RTScheduleGraphPane_Scheduled_Time;
                    YAxis.Title.Text = Resources.RTScheduleGraphPane_UpdateGraph_Concurrent_frames;
                    break;

                case SchedulingMetrics.MAX_SAMPLING_TIMES:
                    XAxis.Title.Text = Resources.RTScheduleGraphPane_UpdateGraph_Target;
                    YAxis.Title.Text = Resources.RTScheduleGraphPane_UpdateGraph_Max_sampling_times;
                    break;

                case SchedulingMetrics.MEAN_SAMPLING_TIMES:
                    XAxis.Title.Text = Resources.RTScheduleGraphPane_UpdateGraph_Target;
                    YAxis.Title.Text = Resources.RTScheduleGraphPane_UpdateGraph_Mean_sampling_times;
                    break;

                case SchedulingMetrics.REDUNDANCY_OF_TARGETS:
                    XAxis.Title.Text = Resources.RTScheduleGraphPane_RTScheduleGraphPane_Scheduled_Time;
                    YAxis.Title.Text = Resources.RTScheduleGraphPane_UpdateGraph_Redundancy_of_targets;
                    break;

                case SchedulingMetrics.TARGETS_PER_FRAME:
                    XAxis.Title.Text = Resources.RTScheduleGraphPane_RTScheduleGraphPane_Scheduled_Time;
                    YAxis.Title.Text = Resources.RTScheduleGraphPane_UpdateGraph_Targets_per_frame;
                    break;
                }
            }

            CurveList.Clear();

            using (var longWait = new LongWaitDlg())
            {
                longWait.PerformWork(null, 800, progressMonitor =>
                {
                    AddCurve(document, Color.Blue, progressMonitor);
                    for (int i = 0; i < windows.Length; i++)
                    {
                        double window = windows[i];
                        // Do not show the window used by the current document twice.
                        if (window == GetSchedulingWindow(document))
                        {
                            continue;
                        }

                        var settings = document.Settings.ChangePeptidePrediction(p => p.ChangeMeasuredRTWindow(window));
                        if (settings.PeptideSettings.Prediction.RetentionTime != null)
                        {
                            settings = settings.ChangePeptidePrediction(p =>
                                                                        p.ChangeRetentionTime(p.RetentionTime.ChangeTimeWindow(window)));
                        }
                        var docWindow = document.ChangeSettings(settings);

                        AddCurve(docWindow, COLORS_WINDOW[(i + 1) % COLORS_WINDOW.Count], progressMonitor);
                    }
                });
            }

            AxisChange();
        }
Ejemplo n.º 15
0
        public override void UpdateGraph(bool selectionChanged)
        {
            CurveList.Clear();
            GraphObjList.Clear();
            SrmDocument document         = GraphSummary.DocumentUIContainer.DocumentUI;
            var         selectedTreeNode = GraphSummary.StateProvider.SelectedNode as SrmTreeNode;

            if (selectedTreeNode == null || document.FindNode(selectedTreeNode.Path) == null)
            {
                Title.Text = Helpers.PeptideToMoleculeTextMapper.Translate(Resources.MassErrorReplicateGraphPane_UpdateGraph_Select_a_peptide_to_see_the_mass_error_graph, document.DocumentType);
                EmptyGraph(document);
                return;
            }
            if (!document.Settings.HasResults)
            {
                Title.Text = Resources.AreaReplicateGraphPane_UpdateGraph_No_results_available;
                EmptyGraph(document);
                return;
            }
            DisplayTypeChrom displayType;

            if (Equals(PaneKey, PaneKey.PRECURSORS))
            {
                displayType = DisplayTypeChrom.precursors;
            }
            else if (Equals(PaneKey, PaneKey.PRODUCTS))
            {
                displayType = DisplayTypeChrom.products;
            }
            else
            {
                displayType = GraphChromatogram.GetDisplayType(document, selectedTreeNode);
            }
            Title.Text = null;
            var aggregateOp = GraphValues.AggregateOp.FromCurrentSettings();

            YAxis.Title.Text = aggregateOp.Cv
                ? aggregateOp.AnnotateTitle(Resources.MassErrorReplicateGraphPane_UpdateGraph_Mass_Error_No_Ppm)
                : Resources.MassErrorReplicateGraphPane_UpdateGraph_Mass_Error;
            DocNode      selectedNode = selectedTreeNode.Model;
            DocNode      parentNode   = selectedNode;
            IdentityPath identityPath = selectedTreeNode.Path;

            // If the selected tree node is a transition, then its siblings are displayed.
            if (selectedTreeNode is TransitionTreeNode)
            {
                if (displayType != DisplayTypeChrom.single)
                {
                    SrmTreeNode parentTreeNode = selectedTreeNode.SrmParent;
                    parentNode   = parentTreeNode.Model;
                    identityPath = parentTreeNode.Path;
                }
            }
            // If the selected node is a peptide with one child, then show the children,
            // unless chromatogram display type is total
            else if (selectedTreeNode is PeptideTreeNode)
            {
                var children = ((PeptideDocNode)selectedNode).TransitionGroups
                               .Where(PaneKey.IncludesTransitionGroup)
                               .ToArray();
                if (children.Length == 1 && displayType != DisplayTypeChrom.total)
                {
                    selectedNode = parentNode = children[0];
                    identityPath = new IdentityPath(identityPath, parentNode.Id);
                }
            }
            else if (!(selectedTreeNode is TransitionGroupTreeNode))
            {
                Title.Text = Helpers.PeptideToMoleculeTextMapper.Translate(Resources.MassErrorReplicateGraphPane_UpdateGraph_Select_a_peptide_to_see_the_mass_error_graph, document.DocumentType);
                EmptyGraph(document);
                CanShowMassErrorLegend = false;
                return;
            }
            // If a precursor is going to be displayed with display type single
            if (parentNode is TransitionGroupDocNode && displayType == DisplayTypeChrom.single)
            {
                // If no optimization data, then show all the transitions
                displayType = DisplayTypeChrom.all;
            }

            var       replicateGroupOp = ReplicateGroupOp.FromCurrentSettings(document.Settings);
            GraphData graphData        = new MassErrorGraphData(document,
                                                                identityPath,
                                                                displayType,
                                                                replicateGroupOp,
                                                                PaneKey);

            CanShowMassErrorLegend = graphData.DocNodes.Count != 0;
            InitFromData(graphData);

            int    selectedReplicateIndex = SelectedIndex;
            double minRetentionTime       = double.MaxValue;
            double maxRetentionTime       = double.MinValue;

            int iColor = 0, iCharge = -1;
            var charge                 = Adduct.EMPTY;
            int countLabelTypes        = document.Settings.PeptideSettings.Modifications.CountLabelTypes;
            int colorOffset            = 0;
            var transitionGroupDocNode = parentNode as TransitionGroupDocNode;

            if (transitionGroupDocNode != null && displayType == DisplayTypeChrom.products)
            {
                // If we are only displaying product ions, we want to use an offset in the colors array
                // so that we do not re-use colors that would be used for any precursor ions.
                colorOffset =
                    GraphChromatogram.GetDisplayTransitions(transitionGroupDocNode, DisplayTypeChrom.precursors).Count();
            }
            for (int i = 0; i < graphData.DocNodes.Count; i++)
            {
                var docNode        = graphData.DocNodes[i];
                var pointPairLists = graphData.PointPairLists[i];
                int numSteps       = pointPairLists.Count / 2;
                for (int iStep = 0; iStep < pointPairLists.Count; iStep++)
                {
                    int   step          = iStep - numSteps;
                    var   pointPairList = pointPairLists[iStep];
                    Color color;
                    // ReSharper disable ExpressionIsAlwaysNull
                    var nodeGroup = docNode as TransitionGroupDocNode;
                    if (parentNode is PeptideDocNode)
                    {
                        int iColorGroup = GetColorIndex(nodeGroup, countLabelTypes, ref charge, ref iCharge);
                        color = COLORS_GROUPS[iColorGroup % COLORS_GROUPS.Count];
                    }
                    else if (displayType == DisplayTypeChrom.total)
                    {
                        color = COLORS_GROUPS[iColor % COLORS_GROUPS.Count];
                    }
                    else if (docNode.Equals(selectedNode) && step == 0)
                    {
                        color = ChromGraphItem.ColorSelected;
                    }
                    else
                    {
                        color = COLORS_TRANSITION[(iColor + colorOffset) % COLORS_TRANSITION.Count];
                    }
                    // ReSharper restore ExpressionIsAlwaysNull
                    iColor++;

                    string label = graphData.DocNodeLabels[i];
                    if (step != 0)
                    {
                        label = string.Format(Resources.RTReplicateGraphPane_UpdateGraph_Step__0__, step);
                    }
                    BarItem curveItem = new MeanErrorBarItem(label, pointPairList, color, Color.Black);

                    if (selectedReplicateIndex != -1 && selectedReplicateIndex < pointPairList.Count)
                    {
                        PointPair pointPair = pointPairList[selectedReplicateIndex];
                        if (!pointPair.IsInvalid)
                        {
                            minRetentionTime = Math.Min(minRetentionTime, pointPair.Y);
                            maxRetentionTime = Math.Max(maxRetentionTime, pointPair.Y);
                        }
                    }

                    curveItem.Bar.Border.IsVisible = false;
                    curveItem.Bar.Fill.Brush       = new SolidBrush(color);
                    curveItem.Tag = new IdentityPath(identityPath, docNode.Id);
                    CurveList.Add(curveItem);
                }
            }

            // Draw a box around the currently selected replicate
            if (ShowSelection && minRetentionTime != double.MaxValue)
            {
                maxRetentionTime = Math.Max(maxRetentionTime, 0);
                minRetentionTime = Math.Min(minRetentionTime, 0);
                GraphObjList.Add(new BoxObj(selectedReplicateIndex + .5, maxRetentionTime, 1,
                                            maxRetentionTime - minRetentionTime, Color.Black, Color.Empty)
                {
                    IsClippedToChartRect = true,
                });
            }

            XAxis.Scale.MinAuto = XAxis.Scale.MaxAuto = selectionChanged;
            YAxis.Scale.MinAuto = YAxis.Scale.MaxAuto = true;
            if (Settings.Default.MinMassError != 0)
            {
                YAxis.Scale.Min = Settings.Default.MinMassError;
            }
            if (Settings.Default.MaxMassError != 0)
            {
                YAxis.Scale.Max = Settings.Default.MaxMassError;
            }
            Legend.IsVisible = Settings.Default.ShowMassErrorLegend;
            AxisChange();
        }
Ejemplo n.º 16
0
 public void Clear()
 {
     CurveList.Clear();
     m_HasChanged = true;
 }