Using CrossGraphs to Display NONMEM Table Output
Last Updated: 3 April 2012
Information about CrossGraphs can found at the PPDInformatics web page.
In order to make the nmcg command work you must have the DOS environment variable CGHOME defined. This can be done
by changing the set CGHOME line in wfn.bat:
rem ******* Other Software
rem If you use Crossgraphs then set CGHOME
Replace c:\belmont with the full path to the cgwww.exe file if CrossGraphs is installed somewhere else.
Thanks to help from Jeremy Poole (CrossGraphs technical support) the process of creating files suitable for displaying graphs created by Crossgraphs has been automated. If you have a NONMEM table file in the run directory then you can use the nmcg batch command file to create a Crossgraphs descriptor file (runname.dsc), a Crossgraphs binary data file (runname.bin) and several Crossgraphs design files (fit.dsn, pred.dsn, ipred.dsn, res.dsn and wres.dsn). The nmcg command is used as follows:
If you open Crossgraphs and select one of these design files in the run directory you can then Execute the design and see graphs of individual fits, prediction vs observation plots and residual plots.
nmcg assumes that you include
certain named variables in the NONMEM table file:
ID Identifies the individual subject
TIME The independent variable
Y The individual ("post hoc") prediction
DV The dependent variable
PRED The population prediction
RES The unweighted residual
WRES The weighted residual
If you have used different names for these items in your table file then CrossGraphs will prompt you for the corresponding variable name e.g. if you have a model with DOSE as the independent variable you will be prompted for this name if you do not have a variable named TIME in your NONMEM table file.
If you use IPRED
for the individual prediction this is saved with the name IPRE in the NONMEM
table file and CrossGraphs will prompt you for a
variable name to use for "Y". You should select IPRE from the list.
Note that this works for the fit.dsn but will not work for ipred.dsn because a
derived variable in ipred.dsn that assumes the variable name Y is in the NONMEM
table file. In this case you can edit the NONMEM table file to change the field
name IPRE to Y and re-run nmcg. You can also
add the Y variable to future $TABLE output records and put this assignment in
your $ERROR block after you have defined IPRED:
This will let nmcg work as it was designed without requiring special intervention.
Once you have created the runname.bin file nmgo will refresh it automatically if you re-run the model again. You do not have to run nmcg more than once for any run which has created a NONMEM table file. When the refresh happens you will see the Crossgraphs application briefly flash across your screen as nmgo comes to an end.
From Windows Explorer DSN Files
In the File Manager, under the View menu, choose Folder Options. In the dialog that comes up, select the File Types tab. Click on the New Type button. In the next dialog, fill in a description (e.g. "CrossGraphs design file") and specify .dsn as the default extension for the Content Type. Below the Actions list, click the New button. Add an action and application (modify this, if necessary, to reflect where you actually have CrossGraphs, and the cgwww.exe executable, installed):
Application: c:\belmont\cgwww.exe /d
Click OK. Then click the Set Default button.
Click New again, and now define another pair:
Application: c:\belmont\cgwww.exe /r
Click OK and then click OK again to close the Folder Options dialog. With luck, you should now have associated .dsn files with running CrossGraphs on them. If you double click on a .dsn file, it should start CrossGraphs and open the design. If you right-click on the .dsn file and then choose "display", it should start CrossGraphs, open the design, and display its report.
The following instructions describe how to create a Crossgraphs binary file using the Crossgraphs program. This should be unnecessary if you use nmcg. If you do not use nmcg you probably want to run the nmdsc batch file to create a Crossgraphs descriptor file from the NONMEM table output file.
Goto Start Programs Belmont Crossgraphs. The tricky part is getting your NONMEM table file output into CG format. When WFN finishes it creates a description file with the extension .dsc in the run sub-directory containing the table file. Lets call the table file "2cpt.tbl" and the description file "2cpt.dsc".
1. Click on Data
2. Click on Datasets Add
3. Search for the 2cpt run directory eg. 2cpt.wc, change Files of Type to "All Files (*.*)", and Open 2cpt.tbl
4. Click on OK when the path and filename appear on the next screen in the ASCII File name field.
5. Open the 2cpt.dsc file when prompted for a Description file.
6. A square cursor will appear on the blank New Datasource screen. Click anywhere on the blank part and a dataset icon will appear. Click on OK.
7. A Save Datasource (.bin) File dialog will open. Enter a name e.g 2cpt.bin and click Save.
8. The Crossgraphs Design Window will then open.
9. Click on File Open Existing Design and try loading the attached fit.dsn file.
10. Use the file dialog to Open the 2cpt.bin file.
11. It is assumed that the NONMEM Table File has ID, TIME, Y, DV, PRED, RES, WRES fields. Y is the individual prediction produced by FOCE or the POSTHOC option. Use the Variable Substitution dialog as necessary to match the names in your NONMEM output table with those corresponding to those expected by the Design file.
12. The Design Window will then have its blank spaces filled out.
13. Click on Execute Display Report on Screen... and you will see the observations, IPRED and PRED values plotted.
14. Click on Format to change plot properties eg Axes to set limits or choose logarithmic scale.
15. If you close the Report window and return to the Design window then double-click on the middle lower right box with a scatter graph icon on it you can play around with other properties e.g. choose the X and Y variables and set colour, symbols, line types etc.
Steps 1 to 7 are
tedious because you have to do this with every new NONMEM output table you
produce. But after that any special design features you want to apply to the
data are easy to save for particular problems you are investigating.
Note that if you recreate a NONMEM output table for an existing design you only have to use the Data Refresh Design's Datasource option. This will automatically perform the equivalent of steps 1-7.
There are CG dsn files in the %wfnhome%\bin directory for plotting IPRED vs DV (ipred.dsn), PRED vs DV (pred.dsn), PRED vs RES (res.dsn) and PRED vs WRES (wres.dsn). These are copied to the run directory and refer to the datasource bin file as runname.bin. If you use runname.bin for the *.bin file requested in step 7 you can use these dsn files to look at graphs of the results. Use Crossgraphs to open the dsn files in the run directory.