I need help with a percent difference custom field

I have the following scenario:

label spl name inj
A Asy1 1 Avg Amount Percent Difference Amount
A Asy1 2
A Asy2 1 Avg Amount
A Asy2 2
B Asy1 1 Avg Amount Percent Difference Amount
B Asy1 2
B Asy2 1 Avg Amount
B Asy2 2

I would like a custom field to calculate the average amount of the duplicate assay injections.
Then I would like a custom field to calculate the percent difference of the average amount for each set of assays.

Best Answer

  • Accepted Answer
    If you used Area instead of Amount, then at least it calculated correctly since you tested it. To edit it for Amount, just copy and paste the formula to Wordpad, replace Area with Amount, and paste them back into the translation table. I don't see any difficulties with your average amount custom field SAME.%..AVE(Amount) since you have different labels for each sample but check my post above for issues with Amount. 

    All depends on your bracket standard set-up. Using sliding with overlap may be an issue. Using Average of standards throughout run will work. You will have to test that. 

Answers

  • For the average amount of duplicate assay injections, create a peak, real, calculated CF, result set only, sample and peak type All. Formula is SAME.%..AVE(Amount) and make sure you have the function "Summarize Custom Fields" as the last line in sample set before processing. Then label the first set of Asy 1 injections as for example A, the second set B, then for Asy 2 first set C second set D. The custom field will calculate the average amount for all injections of samples with the same label. So make sure each set of Assy gets a unique label. 

    As for percent difference, what do you mean? How are you calculating this? 
  • Thank you for your reply.
    For each lot/batch we do two assay preps (Asy1 & Asy 2)  I would like to have the same label for these.  Is that possible?

    For the percent difference. I would like to get a percent difference between the average amount from Asy1 and Asy2.  
    (ABS(avgamount(asy1)-avgamount(asy2))/ AVE(avgamount of asy1&asy2) X 100

    Thanks for the help
  • edited March 17
    Hi. Yes, for the 2 assay preps per lot, you can label all injections of Asy1 as A and all injections of Asy2 as B. Then the SAME.%..AVE(Amount) will average the amount for all the As and all the Bs to give you two results. Problem is this custom field wont "relate" back to the labels A and B when calculating % Difference, so if you code a CF as your formula for % Difference and reference SAME.%..AVE(Amount), you end up with the same value subtracted from itself, divided by half of itself, so there is no way to ask it to only take into account the As and Bs. 

    Another way is to create 2 CFs as A.%..AVE(Amount) and B.%..AVE(Amount) and call them Avr_A and Avr_B. Then a 3rd peak, real CF search order Result Set Only, all peak and sample type. Formula is:

    ABS((Avr_A-Avr_B))/((0.5*(Avr_A+Avr_B)))*100 and this will give you a % Difference value. But the drawback is you are limited to A and B so if you running several batches of assay you may need a lot of CFs or to combine them into one long formula. 

    Another way to make it easier is to use the report method to calculate the average amount per batch, so an All Peaks Table filtered by Label = "X" and a summary function of average against all the Amounts. 

    Then you just need one CF Peak, Real, Calculated:

    ABS(((A.%..AVE(Amount))-(B.%..AVE(Amount))))/((0.5*((A.%..AVE(Amount))+(B.%..AVE(Amount)))*100
  • Hmmmm.......
    If there is no way to have it correlate back to the  labels, then there in lies the rub.  A sample set could have anywhere from 1 to 20 batches.  If we went back to your original thought and had each Assay a different label, could it be correlated that then?
  • No, using the original idea of a different label will still only give one result per label for SAME.%..AVE(Amount) so if asking Empower to subtract this value from itself, it only has one value to look to, and that's the current value. Its not going to subtract B from A, and then on down to C from B etc. 

    There is another way around it but its a long formula. I cant see any other way. You could keep SAME.%..AVE(Amount) for the average off all Assay 1, Assay 2, Assay 3 etc. Then for % Difference, taking into account the worst case of 20 batches:

    Create a Peak, Enumerated CF Search Order Result Set Only. All Samples and Peak Type. Set the "Use as" to Field. Lets say 20 batches in a sample set. Assay 1 injections are labelled U1, Assay 2 Injections are labelled U2 all the way to Assay 20 injections labelled as U20. Presuming you want to calculate the percent Diff between Assay 1 and Assay 2 then between Assay 2 and Assay 3 etc (if its only % Diff between 1 and 2, then 3 and 4, then 5 and 6 etc adjust the formula as appropriate), for the formula for the CF put in:

    ENUM(EQ(Label,"U2"),EQ(Label,"U3"),EQ(Label,"U4")….EQ(Label,"U20")) and for the translation table you get a list of integers starting with 0 down to 19. So 0 corresponds to the first argument (ie anywhere where Label = U2), 1 corresponds to the second argument (ie anywhere where Label = U3 and on to argument 19 corresponding to Label = U20), so for position 0 the formula you type in is:

    ABS(((U1.%..AVE(Amount))-(U2.%..AVE(Amount))))/((0.5*((U1.%..AVE(Amount))+(U2.%..AVE(Amount)))*100 (fc) then position 1 becomes:

    ABS(((U2.%..AVE(Amount))-(U3.%..AVE(Amount))))/((0.5*((U2.%..AVE(Amount))+(U3.%..AVE(Amount)))*100 (fc) all the way down to position 19. 


    An easy way to do this is to type in the formula in Wordpad for position 0 then just copy and paste into the different translations from 1 to 19, only changing the U2, U3 parts etc of the formula. Its critical you add a space and then (fc) after each formula. Only that way will Empower return it as a calculated custom field. 


    You can only set the precision of this CF once so set it to whatever you want, eg 3 decimal places. Also note that you cant do anything further with this CF, like get an average of the tabulated values. However, it should work for what you are trying to do and even if you have 40 batches you just run a second sample set of U1 to U20. Good luck. 
  • Thank you very much I would have never figured this one out.  I will test this out.
  • No problem. You may have to edit the formula a bit to get the brackets right, Empower is very dependant on brackets. But I have used those CFs a lot of the type Average Area A - Average Area B/0.5*(Average Area A + Average Area B)*100 so I know that they work, you just need to test the formula against some example data.
  • Yes I will test it with some data sometime in the next couple of days and get back to you how it worked.
  • Just to add I tested the following CF for 3 injections of A followed by 3 injections of B and it worked fine. So copy the syntax as I have it for your translation table but tailor it for U1, U2 etc:

    ABS((A.%..AVE(Area)-B.%..AVE(Area)))/((0.5*((A.%..AVE(Area))+B.%..AVE(Area))))*100 (fc)
  • Hi , I tried a similar approach for another calculation for duplicate injections in standards :

    (S0101.1.(Area)-S0101.2.(Area))/((S0101.1.(Area)+S0101.2.(Area))/2)*100 (fc)

    This works fine but a similar approach for unknowns and average amount :

    (U0101.1.(Amount)-U0102.1.(Amount))/((U0101.1.(Amount)+U0102.1.(Amount))/2)*100 (fc)

    returns a value of 200

    ENUM(EQ(Label,"S0101"),EQ(Label,"S0201"),EQ(Label,"S0301"),EQ(Label,"U0101"),EQ(Label,"U0102"),EQ(Label,"U0103"),EQ(Label,"U0104"))

    any thoughts thanks

  • sorry not average,  % difference
  • Simple things first- is the Sample and Peak Type for the CF set to all? So as to include both Standards and Unknowns? 

    I have had problems with intersample CFs before with Amount, and I think its linked to how Empower calculates Amount and how you do your standard bracketing routine. If you run standards throughout the sample set, building one overall calibration curve to quantitate all unknowns, it isn't a problem as only one curve is associated with the sample set and processing method.

    But if you do sliding with or without overlap,jumping back and forth between building calibration curves, clearing the same ones, then building half of the previously cleared curve for the next set of unknowns, you essentially require two standards to get an amount and the second standard hasn't been acquired yet and you are asking Empower to jump forward a step to get the right calibration curve for that amount so I think that screws up the syntax and you get odd results like 200. I had a lot of trouble with this when I was looking for average amount for a batch of samples that split over 2 calibration curves ie 10 samples, 6 injections between bracket standards so 4 on a different bracket and it wouldn't work at all. Only works when either you have all the required labels of unknowns in the same bracket or if you run one calibration curve and quantify all unknowns off that. 


    Another thing, if you don't have the above issue, is double check your syntax and naming of the custom field. maybe call the CF X_PercentDiff so the Capital X will work only after all fields with the previous letters have been stored. If this doesn't work, might be worth two ENUM CFs one for all the Standard labels and one for Unknown labels but only if the previous calibration set-up isn't an issue for you.
  • Hello Empower2019

    I labeled every Assay with a different label Spl1 Asy1 +A1, Spl1 Asy2 = A2, Spl2 Asy1 = A3, Spl2 Asy2 = A4 and so on.  I expanded your equation 30 that will give me 15 total lots/batches of assays in one run.

    The ave amount calculation works great.  And the percent difference calculation works great as well.  However I just realized that the equation I put into the translation was   ABS((A1.%..AVE(Area)-A2.%..AVE(Area)))/((0.5*((A1.%..AVE(Area))+A2.%..AVE(Area))))*100 (fc) 

    I used AREA by accident and not AMOUNT.  However I did test it and it works fine.  it did give me the percent difference of the average amount.  Any thoughts?
Sign In or Register to comment.