From 763fc841bf19385b5c6d70df6b9f029b89511c5e Mon Sep 17 00:00:00 2001 From: RitaCh Date: Thu, 22 Aug 2024 15:55:20 -0700 Subject: [PATCH 1/2] Fixes to the Relative Abundance graph formatting --- .../SummaryRelativeAbundanceGraphPane.cs | 21 ++++++++++++--- .../Skyline/Properties/Settings.Designer.cs | 11 ++++++++ .../Skyline/Properties/Settings.settings | 3 +++ pwiz_tools/Skyline/Skyline.Designer.cs | 10 +++++++ pwiz_tools/Skyline/Skyline.resx | 12 +++++++++ pwiz_tools/Skyline/SkylineGraphs.cs | 27 +++++++++++++++++-- pwiz_tools/Skyline/app.config | 3 +++ 7 files changed, 82 insertions(+), 5 deletions(-) diff --git a/pwiz_tools/Skyline/Controls/Graphs/SummaryRelativeAbundanceGraphPane.cs b/pwiz_tools/Skyline/Controls/Graphs/SummaryRelativeAbundanceGraphPane.cs index 2b6e1428b27..e6df5e583ec 100644 --- a/pwiz_tools/Skyline/Controls/Graphs/SummaryRelativeAbundanceGraphPane.cs +++ b/pwiz_tools/Skyline/Controls/Graphs/SummaryRelativeAbundanceGraphPane.cs @@ -219,16 +219,21 @@ public override void UpdateGraph(bool selectionChanged) var document = GraphSummary.DocumentUIContainer.DocumentUI; var graphSettings = GraphSettings.FromSettings(); + var aggregateOp = GraphValues.AggregateOp.FromCurrentSettings(); // Only create graph data (and recalculate abundances) // if settings have changed, the document has changed, or if it // is not yet created + var dataChanged = false; if (_graphData?.GraphPointList == null || !ReferenceEquals(document, _graphData.Document) || - !Equals(graphSettings, _graphData.GraphSettings)) + !Equals(graphSettings, _graphData.GraphSettings) || + !Equals(_graphData.AggregateOp, aggregateOp)) { _graphData = CreateGraphData(document, graphSettings); + dataChanged = true; } + // Calculate y values and order which can change based on the // replicate display option or the show CV option _graphData.CalcDataPositions(GraphSummary.ResultsIndex, selectedProtein); @@ -278,7 +283,8 @@ public override void UpdateGraph(bool selectionChanged) } } AddPoints(new PointPairList(unmatchedPoints), Color.Gray, DotPlotUtil.PointSizeToFloat(PointSize.normal), false, PointSymbol.Circle); - UpdateAxes(); + if(dataChanged || Settings.Default.RelativeAbundanceLogScale != YAxis.Scale.IsLog) + UpdateAxes(); if (Settings.Default.GroupComparisonAvoidLabelOverlap) AdjustLabelSpacings(_labeledPoints, GraphSummary.GraphControl); else @@ -357,7 +363,14 @@ protected virtual void UpdateAxes() YAxis.Scale.MinAuto = true; XAxis.Scale.MaxAuto = true; XAxis.Scale.MinAuto = true; - if (Settings.Default.AreaLogScale ) + + if (CurveList.First() is LineItem curve) + { + // if markers are overlapping leave a little space between the X axis and the first marker + if(curve.Symbol.Size * _graphData.PointPairList.Count > Chart.Rect.Width) + XAxis.Scale.Min = -(_graphData.PointPairList.Last().X - _graphData.PointPairList.First().X) * 0.02; + } + if (Settings.Default.RelativeAbundanceLogScale ) { YAxis.Title.Text = TextUtil.SpaceSeparate(GraphsResources.SummaryPeptideGraphPane_UpdateAxes_Log, YAxis.Title.Text); YAxis.Type = AxisType.Log; @@ -436,6 +449,7 @@ protected GraphData(SrmDocument document, GraphSettings graphSettings) { Document = document; GraphSettings = graphSettings; + AggregateOp = GraphValues.AggregateOp.FromCurrentSettings(); var schema = SkylineDataSchema.MemoryDataSchema(document, SkylineDataSchema.GetLocalizedSchemaLocalizer()); bool anyMolecules = document.HasSmallMolecules; // Build the list of points to show. @@ -475,6 +489,7 @@ protected GraphData(SrmDocument document, GraphSettings graphSettings) public SrmDocument Document { get; } public GraphSettings GraphSettings { get; } + public GraphValues.AggregateOp AggregateOp { get; } public void CalcDataPositions(int iResult, PeptideGroupDocNode selectedProtein) { diff --git a/pwiz_tools/Skyline/Properties/Settings.Designer.cs b/pwiz_tools/Skyline/Properties/Settings.Designer.cs index 5503677e624..0aaaa1c644f 100644 --- a/pwiz_tools/Skyline/Properties/Settings.Designer.cs +++ b/pwiz_tools/Skyline/Properties/Settings.Designer.cs @@ -3541,5 +3541,16 @@ public bool GroupComparisonSuspendLabelLayout this["GroupComparisonSuspendLabelLayout"] = value; } } + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool RelativeAbundanceLogScale { + get { + return ((bool)(this["RelativeAbundanceLogScale"])); + } + set { + this["RelativeAbundanceLogScale"] = value; + } + } } } diff --git a/pwiz_tools/Skyline/Properties/Settings.settings b/pwiz_tools/Skyline/Properties/Settings.settings index 90423083425..eda47554c17 100644 --- a/pwiz_tools/Skyline/Properties/Settings.settings +++ b/pwiz_tools/Skyline/Properties/Settings.settings @@ -884,5 +884,8 @@ False + + True + \ No newline at end of file diff --git a/pwiz_tools/Skyline/Skyline.Designer.cs b/pwiz_tools/Skyline/Skyline.Designer.cs index b056de9948c..895ff36b20f 100644 --- a/pwiz_tools/Skyline/Skyline.Designer.cs +++ b/pwiz_tools/Skyline/Skyline.Designer.cs @@ -171,6 +171,7 @@ private void InitializeComponent() this.showLibraryPeakAreaContextMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.showDotProductToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.peptideLogScaleContextMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.relativeAbundanceLogScaleContextMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.peptideCvsContextMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator28 = new System.Windows.Forms.ToolStripSeparator(); this.areaPropsContextMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -1145,6 +1146,7 @@ private void InitializeComponent() this.showLibraryPeakAreaContextMenuItem, this.showDotProductToolStripMenuItem, this.peptideLogScaleContextMenuItem, + this.relativeAbundanceLogScaleContextMenuItem, this.peptideCvsContextMenuItem, this.toolStripSeparator28, this.areaPropsContextMenuItem, @@ -1339,6 +1341,13 @@ private void InitializeComponent() resources.ApplyResources(this.peptideLogScaleContextMenuItem, "peptideLogScaleContextMenuItem"); this.peptideLogScaleContextMenuItem.Click += new System.EventHandler(this.peptideLogScaleContextMenuItem_Click); // + // relativeAbundanceLogScaleContextMenuItem + // + this.relativeAbundanceLogScaleContextMenuItem.CheckOnClick = true; + this.relativeAbundanceLogScaleContextMenuItem.Name = "relativeAbundanceLogScaleContextMenuItem"; + resources.ApplyResources(this.relativeAbundanceLogScaleContextMenuItem, "relativeAbundanceLogScaleContextMenuItem"); + this.relativeAbundanceLogScaleContextMenuItem.Click += new System.EventHandler(this.relativeAbundanceLogScaleContextMenuItem_Click); + // // peptideCvsContextMenuItem // this.peptideCvsContextMenuItem.CheckOnClick = true; @@ -2762,6 +2771,7 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripMenuItem areaRelativeAbundanceContextMenuItem; private System.Windows.Forms.ToolStripMenuItem areaNormalizeContextMenuItem; private System.Windows.Forms.ToolStripMenuItem peptideLogScaleContextMenuItem; + private System.Windows.Forms.ToolStripMenuItem relativeAbundanceLogScaleContextMenuItem; private System.Windows.Forms.ToolStripMenuItem peptideOrderContextMenuItem; private System.Windows.Forms.ToolStripMenuItem peptideOrderDocumentContextMenuItem; private System.Windows.Forms.ToolStripMenuItem peptideOrderRTContextMenuItem; diff --git a/pwiz_tools/Skyline/Skyline.resx b/pwiz_tools/Skyline/Skyline.resx index 6cff999da83..cee01214c8c 100644 --- a/pwiz_tools/Skyline/Skyline.resx +++ b/pwiz_tools/Skyline/Skyline.resx @@ -923,6 +923,12 @@ Log Scale + + 209, 22 + + + Log Scale + 209, 22 @@ -2967,6 +2973,12 @@ System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + relativeAbundanceLogScaleContextMenuItem + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + peptideLogScaleContextMenuItem diff --git a/pwiz_tools/Skyline/SkylineGraphs.cs b/pwiz_tools/Skyline/SkylineGraphs.cs index 33c613ae30e..f687990283f 100644 --- a/pwiz_tools/Skyline/SkylineGraphs.cs +++ b/pwiz_tools/Skyline/SkylineGraphs.cs @@ -3918,8 +3918,16 @@ private void BuildAreaGraphMenu(GraphSummary graphSummary, ToolStrip menuStrip, peptideCvsContextMenuItem.Checked = set.ShowPeptideCV; } - menuStrip.Items.Insert(iInsert++, peptideLogScaleContextMenuItem); - peptideLogScaleContextMenuItem.Checked = set.AreaLogScale; + if (graphType != GraphTypeSummary.abundance) + { + menuStrip.Items.Insert(iInsert++, peptideLogScaleContextMenuItem); + peptideLogScaleContextMenuItem.Checked = set.AreaLogScale; + } + else + { + menuStrip.Items.Insert(iInsert++, relativeAbundanceLogScaleContextMenuItem); + relativeAbundanceLogScaleContextMenuItem.Checked = set.RelativeAbundanceLogScale; + } selectionContextMenuItem.Checked = set.ShowReplicateSelection; menuStrip.Items.Insert(iInsert++, selectionContextMenuItem); if (graphType == GraphTypeSummary.abundance) @@ -4636,6 +4644,17 @@ public void ShowPeptideLogScale(bool isChecked) UpdateSummaryGraphs(); } + private void relativeAbundanceLogScaleContextMenuItem_Click(object sender, EventArgs e) + { + ShowRelativeAbundanceLogScale(relativeAbundanceLogScaleContextMenuItem.Checked); + } + + public void ShowRelativeAbundanceLogScale(bool isChecked) + { + Settings.Default.RelativeAbundanceLogScale = isChecked ; + UpdateRelativeAbundanceGraphs(); + } + private void peptideCvsContextMenuItem_Click(object sender, EventArgs e) { ShowCVValues(peptideCvsContextMenuItem.Checked); @@ -4764,6 +4783,10 @@ public void UpdatePeakAreaGraph() _listGraphPeakArea.ForEach(g => g.UpdateUI()); } + public void UpdateRelativeAbundanceGraphs() + { + _listGraphPeakArea.FindAll(g => g.Type == GraphTypeSummary.abundance).ForEach(g => g.UpdateUI()); + } private void UpdateSummaryGraphs() { UpdateRetentionTimeGraph(); diff --git a/pwiz_tools/Skyline/app.config b/pwiz_tools/Skyline/app.config index 068b562b037..ca305829542 100644 --- a/pwiz_tools/Skyline/app.config +++ b/pwiz_tools/Skyline/app.config @@ -873,6 +873,9 @@ True + + True + From 4dec04beae3770883ba648a349d1392557a00ad0 Mon Sep 17 00:00:00 2001 From: RitaCh Date: Wed, 11 Sep 2024 21:17:52 -0700 Subject: [PATCH 2/2] Test failure fix and code review comment addressed --- .../Controls/Graphs/SummaryRelativeAbundanceGraphPane.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pwiz_tools/Skyline/Controls/Graphs/SummaryRelativeAbundanceGraphPane.cs b/pwiz_tools/Skyline/Controls/Graphs/SummaryRelativeAbundanceGraphPane.cs index e6df5e583ec..95d7340bb06 100644 --- a/pwiz_tools/Skyline/Controls/Graphs/SummaryRelativeAbundanceGraphPane.cs +++ b/pwiz_tools/Skyline/Controls/Graphs/SummaryRelativeAbundanceGraphPane.cs @@ -225,18 +225,19 @@ public override void UpdateGraph(bool selectionChanged) // if settings have changed, the document has changed, or if it // is not yet created var dataChanged = false; + var oldGraphData = _graphData; if (_graphData?.GraphPointList == null || !ReferenceEquals(document, _graphData.Document) || !Equals(graphSettings, _graphData.GraphSettings) || !Equals(_graphData.AggregateOp, aggregateOp)) { _graphData = CreateGraphData(document, graphSettings); - dataChanged = true; } // Calculate y values and order which can change based on the // replicate display option or the show CV option _graphData.CalcDataPositions(GraphSummary.ResultsIndex, selectedProtein); + dataChanged = _graphData.MinY != oldGraphData?.MinY || _graphData.MaxY != oldGraphData?.MaxY; // For proper z-order, add the selected points, then the matched points, then the unmatched points var selectedPoints = new PointPairList(); @@ -364,7 +365,7 @@ protected virtual void UpdateAxes() XAxis.Scale.MaxAuto = true; XAxis.Scale.MinAuto = true; - if (CurveList.First() is LineItem curve) + if (CurveList.FirstOrDefault() is LineItem curve) { // if markers are overlapping leave a little space between the X axis and the first marker if(curve.Symbol.Size * _graphData.PointPairList.Count > Chart.Rect.Width)