Using Quant, how do I average properties like RT, area, and ion ratio?

Setup: I have a 1260 with auto sampler feeding a 6495 using 7.0 for acquisition and data analysis.

Goal: Average properties like RT, Area, and ion ratio for successive injections using Quantitative Analysis.

Example: From the following injection sequence, I'd like to calculate the average and standard deviation of the RT, peak area response, and ion ratio between my target and qualifier ions for the Precision and Low/Med/High Accuracy sample groups. I can do this with Excel by exporting a CSV but I'd rather set up a Quant method and PDF reporting to perform this to minimize the amount of data interpretation.

 

How do I average properties of successive injections?

 

23 JUN 2020 Edit: It looks like there is the ability to run scripts and expressions as part of the report builder using Python for .NET; Are there any examples available of expressions or scripts that I can use to write my own? Nothing comes up immediately when I searched.

I did find the Report Builder Familiarization guide available here. Is there anything else describing the types of variables that are available or any sort of debugging environment?

 

 

InjectionDescription

Nominal

Concentration

Sample

Group

1

Blank

0Blanks
2Precision 1100Precision
3Precision 2100Precision
4Precision 3100Precision
5Precision 4100Precision
6Precision 5100Precision
7Precision 6100Precision
8Precision 7100Precision
9

Precision 8

100Precision
10Precision 9100Precision
11Blank0Blanks
12Accuracy 150Accuracy Low
13Accuracy 250Accuracy Low
14Accuracy 350Accuracy Low
15Blank0Blanks
16Accuracy 4100Accuracy Med
17Accuracy 5100Accuracy Med
18Accuracy 6100Accuracy Med
19Blank0Blanks
20Accuracy 7150Accuracy High
21Accuracy 8150Accuracy High
22Accuracy 9150Accuracy High
23Blank0Blanks
24Linearity 115Linearity
25

Linearity 2

30Linearity
26Linearity 345Linearity
27Linearity 460Linearity
28Linearity 575Linearity
29Linearity 690Linearity
30Linearity 7105Linearity
31Linearity 8120Linearity
32Linearity 9135Linearity
34Linearity 10150Linearity
35Blank0Blanks
Parents
  • Hi,

     

    a

    If you're interested in direct PDF reporting with Python you might find this custom report I made some time ago interesting. This report calculates average, SD, RSD and variance for each component area. You could modify the template to perform calculations you require.

     

    For expressions in PDF Rerporting Tool it is best to check shipping templates or ask specific questions in this forum. There are few questions already asked and answered related to the script box in the past.

    attachments.zip
  • The *.zip file is password protected and cannot be extracted without the password. Can you share that with me?

  • Ah, try our atandard 3000hanover and let me know if that does not work.

  • Thanks , that password worked to unlock the zip file. One down...

     

    After running your script I get an error that RepositoryRevisionNumber isn't there. Digging through the XML, I found reference to it in 53-55 of BatchInfo.py. After commenting those lines out, I get the included pdf so success on that front.

     

    I'm using B.08 and the example you gave is using 10; my first guess is that DataProvider.BatchAttributes has RepositoryRevisionNumber in 10 but not in B.08. I'd inspect the variables via Visual Studio to validate this but when I start DepugPythonReporting.py with a break at line 53 of BatchInfo.py I get the following error:

     

    Error: Unknown command line parameter - QuantReportMethodRun.exe

    Per the reporting developer's guide and comments on this forum I'm using VS 2015 w/ Python tools and IronPython 2.7.5. I don't normally use VS so I may have missed something during setup of the debugger.

     

    I added the following as my script path which is where I suppose the error originates:

     

    QuantReportMethodRun.exe –BP=C:\MassHunter\Data\QuantExamples\QQQ\DrugsOfAbuse\QuantResults\ –BF=DrugsOfAbuseDemo.batch.bin -M=C:\Users\User\Documents\Test Scripts for Quant\QualityMetrics\test_method_please_ignore.m –OP=C:\Users\User\Documents\Test Scripts for Quant\Temp

    DebugPythonReporting.py looks like it's pointing correctly:

    import clr
    import sys

    import System

    # append quant path
    # modify path if necessary
    sys.path.append(
    "C:\\Program Files\\Agilent\\MassHunter\\Workstation\\Quant\\bin")

    # add debug dll path
    sys.path.append(
    System.IO.Path.GetDirectoryName(System.IO.Path.GetDirectoryName(__file__)))

    # load debug tool
    clr.AddReference("QuantDebugTools")

    import Agilent
    # run
    Agilent.MassSpectrometry.DataAnalysis.Quantitative.DebugTools.RunPython.RunReport(sys.argv[1:])

    I can also see QuantReportMethodRun.exe in C:\Program Files\Agilent\MassHunter\Workstation\Quant\bin.

     

    Any thoughts on what I'm missing for my debugger setup?

  • Hi ,

     

    I tested this with my MH Quant 10 and it is working. As you're using older software version I would just copy 'QualityMetrics.report.xml' and 'Codes\QualityMetrics.py' files to your default direct report template folder '\MassHunter\Report Templates\Quant\PDF-Reporting'. These are only files that have been modified.

     

    Regarding VS, unfortunately I can't help you at that topic as I don't have it installed and am unable to reproduce the error. In this case we may get report template to work without it as file generating the error was not modified and so older versions may be used.

     

    Hope this helps and you should be good when you get the report generated.

Reply
  • Hi ,

     

    I tested this with my MH Quant 10 and it is working. As you're using older software version I would just copy 'QualityMetrics.report.xml' and 'Codes\QualityMetrics.py' files to your default direct report template folder '\MassHunter\Report Templates\Quant\PDF-Reporting'. These are only files that have been modified.

     

    Regarding VS, unfortunately I can't help you at that topic as I don't have it installed and am unable to reproduce the error. In this case we may get report template to work without it as file generating the error was not modified and so older versions may be used.

     

    Hope this helps and you should be good when you get the report generated.

Children
  •  

    Updating from hypen to forward slash in the script argument fixed the issue; spaces are also bad/weird probably because of the way most .NET programs use CommandLineToArgvW. New Script Arguments reads as:

    /BatchPath=C:\temp\ /BatchFile=DrugsOfAbuseDemo.batch.bin /Method=C:\temp\test_method_please_ignore.m /OutputPath=C:\temp\report

    New error: 

    Error: Batch file 'DrugsOfAbuseDemo.batch.bin' does not exist
    Press any key to continue . . .

    The file is clearly there. Specifying full path for /BatchFile fixes this. New script argument reads as:

    /BatchPath=C:\temp\ /BatchFile=C:\temp\DrugsOfAbuseDemo.batch.bin /Method=C:\temp\test_method_please_ignore.m /OutputPath=C:\temp\report

    And I can suddenly browse variables in debug mode!

     

    Thank you both!

  • In the following for loop I would expect to set the full set of column names for each variable by each sample.

    for sample in DataProvider.SelectSamples("", ""):
       table.AddCell(sample.SampleGroup)

    The PDF DataSet Column Labels Reference says there's a column called SampleGroup. Instead I get an error:

    The value for column 'SampleGroup' in table 'Batch' is DBNull.

    When I add a break at the for loop, the debugger indicates there is no SampleGroup variable name.

     

    Basically, I've gone through the drugs of abuse dataset and added arbitrary sample groupings to different injections. I'd like to recover their attributes by groupings. How do I do this?

  • ,

     

    I don't do much report/script coding myself (the examples I provided were from a colleague) but in general I can suggest a few things to try.

     

    First if you really do just want to work on samples that are in a group, try filtering only for those. There are examples of this in the RSD07.py file I posted.

     

    for sample in DataProvider.SelectSamples("SampleGroup<>''","AcqDateTime"):
     if sample is not None:

        ...

     

    In general be aware that most of the methods used in reporting and scripting do not tolerate null entries, so you need to check for those yourself, as in the example above.

     

    Another thing you could try if you really want to go through all rows looking for groups is checking to see if the group is null. Most variables have a IsVariableNameNull() method that returns a boolean. There are examples in the reporting reference manual on how to use these, such as this one that checks for a dilution entry

     

    table.AddCell("" if sample.IsDilutionNull() else DataProvider.FormatNumber("Dilution",sample.Dilution))

Was this helpful?