Exemple #1
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]);
            }
        }
        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();
        }