Issue 877: "How Skyline Calculates Peak Areas and Heights" tip could use updating

issues
Status:open
Assigned To:Brendan MacLean
Type:Defect
Area:Skyline
Priority:3
Milestone:4.3
Opened:2022-02-22 11:32 by Brian Pratt
Changed:2022-02-22 14:57 by Brian Pratt
Resolved:
Resolution:
Closed:
2022-02-22 11:32 Brian Pratt
Title»"How Skyline Calculates Peak Areas and Heights" tip could use updating
Assigned To»Brendan MacLean
Type»Defect
Area»Skyline
Priority»3
(This came up during a Skyline training session)

The Tip ends with "Note: with v1.4 patch 1 and higher the light blue areas are not included in the background area."

Probably this text can be dropped now, though just dropping it makes the blue areas somewhat mysterious. Perhaps it would be better to alter the image to visually tag the areas that *are* included in the background value and say something about those instead. See attached suggested image.
 
 revised.png

2022-02-22 14:25 Brendan MacLean
Notify»Nick Shulman
I am not sure the revised image is correct. It may be more desirable, but I am not positive it is what Crawpeaks does. The original images has a different interpretation, where each point is max(intensity, background), whereas the new interpretation would calculate the full trapezoid minus the triangle above the background.

It could be that I got this wrong on the original image. Though, I know I was reading the Crawpeaks code at the time.

Nick, can you have a look and let us know which you think is correct? Is CrawPeaks calculating trapezoidal areas using max(intensity, background), or is it calculating the full trapezoid minus the triangle above the background, which would require calculating the length of the time edge at the brackground crossing-point. Since, the first is simpler, I am guessing it may actually be what CrawPeaks does.

2022-02-22 14:40 Brian Pratt
I'm certainly not sure it's correct either.

My logic was just that if we're saying some specific areas aren't included then it probably follows that the rest of the area is, but it was just a guess.

2022-02-22 14:52 Nick Shulman
The raw area and the background area are calculated in FoundPeak.cs:
https://github.com/ProteoWizard/pwiz/blob/master/pwiz_tools/Shared/Common/PeakFinding/FoundPeak.cs
            float rawArea = GetAreaUnderCurve(intensitiesToSum);
            float backgroundArea = GetAreaUnderCurve(intensitiesToSum.Select(intensity => Math.Min(backgroundLevel, intensity)));
and then the transition peak area that Skyline reports is the rawArea minus the backgroundArea.

Note that when you are calculating the integral, the only difference that rectangles versus trapezoids makes is in how the two points at the ends of the range are treated. The way the internal points along the integral get summed is the same for trapezoids and rectangles. In the implementation of "GetAreaUnderCurve", the first and last intensities get divided by 2, which I think means that it's the equivalent to using trapezoids.

I do not think there's anything incorrect in the new picture, but I'm not sure that I understand what the issue might be.

2022-02-22 14:57 Brian Pratt
It's all in reference to
https://skyline.ms/wiki/home/software/Skyline/page.view?name=tip_peak_calc&_docid=wiki%3A2649fe02-28ae-1030-b663-5d0a05bcf5f8

During a Skyline training, folks were looking at it and it just seemed a bit confusing since it was trying to straddle a change that was made a long time ago and no longer matters.