A question was asked on the Agilent community forum “How can I automatically find the retention time of the largest peak by area percentage?”.
Here’s an example of using Agilent OpenLab CDS custom calculation engine to find the retention time of the largest peak for each injection. There are probably other solutions, but this shows the use of aggregating functions and the use of LINQ, a Microsoft technology that integrates query capabilities into programming languages, and more helpfully, into OpenLab CDS Custom Calculation Engine.
Finding the largest area percentage is relatively easy. First, we need to determine the scope of this calculation. If the data contains only one signal, the scope could be Injection, otherwise we may need to perform this calculation for each Signal.
Having decided on the scope and added an Identifier and Display name, we will employ the Max() function to determine the largest peak area. This function, according to the OpenLab Help and Learning, takes two arguments: Max(“FieldName or CCName”, object list)
In this case, the field name is Peak_AreaPercent and the object list is the collection of all peaks in this injection CurrentInjection.AllPeaks. The first calculation is
Max(“Peak_AreaPercent”, CurrentInjection.AllPeaks)
That’s the first part of the calculation. Next, we can add a second calculation with the same scope to this calculation file.
In this new calculation we will use this MaxPeakArea variable to query this collection of peaks to find the retention time of the corresponding peak. Starting with the collection of peaks in CurrentInjection.AllPeaks we will use the LINQ filter Where(). In the OpenLab Help and Learning, this function takes two arguments: InputList.Where(Function(x) predicate), the predicate being the particular value we wish to compare. The first part of the formula becomes
CurrentInjection.AllPeaks.Where(Function(p) p.Peak_AreaPercent = MaxAreaPercent)
This formula will return a collection of peaks where the area percentage matches the value calculated using the previous formula. We now need to select a single peak and return its retention time. Since the list is likely only to contain a single peak, we can use the First() selector to pick the first value. The complete formula becomes:
CurrentInjection.AllPeaks.Where(Function(p) p.Peak_AreaPercent = MaxAreaPercent).First().Peak_RetentionTime
Those two calculations in the same custom calculation file will give results like those shown below in the summary section of the OpenLab Injection Results window:
I’ll post more examples of custom calculations and OpenLab Intelligent reporting templates as I come across interesting examples.