Module 2: Data Wrangling and Visualization in Julia (Exercises)

Author

Jessica Wojciechowski

1 Module Introduction and Objectives

The target audience are pharmacometricians with experience in the R programming and statistical language and familiar with dataset preparation and exploratory data analysis in pharmacometrics. The Module makes reference to similarities and differences to R and builds on the concepts described in Module 1: Introduction to Julia.

The concepts and Julia packages showcased in this Module are:

All output DataFrames have been converted for presentation purposes using SummaryTables.jl.

1.1 Objectives

The objectives of the Module 2 exercises are to:

  1. Perform an exploratory data analysis on an example dataset and re-create the figures and tables presented using Julia
  2. Bonus Challenge: translate your existing analysis code for exploratory data analysis and data summaries from R (or current programming language) to Julia

The exercises are designed to be challenging and require reference to the Module materials and package documentation.

2 Exercise Setup

To obtain the example analysis dataset for all exercises, the PharmaDatasets package needs to be loaded. This is not the only package required to complete the exercises and you will need to load any additional packages.

# Load the PharmaDatasets package
using PharmaDatasets

The example analysis dataset can be obtained by:

# Load the warfarin dataset
warfarin_df = dataset("pumas/warfarin_nonmem")

3 Summary Table of Demographics

Generate a summary table of the analysis population that appears as below:

Characteristic Total (n = 32)
Age (years)
Mean (SD) 31.0 (10.5)
Median (Min, Max) 27.5 (21.0, 63.0)
Missing (%) 0 (0.00)
Body Weight (kg)
Mean (SD) 70.0 (12.7)
Median (Min, Max) 71.7 (40.0, 102.)
Missing (%) 0 (0.00)
Sex; n (%)
F 5 (15.6)
M 27 (84.4)
Female 0 (0.00)
Male 0 (0.00)
Missing 0 (0.00)
Note

The aesthetics of the example table is only for presentation purposes only.

4 Summary of Observations Over Time

Create a numerical summary (mean and 90% confidence interval) of pharmacokinetic [PK] (dvid = 1) and pharmacodynamic [PD] (dvid = 2) observations over time, stratified by sex:

43×8 DataFrame
18 rows omitted
Row sex dvid time nid mean_val sd_val lo90_val hi90_val
Cat… String Float64 Int64 Float64 Float64 Float64 Float64
1 F Warfarin Concentration (mg/L) 0.5 1 0.0 NaN NaN NaN
2 F Warfarin Concentration (mg/L) 1.0 2 4.65 2.75772 -1.04397 10.344
3 F Warfarin Concentration (mg/L) 2.0 1 11.6 NaN NaN NaN
4 F Warfarin Concentration (mg/L) 3.0 5 12.14 0.912688 11.3175 12.9625
5 F Warfarin Concentration (mg/L) 6.0 5 12.0 0.556776 11.4983 12.5017
6 F Warfarin Concentration (mg/L) 9.0 5 11.46 1.58209 10.0343 12.8857
7 F Warfarin Concentration (mg/L) 12.0 3 10.4 1.4 8.4978 12.3022
8 F Warfarin Concentration (mg/L) 24.0 5 7.66 1.29923 6.48919 8.83081
9 F Warfarin Concentration (mg/L) 36.0 5 6.38 1.97028 4.60447 8.15553
10 F Warfarin Concentration (mg/L) 48.0 5 4.7 1.9975 2.89994 6.50006
11 F Warfarin Concentration (mg/L) 72.0 5 3.46 1.53721 2.07474 4.84526
12 F Warfarin Concentration (mg/L) 96.0 5 1.98 1.11669 0.973686 2.98631
13 F Warfarin Concentration (mg/L) 120.0 3 1.8 0.6245 0.951483 2.64852
32 M Warfarin Concentration (mg/L) 48.0 27 6.13333 1.32346 5.69951 6.56716
33 M Warfarin Concentration (mg/L) 72.0 27 4.26667 1.08238 3.91187 4.62147
34 M Warfarin Concentration (mg/L) 96.0 26 3.06923 0.761981 2.81435 3.32411
35 M Warfarin Concentration (mg/L) 120.0 26 2.19615 0.619342 1.98898 2.40332
36 M Prothrombin Complex Activity 0.0 26 97.1154 5.42827 95.2996 98.9311
37 M Prothrombin Complex Activity 24.0 27 37.4074 6.13476 35.3964 39.4184
38 M Prothrombin Complex Activity 36.0 27 24.4074 4.10684 23.0612 25.7536
39 M Prothrombin Complex Activity 48.0 27 19.1481 4.40021 17.7058 20.5905
40 M Prothrombin Complex Activity 72.0 26 20.4231 6.34459 18.3008 22.5453
41 M Prothrombin Complex Activity 96.0 26 25.5385 11.1937 21.7942 29.2827
42 M Prothrombin Complex Activity 120.0 26 33.3462 13.221 28.9237 37.7686
43 M Prothrombin Complex Activity 144.0 8 38.875 18.2947 26.8472 50.9028

5 Plot of Summarized Observations Over Time

Re-create the following plot of the summarized PK and PD observations over time: