예제 #1
0
 public AreaCVHistogram2DGraphPane(GraphSummary graphSummary)
     : base(graphSummary)
 {
     _areaCVGraphData = null;
     _lineItems       = new LineItem[2];
     _cache           = new AreaCVGraphData.AreaCVGraphDataCache();
 }
예제 #2
0
 public AreaCVGraphDataStatistics(AreaCVGraphData data, int items)
 {
     DataCount     = data.Data.Count;
     Items         = items;
     MinMeanArea   = data.MinMeanArea;
     MaxMeanArea   = data.MaxMeanArea;
     Total         = data.Total;
     MaxCV         = data.MaxCV;
     MinCV         = data.MinCV;
     MaxFrequency  = data.MaxFrequency;
     MedianCV      = data.MedianCV;
     MeanCV        = data.MeanCV;
     BelowCVCutoff = data.BelowCVCutoff;
 }
예제 #3
0
            private AreaCVGraphData CreateOrGet(GraphDataProperties properties)
            {
                var result = Get(properties);

                if (result == null)
                {
                    SrmDocument         document;
                    AreaCVGraphSettings settings;
                    lock (_cacheInfo)
                    {
                        document = _cacheInfo.Document;
                        settings = _cacheInfo.Settings;
                    }

                    result = new AreaCVGraphData(document,
                                                 new AreaCVGraphSettings(settings.GraphType,
                                                                         properties.NormalizationMethod,
                                                                         properties.RatioIndex,
                                                                         settings.Group,
                                                                         properties.Annotation,
                                                                         settings.PointsType,
                                                                         settings.QValueCutoff,
                                                                         settings.CVCutoff,
                                                                         properties.MinimumDetections,
                                                                         settings.BinWidth,
                                                                         settings.MsLevel,
                                                                         settings.Transitions,
                                                                         settings.CountTransitions), _tokenSource.Token);

                    lock (_cacheInfo)
                    {
                        if (IsValidFor(document, settings))
                        {
                            _cacheInfo.Data.Add(result);
                        }
                    }
                }

                return(result);
            }
예제 #4
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]);
            }
        }
예제 #5
0
 private void DataCallback(AreaCVGraphData data)
 {
     GraphSummary.GraphControl.BeginInvoke((Action)(() => { GraphSummary.UpdateUI(); }));
 }
예제 #6
0
            public bool TryGet(SrmDocument document, AreaCVGraphSettings settings, Action <AreaCVGraphData> callback, out AreaCVGraphData result)
            {
                var properties = new GraphDataProperties(settings);

                if (!IsValidFor(document, settings))
                {
                    Cancel();

                    lock (_cacheInfo)
                    {
                        _cacheInfo.Clear();
                        _cacheInfo.Document = document;
                        _cacheInfo.Settings = settings;
                    }

                    // Get a list of all properties that we want to cache data for, except for the data that just got requested
                    var propertyList = new List <GraphDataProperties>(GetPropertyVariants(settings).Except(new[] { properties }));
                    _producerConsumer.Add(propertyList, false, false);
                }


                result = Get(properties);
                if (result != null)
                {
                    return(true);
                }

                lock (_requestLock)
                {
                    if (!properties.Equals((object)_requested))
                    {
                        _producerConsumer.Add(properties);

                        _requested = properties;
                        _callback  = callback;
                    }

                    return(false);
                }
            }
예제 #7
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();
        }