MonolixSuite in R
Auto Light Dark
Auto Light Dark

plotBivariateDataViewer

[Monolix - PKanalix] Generate Bivariate observations plots

Plot the bivariate viewer.

Usage

R
plotBivariateDataViewer(
  obs1 = NULL,
  obs2 = NULL,
  settings = list(),
  stratify = list(),
  preferences = list()
)

Arguments

obs1

(character) Name of the observation to display in x axis (in dataset header). By default the first observation is considered.

obs2

(character) Name of the observation to display in y axis (in dataset header). By default the second observation is considered.

settings

List with the following settings

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

  • lines (logical) - If TRUE individual observations are displayed as lines (default TRUE).

  • legend (logical) add (TRUE) / remove (FALSE) plot legend (default FALSE).

  • grid (logical) add (TRUE) / remove (FALSE) plot grid (default TRUE).

  • xlog (logical) add (TRUE) / remove (FALSE) log scaling on x axis (default FALSE).

  • ylog (logical) add (TRUE) / remove (FALSE) log scaling on y axis (default FALSE).

  • xlab (character) label on x axis (Name of obs1 by default).

  • ylab (character) label on y axis (Name of obs2 by default).

  • ncol (integer) number of columns when facet = TRUE (default 4).

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

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

  • fontsize (integer) Plot text font size.

  • units (logical) Set units in axis labels (only available with PKanalix).

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

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). 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").

  • individualSelection - Ids to display (by default the 12 first ids are displayed) defined as:

    • indices (vector) - Indices of the individuals to display (by default, the 12 first individuals are selected). If occasions are present, all occasions of the selected individuals will be displayed. Takes precedence over ids. For instance c(5,6,10,11).

    • isRange (logical) - If TRUE, all individuals whose index is inside [min(indices), max[indices]] are selected (FALSE by default). Forced to FALSE if ids is defined.

    • ids (vector) - Names of the individuals to display. If occasions are present, all occasions of the selected individuals will be displayed. For instance c("101-01","101-02","101-03"). If ids are integers, can also be c(1,3,6). Ignored if indices is defined.

preferences

(optional) preferences for plot display, run getPlotPreferences("plotBivariateDataViewer") to check available displays.

Value

A ggplot object

See also

getPlotPreferences

Examples

R
  initializeLixoftConnectors(software = "monolix")
  project <- file.path(getDemoPath(), "1.creating_and_using_models",
                       "1.1.libraries_of_models", "warfarinPKPD_project.mlxtran")
  loadProject(project)

  plotBivariateDataViewer(obs1 = "y1", obs2 = "y2")

Default plotBivariateDataViewer output for the warfarin PKPD demo, with observation y1 on the x axis, about 0 to 18, and y2 on the y axis, about 10 to 100. Each individual is a connected path of dots in time order, with an arrowhead marking the end of the path. Paths start near y2 equals 90 to 100 and loop down to low y2 values at low y1.
R

  plotBivariateDataViewer(settings = list(lines = FALSE))
#> Warning: obs1 not specified. It is set to y1.
#> Warning: obs2 not specified. It is set to y2.

plotBivariateDataViewer output with lines turned off. Scatter plot of y2 versus y1 showing only the observation dots. One cluster sits at high y2, about 60 to 100, and a larger cluster at low y2, about 10 to 50, across y1 values from 0 to about 12.
R


  # stratification
  plotBivariateDataViewer(obs1 = "y1", obs2 = "y2", stratify = list(individualSelection = list(indices = 10)))

plotBivariateDataViewer output for a single selected individual, index 10. Four dots of y2 versus y1 are joined in time order, starting near y1 5.6 and y2 44, dropping to about y2 27 at y1 4, then moving to y1 about 0.8 and y2 31, where an arrowhead marks the last point.
R

  plotBivariateDataViewer(stratify = list(split = "age",
                                          filter = list("sex", "1"),
                                          groups = list(name = "age", definition = c(25))))
#> Warning: obs1 not specified. It is set to y1.
#> Warning: obs2 not specified. It is set to y2.

plotBivariateDataViewer output filtered to sex 1 and split by age groups with a break at 25. Two panels, age 21-25 and age 25-63, each show individual y2 versus y1 paths with arrowheads at the last point. The age 25-63 panel includes paths that start at high y2 near 90 to 100.
R

  plotBivariateDataViewer(stratify = list(color = "wt",
                                          groups = list(name = "wt", definition = 75)))
#> Warning: obs1 not specified. It is set to y1.
#> Warning: obs2 not specified. It is set to y2.

plotBivariateDataViewer output colored by weight groups with a break at wt 75. The y2 versus y1 individual paths are drawn in two colors, gold and purple, one per weight group, with arrowheads at the last point. No legend is shown.
R

  plotBivariateDataViewer(stratify = list(split = c("age", "sex"),
                                          groups = list(name = "age", definition = 25)))
#> Warning: obs1 not specified. It is set to y1.
#> Warning: obs2 not specified. It is set to y2.

plotBivariateDataViewer output split by age group, break at 25, and sex. Three panels titled age 21-25 sex 1, age 25-63 sex 0 and age 25-63 sex 1 each show individual y2 versus y1 paths with arrowheads marking the last point. The age 21-25 sex 1 panel stays at y2 below about 55.
R

  # update plot settings or preferences
  plotBivariateDataViewer(preferences = list(obs = list(color = "#32CD32")))
#> Warning: obs1 not specified. It is set to y1.
#> Warning: obs2 not specified. It is set to y2.

plotBivariateDataViewer output with a custom observation color preference. The same y2 versus y1 individual paths as the default plot, with dots, lines and arrowheads, are drawn in lime green instead of blue.
R

Last updated: