Averaging 2 rows

When we are running samples, we always run 2 samples of each and have a strict naming convention where they are always named "SAMPLENAME-A" and "SAMPLENAME-B".  Is there a way to have the average of selected values in "-A" and "-B" be displayed?  We often run 10 or more samples, each with "-A" and "-B" versions.  

I use Custom Calculator values for many of the values.

 

I am not worried about how the values are displayed.  I would prefer that they are displayed inline after each sample pair (as displayed on the image), but they can also be displayed after the total sample run in it's own table.

 

CURRENTLY:

 

DESIRED DISPLAY:

 

While I am a programmer comfortable with PHP, I am not well versed with VB, and not sure how to work within the confines of the console.

Parents
  • Hello,

     

    You can use a CCF to do the calculation. I would start by splitting up the name as shown below in SampleNameT. Then you can use that separated name to group your injections both in CC and IR. Then you can use an expression like PeakAve, to get the average by compound across the duplicate injections where the name before the - matches. You can replace compound amount with compound concentration or any other peak variable in that expression.  You can also replace it with something like GetDoubleCC("CC20") where the name in "" is another peakorgroup CC.

     

    CStr(Split(Sample_Name, "-")(0))

     

     CurrentSequence.AllPeaksAndGroups.Where(function (x) x.Injection.Sample.Sample_Type = 3) .Where(function (x) x.Injection.GetStringCC("SampleNameT") = CurrentInjection.GetStringCC("SampleNameT")).Where(function (x) x.Compound_Name = CurrentPeakOrGroup.Compound_Name).Select(function(x) x.Compound_Amount).Average

     

     

     

     

  • Martin,

    I have run into one more problem.  In order to display the compound as a percentage, I also need to get the average of another field, but this one is a custom field("Sample Weight/g").  I tried using the same query that you created to get the average of the peaks and changing the query, but it does not seem to be working.  Below are a few iterations of your code that I modified that are failing at the "select" statement.  Do you know how I can get the average of the Custom Field "Sample Weight/g" for the same variable "SampleNameT"?

    CurrentSequence.AllPeaksAndGroups.Where(function (x) x.Injection.Sample.Sample_Type = 3) .Where(function (x) x.Injection.GetStringCC("SampleNameT") = CurrentInjection.GetStringCC("SampleNameT")).Where(function (x) x.Compound_Name = CurrentPeakOrGroup.Compound_Name).Select(function(x) x.GetCustomField("Sample Weight/g")).Average

    I also tried

    CurrentSequence.AllPeaksAndGroups.Where(function (x) x.Injection.Sample.Sample_Type = 3) .Where(function (x) x.Injection.GetStringCC("SampleNameT") = CurrentInjection.GetStringCC("SampleNameT")).Where(function (x) x.Compound_Name = CurrentPeakOrGroup.Compound_Name).Select(function(x) x.Injection.GetStringCC("Sample Weight/g")).Average

    In both cases, the Custom Calculator Editor gives me the same error: "BC30516: 'Average' doesn't accept this number of arguments"

    I also tried creating a CC named "Sample_Wgt" with a CCF of " CurrentSample.GetCustomField("Sample Weight/g")" and then plugging that into the above query, but that only grabs the value for the current injection:

    CurrentSequence.AllPeaksAndGroups.Where(function (x) x.Injection.Sample.Sample_Type = 3) .Where(function (x) x.Injection.GetStringCC("SampleNameT") = CurrentInjection.GetStringCC("SampleNameT")).Where(function (x) x.Compound_Name = CurrentPeakOrGroup.Compound_Name).Select(function(x) Sample_Wgt).Average.  

  • My little pea brain is still having a problem with this one.  Any advice you can give would be appreciated.

Reply Children
  • Hello,

    Setup a another CC as below. Replace CC7 with a name of your choice and "Number" with Sample Weight/g. Then you should be able to use the CC below

    CurrentSequence.AllPeaksAndGroups.Where(function (x) x.Injection.Sample.Sample_Type = 3) .Where(function (x) x.Injection.GetStringCC("SampleNameT") = CurrentInjection.GetStringCC("SampleNameT")).Where(function (x) x.Compound_Name = CurrentPeakOrGroup.Compound_Name).Select(function(x) x.Injection.GetDoubleCC("CC7")).Average

Was this helpful?