MonolixSuite in R
Auto Light Dark
Auto Light Dark

plotCAObservationsVsPredictions

[PKanalix] Plot observations vs the CA predictions.

Plot the observations vs the CA predictions.

Usage

R
plotCAObservationsVsPredictions(
  obsName = NULL,
  settings = list(),
  preferences = list(),
  stratify = list()
)

Arguments

obsName

(character) Name of the observation (if several OBS ID are used). By default the first observation id is considered.

settings

List with the following settings:

  • useCensored (logical) Choose to use BLQ data (TRUE) or to ignore it (FALSE, default) to compute the spline.

  • obs (logical) - If TRUE, observations are displayed as dots (default TRUE).

  • cens (logical) - If TRUE, censored observations are displayed as red dots (default TRUE).

  • spline (logical) - If TRUE, spline is displayed (default FALSE).

  • identityLine (logical) - If TRUE, identity line y=x is displayed (default TRUE).

  • legend (logical) If TRUE, plot legend is displayed (default FALSE).

  • grid (logical) If TRUE, plot grid is displayed (default TRUE).

  • xlog (logical) If TRUE, log-scale on x axis is used (default FALSE).

  • ylog (logical) If TRUE, log-scale on y axis is used (default FALSE).

  • ncol (integer) number of columns when split is used (default 4).

  • xlim (c(double, double)) limits of the x axis.

  • ylim (c(double, double)) limits of the y axis.

  • xlab (character) label on x axis (default "individual predictions").

  • ylab (character) label on y axis (default "observations").

  • fontsize (integer) Font size of text elements (default 11).

  • scales (character) Should scales be fixed ("fixed"), free ("free", default), or free in one dimension ("free_x", "free_y")

preferences

(optional) preferences for plot display, run getPlotPreferences("plotCAObservationsVsPredictions") to check available options.

stratify

List with the stratification arguments:

  • groups - Definition of stratification groups. By default, stratification groups are already defined as one group for each category for categorical covariates, and two groups of equal number of individuals for continuous covariates. To redefine groups, for each covariate to redefine, specify a list with:

    name

    character

    covariate name (e.g "AGE")

    definition

    vector(continuous) || list>(categorical)

    For continuous covariates, vector of break values (e.g c(35, 65)). For categorical covariates, groups of categories as a list of vectors(e.g list(c("study101"), c("study201","study202")))

  • split (vector) - Vector of covariates used to split (i.e facet) the plot (by default no split is applied). For instance c("FORM","AGE").

  • filter (list< list> >) - List of pairs containing a covariate name and the vector of indexes or categories (for categorical covariates) of the groups to keep (by default no filtering is applied). For instance, list("AGE",c(1,3)) to keep the individuals belonging to the first and third age group, according to the definition in groups. For instance, list("FORM","ref") using the category name for categorical covariates.

  • color (vector) - Vector of covariates used for coloring (by default no coloring is applied). Coloring applies to dots of plots w.r.t continuous covariates, but not on histograms or boxplots. For instance c("FORM","AGE").

  • colors - Vector of colors to use when color argument is used. Takes precedence over colors defined in preferences. For instance c("#ebecf0","#cdced1","#97989c").

Value

  • A ggplot object if one prediction type,

  • A TableGrob object if multiple plots (output of grid.arrange)

See also

getChartsData getPlotPreferences

Examples

R
project <- file.path(getDemoPath(), "/2.case_studies/project_Theo_extravasc_SD.pkx")
loadProject(project)
setCASettings(blqMethod="LOQ") #not recommended but allows to show plot settings related to censored data
runCAEstimation()

# plot with default options
plotCAObservationsVsPredictions()

Scatter plot from plotCAObservationsVsPredictions with default options for a PKanalix compartmental analysis of theophylline data. Observations on the y-axis, about 0 to 12, are plotted against Individual predictions on the x-axis, about 0 to 10. Blue points scatter around the black identity line. Red points along the bottom at about 0 are censored data, shown because blqMethod is set to LOQ.
R


# changing the elements to display
plotCAObservationsVsPredictions(settings=list(spline=T,
                                              useCensored=T,
                                              cens=T,
                                              identityLine=F,
                                              legend=T,
                                              grid=F,
                                              xlog=T,
                                              ylog=T,
                                              xlim=c(0.01,20),
                                              ylim=c(0.01,20),
                                              fontsize=9,
                                              xlab=c('Individual CA predictions'),
                                              ylab=c('Theophylline measurements (obs)')))
#> Warning: log-10 transformation introduced infinite values.
#> Warning: log-10 transformation introduced infinite values.
#> Warning: NaNs produced
#> Warning: log-10 transformation introduced infinite values.

Scatter plot from plotCAObservationsVsPredictions with customized settings, log scale on both axes, spline on, identity line off and legend on. The y-axis is Theophylline measurements obs, the x-axis is Individual CA predictions, both from about 0.01 to 10. Blue points are Observed data, red points at about 0.06 are Censored Data, and an orange Spline line follows the data, close to the diagonal at high values.
R



# coloring by FORM and Period using a greyscale
plotCAObservationsVsPredictions(settings = list(legend=T),
                                stratify = list(color=c("FORM", "Period"),
                                                colors=c("#cdced1","#97989c","#4c4d4f","#161617")))

Scatter plot from plotCAObservationsVsPredictions with stratify color by FORM and Period using a greyscale. Observations versus Individual predictions, both from 0 to about 10 to 12, with a black identity line and red censored points at 0. The legend Observed data lists four greyscale groups, FORM ref and test combined with Period 1 and 2. The groups overlap along the identity line.
R



# coloring by FORM and filtering to keep only SEQ=TR
plotCAObservationsVsPredictions(settings = list(legend=T),
                                stratify = list(color=c("FORM"),
                                                filter=list("SEQ","TR")))

Scatter plot from plotCAObservationsVsPredictions colored by FORM and filtered to keep only SEQ TR. Observations versus Individual predictions with a black identity line. Dark grey points are FORM test and blue points are FORM ref, as shown in the Observed data legend. Red censored points lie at 0 at the bottom. Fewer points appear than in the unfiltered plot.
R


# defining groups for AGE and HT, coloring by AGE and splitting by HT
plotCAObservationsVsPredictions(settings = list(legend=T, cens=F),
                                stratify = list(groups=list(list(name="AGE", definition=c(24, 34)), 
                                                            list(name="HT", definition=180)),
                                                color="AGE",
                                                colors=c("#00a4c6","#64bc48","#ff793f"),
                                                split="HT"))

Scatter plot from plotCAObservationsVsPredictions with groups defined for AGE and HT, colored by AGE and split by HT. Two panels, HT 176 to 180 and HT 180 to 191, show Observations versus Individual predictions with a black identity line. The Observed data legend shows AGE groups 21 to 24 in blue, 24 to 34 in green, and 34 to 39 in orange. Censored data are hidden.
R

Last updated: