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; }
public void moveBarsToBack() { CurveList.Move(0, 999); var points = new PointPairList(); Objects.each(Objects.sort(dateParent.dates()), time => points.Add(new XDate(time).XLDate, 0.0)); var line = new LineItem("", points, Color.Black, SymbolType.None) { Line = { IsVisible = false }, Symbol = { IsVisible = false }, Label = { IsVisible = false } }; CurveList.Insert(0, line); }
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(); }
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), }); } }
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); } } }