Skip to content

Commit

Permalink
Skyline: First draft automation of screenshots for two more tutorials (
Browse files Browse the repository at this point in the history
…#3247)

* Skyline: First draft automation of screenshots for two more tutorials
CEOptimizationTutorialTest and DriftTimePredictorTutorialTest
  • Loading branch information
brendanx67 authored Nov 28, 2024
1 parent 011166e commit 14db3eb
Show file tree
Hide file tree
Showing 10 changed files with 143 additions and 74 deletions.
113 changes: 68 additions & 45 deletions pwiz_tools/Skyline/Controls/Graphs/AreaReplicateGraphPane.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,12 @@ protected override int FirstDataIndex

public bool DotProductLabelsVisible
{
get{return CanShowDotProduct && DotProductDisplayOption.label.IsSet(Settings.Default);}
get { return CanShowDotProduct && DotProductDisplayOption.label.IsSet(Settings.Default); }
}

public bool DotProductLineVisible
{
get { return CanShowDotProduct && DotProductDisplayOption.line.IsSet(Settings.Default); }
}

public bool IsLineGraph
Expand Down Expand Up @@ -668,6 +673,8 @@ public override void UpdateGraph(bool selectionChanged)
Y2Axis.Scale.Min = 0;
Y2Axis.Scale.Max = 1.1;
Y2Axis.Title.Text = DotpLabelText;
Y2Axis.MajorTic.IsOpposite = false;
Y2Axis.MinorTic.IsOpposite = false;
var dotpLine = new LineItem(DotpLabelText, graphData.DotpData, Color.DimGray, SymbolType.Circle )
{
IsY2Axis = true, Line = new Line() { Style = DashStyle.Dash, Color = Color.DimGray, Width = 2.0f},
Expand All @@ -682,49 +689,58 @@ public override void UpdateGraph(bool selectionChanged)
Y2Axis.IsVisible = false;
}

UpdateAxes(resetAxes, aggregateOp, dataScalingOption, normalizeOption);
AddDotProductLine(graphData);

if (Settings.Default.PeakAreaDotpCutoffShow && DotProductDisplayOption.line.IsSet(Settings.Default) && _dotpData != null)
{
var cutoff = ExpectedVisible.GetDotpValueCutoff(Settings.Default);
var highlightValues = new PointPairList(graphData.DotpData.Select(point => point.Y < cutoff ? point : new PointPair(){X = point.X, Y = float.NaN}).ToList());
var cutoffHighlightLine = new LineItem("", highlightValues, Color.DimGray, SymbolType.Circle)
{
IsY2Axis = true,
Line = new Line() { Color = Color.Transparent},
Symbol = new Symbol() { Type = SymbolType.Diamond, Size = 9f, Fill = new Fill(Color.Red), Border = new Border(Color.Red, 1) }
};
cutoffHighlightLine.Label.IsVisible = false;
CurveList.Insert(Math.Min(CurveList.Count, 1), cutoffHighlightLine); // Add below cutoff highlight markers
ToolTip.TargetCurves.Add(cutoffHighlightLine);
UpdateAxes(resetAxes, aggregateOp, dataScalingOption, normalizeOption);
}

private void AddDotProductLine(AreaGraphData graphData)
{
if (!Settings.Default.PeakAreaDotpCutoffShow || !DotProductDisplayOption.line.IsSet(Settings.Default) ||
_dotpData == null)
return;

var belowCutoffCount = _dotpData.Count(dotp => dotp <= cutoff);
var labelText = string.Format(GraphsResources.AreaReplicateGraphPane_Replicates_Count_Above_Below_Cutoff,
_dotpData.Count - belowCutoffCount, belowCutoffCount, DotpLabelText);
var labelObject = new TextObj(labelText, 1, 0, CoordType.ChartFraction, AlignH.Right, AlignV.Top)
{
IsClippedToChartRect = true,
ZOrder = ZOrder.E_BehindCurves,
FontSpec = GraphSummary.CreateFontSpec(Color.Black),
};
labelObject.FontSpec.Fill = new Fill(Color.Transparent);
GraphObjList.Add(labelObject);
var cutoffLine = new LineObj()
{
IsClippedToChartRect = true,
Location = new Location(0, cutoff, CoordType.XChartFractionY2Scale){Rect = new RectangleF(0, cutoff, 1, 0)},
Line = new LineBase(Color.Red)
};
GraphObjList.Add(cutoffLine); // Add cutoff line
//This is a placeholder to make sure the line shows in the legend.
CurveList.Insert(0, new LineItem(string.Format(CultureInfo.CurrentCulture,
GraphsResources.AreaReplicateGraphPane_Dotp_Cutoff_Line_Label, DotpLabelText, cutoff))
{
Points = new PointPairList(new[] { new PointPair(0, 0) }),
Symbol = new Symbol(SymbolType.None, Color.Transparent)
});
}
var cutoff = ExpectedVisible.GetDotpValueCutoff(Settings.Default);
var highlightValues = new PointPairList(graphData.DotpData
.Select(point => point.Y < cutoff ? point : new PointPair() { X = point.X, Y = float.NaN }).ToList());
var cutoffHighlightLine = new LineItem("", highlightValues, Color.DimGray, SymbolType.Circle)
{
IsY2Axis = true,
Line = new Line() { Color = Color.Transparent },
Symbol = new Symbol()
{ Type = SymbolType.Diamond, Size = 9f, Fill = new Fill(Color.Red), Border = new Border(Color.Red, 1) }
};
cutoffHighlightLine.Label.IsVisible = false;
CurveList.Insert(Math.Min(CurveList.Count, 1), cutoffHighlightLine); // Add below cutoff highlight markers
ToolTip.TargetCurves.Add(cutoffHighlightLine);

var belowCutoffCount = _dotpData.Count(dotp => dotp <= cutoff);
var labelText = string.Format(GraphsResources.AreaReplicateGraphPane_Replicates_Count_Above_Below_Cutoff,
_dotpData.Count - belowCutoffCount, belowCutoffCount, DotpLabelText);
var labelObject = new TextObj(labelText, 1, 0, CoordType.ChartFraction, AlignH.Right, AlignV.Top)
{
IsClippedToChartRect = true,
ZOrder = ZOrder.E_BehindCurves,
FontSpec = GraphSummary.CreateFontSpec(Color.Black),
};
labelObject.FontSpec.Fill = new Fill(Color.Transparent);
GraphObjList.Add(labelObject);
_labelHeight = (int)labelObject.FontSpec.GetHeight(CalcScaleFactor());
var cutoffLine = new LineObj()
{
IsClippedToChartRect = true,
Location = new Location(0, cutoff, CoordType.XChartFractionY2Scale)
{ Rect = new RectangleF(0, cutoff, 1, 0) },
Line = new LineBase(Color.Red)
};
GraphObjList.Add(cutoffLine); // Add cutoff line
//This is a placeholder to make sure the line shows in the legend.
CurveList.Insert(0, new LineItem(string.Format(CultureInfo.CurrentCulture,
GraphsResources.AreaReplicateGraphPane_Dotp_Cutoff_Line_Label, DotpLabelText, cutoff))
{
Points = new PointPairList(new[] { new PointPair(0, 0) }),
Symbol = new Symbol(SymbolType.None, Color.Transparent)
});
}

public override void PopulateTooltip(int index, CurveItem targetCurve)
Expand Down Expand Up @@ -952,9 +968,11 @@ private void UpdateAxes(bool resetAxes, GraphValues.AggregateOp aggregateOp, Dat

// Reformat Y-Axis for labels and whiskers
var maxY = GraphHelper.GetMaxY(CurveList,this);
if (DotProductLabelsVisible)
if (DotProductLabelsVisible || DotProductLineVisible)
{
var extraSpace = _labelHeight*(maxY/(Chart.Rect.Height - _labelHeight*2))*2;
var reservedSpace = _labelHeight * 2;
var unitsPerPixel = maxY / (Chart.Rect.Height - reservedSpace);
var extraSpace = reservedSpace*unitsPerPixel;
maxY += extraSpace;
}

Expand Down Expand Up @@ -1019,6 +1037,7 @@ private void AddDotProductLabels(Graphics g, TransitionGroupDocNode nodeGroup, I
foreach (GraphObj pa in _dotpLabels)
GraphObjList.Remove(pa);
_dotpLabels.Clear();
_labelHeight = 0;

if (visible)
{
Expand All @@ -1042,7 +1061,9 @@ private void AddDotProductLabels(Graphics g, TransitionGroupDocNode nodeGroup, I
textObj.FontSpec.Border.IsVisible = false;
textObj.FontSpec.Size = pointSize.Value;
textObj.FontSpec.Fill = new Fill(Color.Transparent);
_labelHeight =(int) textObj.FontSpec.GetHeight(CalcScaleFactor());
var labelHeight = (int) textObj.FontSpec.GetHeight(CalcScaleFactor());
if (labelHeight > _labelHeight)
_labelHeight = labelHeight;
GraphObjList.Add(textObj);
_dotpLabels.Add(textObj);
}
Expand All @@ -1068,7 +1089,9 @@ private string GetDotProductResultsText(int indexResult)
{
if (_dotpData?.Count > 0 && indexResult < _dotpData.Count && !float.IsNaN(_dotpData[indexResult]))
{
var separator = DotProductDisplayOption.line.IsSet(Settings.Default) ? (Func<IEnumerable<string>, string>)TextUtil.SpaceSeparate : TextUtil.LineSeparate;
var separator = DotProductDisplayOption.line.IsSet(Settings.Default)
? (Func<IEnumerable<string>, string>)TextUtil.SpaceSeparate
: TextUtil.LineSeparate;
return separator(new [] { DotpLabelText , string.Format(@"{0:F02}", _dotpData[indexResult]) } ) ;
}
else
Expand Down
11 changes: 8 additions & 3 deletions pwiz_tools/Skyline/Controls/Graphs/GraphChromatogram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ public void UnlockZoom()

public PointF TransformCoordinates(double x, double y, PaneKey? paneKey, CoordType coordType = CoordType.AxisXYScale)
{
var graphPane = _graphHelper.GetGraphPane(paneKey ?? PaneKey.DEFAULT);
var graphPane = GetGraphPane(paneKey);
return graphPane.GeneralTransform(new PointF((float)x, (float)y), coordType);
}

Expand Down Expand Up @@ -1626,7 +1626,7 @@ private void DisplayTransitions(AlignmentFunction timeRegressionFunction,
iColor++;
}

var graphPane = _graphHelper.GetGraphPane(graphPaneKey);
var graphPane = GetGraphPane(graphPaneKey);
if (graphPane == null)
_enableTrackingDot = false;
if (_enableTrackingDot)
Expand Down Expand Up @@ -3534,7 +3534,7 @@ public void TestMouseDown(double x, double y, PaneKey? paneKey)

public string TestFullScanSelection(double x, double y, PaneKey? paneKey)
{
var graphPane = _graphHelper.GetGraphPane(paneKey ?? PaneKey.DEFAULT);
var graphPane = GetGraphPane(paneKey);
var selectionDot = graphPane.CurveList[FULLSCAN_SELECTED_INDEX];
var mouse = TransformCoordinates(x, y, paneKey);
var dot = TransformCoordinates(selectionDot[0].X, selectionDot[0].Y, paneKey);
Expand All @@ -3546,6 +3546,11 @@ public string TestFullScanSelection(double x, double y, PaneKey? paneKey)
return string.Empty;
}

public GraphPane GetGraphPane(PaneKey? paneKey)
{
return _graphHelper.GetGraphPane(paneKey ?? PaneKey.DEFAULT);
}

#endregion Test support
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ <h2>Creating Optimization Methods</h2>
something like the following for your OptimizeCE folder:
</p>
<p>
<img src="s-05.png" />
<img src="s-file-explorer.png" />
</p>
<p>
If you open one of the CSV files in Excel, it should contain a transition list like the one below, with 9 columns in the order precursor m/z,
Expand Down Expand Up @@ -490,7 +490,7 @@ <h2>Analyzing Optimization Data</h2>
Once the data is loaded, Skyline should look something like this:
</p>
<p>
<img src="s-06.png" />
<img src="s-05.png" />
</p>
<p>
The red bar in the middle of the <b>Peak Areas</b> view and the red curve among the chromatograms is the measurement for the
Expand All @@ -517,7 +517,7 @@ <h2>Analyzing Optimization Data</h2>
but not that bad.
</p>
<p>
<img src="s-07.png" />
<img src="s-06.png" />
</p>
<p>
For this tutorial, however, remove this peptide before calculating the new equation for the Thermo TSQ Vantage.
Expand Down Expand Up @@ -562,7 +562,7 @@ <h2>Creating a New Equation for CE</h2>
Skyline will present the following graphs:
</p>
<p>
<img src="s-08.png" />
<img src="s-07.png" />
</p>
<p>
The points correlate very well to the new linear equation, and appear to be on average 3-4 volts below the CE values chosen by the default
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 14db3eb

Please sign in to comment.