Automated Reporting of nlmixr2 Fit Results in Word and PowerPoint

By John Harrold in Word PowerPoint Reporting nlmixr2rpt

December 6, 2022

I’m happy to announce the initial release of nlmixr2rpt: a package designed to automate reporting of nlmixr2 results to Word and PowerPoint. The nlmixr2rpt package is attempting to save you time on the back-end of your analysis so you can focus on the analysis itself. There are three main issues we are attempting to address:

  • Interoperability: While I am personally a fan of LaTeX, corporations tend to favor Word and PowerPoint. If the files coming out of our workflows are the same type used in the corporate setting, we can work better within an organization.

  • Reducing tedium: At any point if you wish to share results you would need to copy and paste information from figures and csv files into report documents.

  • Reproducibility: Manually creating Office documents with tweaks here and there is difficult to QC and difficult to replicate in a regulatory environment.

But how does it work?

Lets say you have an nlmixr2 fit object like the one found in nlmixr2extra:

fit = nlmixr2extra::theoFitOde

The first thing you need to do is create an onbrand report object. Here we will create one for PowerPoint:

obnd_pptx = read_template(
  template = system.file(package="nlmixr2rpt", "templates","nlmixr_obnd_template.pptx"),
  mapping  = system.file(package="nlmixr2rpt", "templates","nlmixr_obnd_template.yaml"))

This uses the onbrand templates from the nlmxir2rpt package, but you could create custom templates for your organization. You add any report information you might want (e.g. a title slide, overview of methods etc.). Once your done you can then append the fit results:

obnd_pptx = report_fit(
  fit     = fit, 
  obnd    = obnd_pptx)

Now you could further append slides and when you’re read you could write the report to a file:

save_report(obnd_pptx, "report.pptx")
## $isgood
## [1] TRUE
## $msgs

The work flow is similar for Word reports. You simply create an onbrand object from a Word template, and then save it to a docx file.

How does nlmixr2rpt know what to do?

The contents of the report and their arrangement is controlled by a customizable YAML file. You can create a copy of that file and use it as a starting point for automating your own workflows:

file.copy(system.file(package="nlmixr2rpt", "templates", "report_fit.yaml"), 

There is a vignette that describes the format of that YAML file in detail but at a high level there are sections where figures and tables are defined. This is where you would create the code to say build out your observed vs predicted figure. Any packages you would normally use (xpose.nlmixr2, ggPMX, etc.) can be used here. You can construct these generically with placeholders that can be defined in the YAML file and overwritten when generating the report.

This way you can create a template for specific types of analyses. Say when you run a Population PK analysis you create essentially the same set of figures and tables at each iteration. You could create a YAML file for PopPK. Then a separate YAML file for exposure-response, etc. Then these can be tweaked during the analysis as needed.

The next sections are where you tell nlmixr2rpt how use those reporting elements in Word and PowerPoint. This just takes ids you define in the previous sections for tables and figures and inserts them into the document being generated.

But how do I…

  • use my own organizational template?
  • change the figures and tables that are reported?
  • use the figures and tables being generated outside of reporting?

Try the pkgdown website and see if that has answers.

What about this…

  • this question that isn’t addressed at the link above?
  • really important feature that is missing?
  • this cryptic error I keep getting?

Go to the GitHub issues page and create a new issue.

Posted on:
December 6, 2022
3 minute read, 604 words
Word PowerPoint Reporting nlmixr2rpt
nlmixr2rpt Word PowerPoint
See Also: