MonolixSuite in R
Auto Light Dark
Auto Light Dark

plotCAParametersVsCovariates

[PKanalix] Individual CA parameter vs covariate plot

Plot the CA individual parameters vs covariates.

Usage

R
plotCAParametersVsCovariates(
  parameters = NULL,
  covariates = NULL,
  settings = list(),
  preferences = list(),
  stratify = list()
)

Arguments

parameters

(vector) vector of ca parameters to display, e.g c("V", "Cl") (by default the first 4 computed ca parameters are displayed).

covariates

(vector) vector of covariates to display, e.g c("AGE", "FORM") (by default the first 4 covariates are displayed).

settings

List with the following settings:

  • regressionLine (logical) If TRUE, regression line is displayed (default TRUE).

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

  • boxplotData (character) for categorical covariate, if boxplotData is not NULL, NCA parameter values are added as dots on top of the boxplot. They can be either "spread" over the width of the box or "aligned" (default NULL)

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

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

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

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

  • units (logical) If TRUE, units are added in axis labels (default TRUE).

preferences

(optional) preferences for plot display, run getPlotPreferences("plotCAParametersVsCovariates") 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 parameters and covariates have only one element

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

See also

getPlotPreferences

Examples

R
  initializeLixoftConnectors(software="pkanalix")
  project <- file.path(getDemoPath(), "/2.case_studies/project_Theo_extravasc_SD.pkx")
  loadProject(project)
  runCAEstimation()
  
# choosing to display only a subset of possible covariates and CA parameters
plotCAParametersVsCovariates(parameters = c("Cl","V"),
                             covariates = c("WT","FORM"))

plotCAParametersVsCovariates with parameters Cl and V and covariates WT and FORM, a 2 by 2 grid. Left panels are scatter plots of Cl in L per h and V in L versus WT with blue dots and rising magenta regression lines. Right panels are boxplots by FORM ref and test, with red crosses marking Cl outliers near 7.8 and 11.5 L per h.
R

#> TableGrob (1 x 1) "arrange": 1 grobs
#>   z     cells    name            grob
#> 1 1 (1-1,1-1) arrange gtable[arrange]

# changing the settings to choose which elements to display
plotCAParametersVsCovariates(settings = list(regressionLine=F,
                                             spline=T,
                                             boxplotData="spread",
                                             legend=T,
                                             grid=F,
                                             units=F,
                                             fontsize=8))

plotCAParametersVsCovariates with splines instead of regression lines and spread boxplot data, a 4 by 4 grid of Tlag, ka, V and Cl versus AGE, HT, WT and FORM. Scatter plots show blue dots with orange spline curves, and the FORM column shows boxplots for ref and test with black jittered points and red outlier crosses. Tlag is higher for ref, about 1.9 h, than for test, about 1 h.
R

#> TableGrob (2 x 1) "arrange": 2 grobs
#>   z     cells    name              grob
#> 1 1 (1-1,1-1) arrange   gtable[arrange]
#> 2 2 (2-2,1-1) arrange gtable[guide-box]

# changing the preferences (appearance of the elements)
plotCAParametersVsCovariates(parameters = c("Cl","V"),
                             covariates = c("WT","FORM"),
                             settings=list(legend=T, spline=T, boxplotData="spread"),
                             preferences = list(boxplot=list(fill="#FBFBFB",
                                                             opacity=0.5,
                                                             legend=""),
                                                boxplotOutlier=list(color="#D71313",
                                                                    size=1.5,
                                                                    shape=2),
                                                boxplotValues=list(color="#1642f2",
                                                                   radius=1.5,
                                                                   shape=17,
                                                                   opacity=0.3,
                                                                   legend="NCA parameter values"),
                                                obs=list(color="#1642f2",
                                                         radius=2,
                                                         shape=17,
                                                         legend="NCA parameter values"),
                                                regressionLine=list(color="#202120",
                                                                    lineWidth=1,
                                                                    lineType="dashed",
                                                                    legend="Linear regression line"),
                                                spline=list(color="#97989c",
                                                            lineWidth=1,
                                                            lineType="solid",
                                                            legend="Spline regression line")))

plotCAParametersVsCovariates for Cl and V versus WT and FORM with custom preferences. Blue triangles labeled NCA parameter values appear in the WT scatter plots with a black dashed Linear regression line and a grey Spline regression line, and as faded jittered points over light boxplots for FORM ref and test, with red open triangles marking Cl outliers.
R

#> TableGrob (2 x 1) "arrange": 2 grobs
#>   z     cells    name              grob
#> 1 1 (1-1,1-1) arrange   gtable[arrange]
#> 2 2 (2-2,1-1) arrange gtable[guide-box]

# split each plot into two subplot for FORM=ref and FORM=test, vertically (ncol=1)
plotCAParametersVsCovariates(parameters = c("Cl","V"),
                             covariates = c("WT","AGE"),
                             settings=list(ncol=1),
                             stratify = list(split=c("FORM")))

plotCAParametersVsCovariates for Cl and V versus WT and AGE split by FORM with ncol 1. Each covariate panel holds two stacked scatter plots labeled FORM ref and FORM test, with blue dots and magenta regression lines. Cl and V tend to increase with WT, while Cl decreases slightly with AGE in both formulations.
R

#> TableGrob (1 x 1) "arrange": 1 grobs
#>   z     cells    name            grob
#> 1 1 (1-1,1-1) arrange gtable[arrange]

# define groups for AGE and HT, color by HT and filter by AGE
plotCAParametersVsCovariates(settings=list(legend=T),
                             parameters = c("Cl","V"),
                             covariates = c("WT","FORM"),
                             stratify = list(groups=list(list(name="AGE", definition=c(30, 35)),
                                                         list(name="HT", definition=c(184.5))),
                                             color="HT",
                                             colors=c("#cdced1","#161617"),
                                             filter=list("AGE",c(1,3))))

Output of plotCAParametersVsCovariates with groups defined on AGE and HT, colored by HT and filtered by AGE. A 2 by 2 grid shows Cl and V versus WT as scatter plots with a regression line, and versus FORM as boxplots for ref and test. Points are light gray for HT 176 to 184.5 and black for HT 184.5 to 191, as listed in the Individual parameters legend.
R

#> TableGrob (2 x 1) "arrange": 2 grobs
#>   z     cells    name              grob
#> 1 1 (1-1,1-1) arrange   gtable[arrange]
#> 2 2 (2-2,1-1) arrange gtable[guide-box]

# filter to keep only second sequence (TR) and FORM=test
plotCAParametersVsCovariates(settings=list(legend=T),
                             parameters = c("Cl","V"),
                             covariates = c("WT","FORM"),
                             stratify = list(filter=list(list("SEQ",2),list("FORM","test"))))

Output of plotCAParametersVsCovariates filtered to keep only sequence 2 and FORM equals test. A 2 by 2 grid shows Cl and V versus WT as scatter plots of about 9 individuals with a pink regression line, and versus FORM as boxplots with a single test category. One Cl value near 11.5 is marked as a red outlier.
R

#> TableGrob (2 x 1) "arrange": 2 grobs
#>   z     cells    name              grob
#> 1 1 (1-1,1-1) arrange   gtable[arrange]
#> 2 2 (2-2,1-1) arrange gtable[guide-box]
  

Last updated: