MonolixSuite in R
Auto Light Dark
Auto Light Dark

plotNCAData

[PKanalix] Generate NCA data plots

Plot the observed data as used for the NCA calculations

Usage

R
plotNCAData(settings = list(), stratify = list(), preferences = list())

Arguments

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 connected by lines (default FALSE if NCA has been run using sparse data option, TRUE either).

  • mean (logical) - If TRUE, mean (geometric or arithmetic) of observations is displayed (default TRUE).

  • error (logical) If TRUE, error bar presenting standard deviation or standard error are displayed (default TRUE).

  • meanMethod (character) - When mean is set to TRUE, display arithmetic mean ("arithmetic", default) or geometric mean ("geometric"). Forced to 'arithmetic' if NCA has been run using sparse data option.

  • errorMethod (character) - When error is set to TRUE, display standard deviation ("standardDeviation", default) or standard error ("standardError"). Forced to 'standardDeviation' if NCA has been run using sparse data option.

  • useCensored (logical) If TRUE, censored observations are used to compute mean and error (default TRUE). Not available if NCA has been run using sparse data option.

  • binLimits (logical) - If TRUE, bins limits are displayed as vertical lines (default FALSE). Not available if NCA has been run using sparse data option.

  • binsSettings a list of settings for time axis binning for observation statistics computation. Not available if NCA has been run using sparse data option.

    • criteria (character) - Binning criteria, one of 'equalwidth', 'equalsize', or 'leastsquare' (default) methods.

    • is.fixedNbBins (logical) - If TRUE, a fixed number of bins is used (see nbBins). If FALSE (default), the number of bins is optimized using binRange and nbBinData.

    • nbBins (integer) - Number of bins (default 10). Ignored if is.fixedNbBins=FALSE.

    • binRange (vector(integer, integer)) - Minimum and maximum number of bins when bins are optimized (default c(5, 100)).

    • nbBinData (vector(integer, integer)) - Minimum and maximum number of data points per bin when bins are optimized (default and c(3, 200)).

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

  • dosingTimes (logical) - If TRUE, dosing times are displayed as vertical lines (default FALSE).

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

  • xlab (character) - Label on x axis (default "time").

  • ylab (character) - Label on y axis (default obsName).

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

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

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

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

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

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

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

  • mergedSplits (logical) - When "split" is used and mean=T, should the means of the different groups be displayed on the same plot (TRUE) or on different subplots (FALSE, default). Not available for count/categorical data. When mergedSplits=T, the "color" argument is ignored and the coloring is done according to the splitted groups.

  • 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 or "id" (by default no coloring is applied). For instance c("FORM","AGE") or "id".

  • 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("plotNCAData") to check available options.

Value

A ggplot object

See also

getPlotPreferences

Examples

R
  initializeLixoftConnectors(software = "pkanalix")
  project <- paste0(getDemoPath(), "/2.case_studies/project_aPCSK9_SAD.pkx")
  loadProject(project)
  setNCASettings(blqMethodBeforeTmax="missing",blqMethodAfterTmax="LOQ")
  runNCAEstimation()
  
  # by default, individual profiles and mean curve are displayed
  plotNCAData()
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's linetype values.

Default plotNCAData output for the aPCSK9 SAD demo. Individual concentration profiles in mg per L versus time in days, from 0 to 84, are drawn as blue dots and lines, with a black mean curve and error bars. Concentrations peak around day 3 to 9, up to about 115, and decline toward 0 by day 84. A few censored points near 0 at late times are red.
R

  
  # displaying dots and mean curve by dose group, merged on a single plot
  plotNCAData(settings=list(lines=F,
                            mean=T,
                            meanMethod="geometric", 
                            ylog=T),
              stratify=list(split="DOSE_mg",
                            mergedSplits=T),
              preferences=list(observationStatistics=list(lineWidth=0.8),
                               obs=list(radius=2)))
#> Warning: log-10 transformation introduced infinite values.
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's linetype values.

plotNCAData output split by DOSE_mg with splits merged on one plot and a log y axis. Observations as dots and geometric mean curves with error bars are shown for three dose groups in blue, dark gray and green. The green group peaks near 70 mg per L and the blue group near 10 mg per L, and all groups decline toward about 0.1 to 1 by day 84.
R

  
  # coloring by ID, without mean curve
  plotNCAData(settings=list(mean=F,error=F),
              stratify = list(color=c("id")))
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's linetype values.

plotNCAData plot of individual concentration profiles colored by id, without mean curve. Concentration in mg per L versus time in days, 0 to about 84. Each individual has its own color, with dots joined by lines. Peaks occur within about the first 10 days, ranging from about 8 to about 116 mg per L, followed by a decline toward zero.
R

  
  # changing the settings to display only the mean curve with SE, with bin limits and dosing times
  plotNCAData(settings=list(dots=F,
                            lines=F,
                            mean=T,
                            error=T,
                            meanMethod="geometric",
                            errorMethod="standardError",
                            useCensored=T,
                            binLimits=T,
                            binsSettings=list(criteria="leastsquare", is.fixedNbBins=T, nbBins=20),
                            cens=F,
                            dosingTimes=T,
                            legend=T,
                            grid=F,
                            xlog=F,ylog=T,
                            xlab="Time since first dose (days)",
                            ylab="mAb concentration (ug/mL)",
                            xlim=c(0,96),
                            ylim=c(0.1,70),
                            fontsize=12,
                            units=F))
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's linetype values.

plotNCAData plot showing only the geometric mean curve with standard error bars, log y axis. mAb concentration in ug per mL versus Time since first dose in days, 0 to 100. The mean rises to about 25 near day 7, then declines to about 0.2 at day 84. Vertical red lines mark the bin limits and a dashed black line at time 0 marks the dose. Legend at the bottom.
R

  
  # changing preferences for observations, censored observations and bin limits
  plotNCAData(settings=list(dots=T, lines=T, legend=T, dosingTimes=T, mean=F, error=F, ylog=T, cens=T),
              preferences=list(obs=list(color="#161617",
                                        radius=2,
                                        shape=18,
                                        lineWidth=0.2,
                                        lineType="dashed",
                                        legend="Observations"),
                               censObs=list(color="#cdced1",
                                            radius=2,
                                            shape=16,
                                            legend="Censored observations"),
                               dosingTimes=list(color="#fcba03",
                                                lineWidth=0.5,
                                                lineType="solid",
                                                legend="Time of doses")))
#> Warning: log-10 transformation introduced infinite values.
#> Warning: log-10 transformation introduced infinite values.
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's linetype values.

plotNCAData plot with customized preferences, log y axis. Concentration in mg per L versus time in days. Observations are black diamonds joined by thin dashed lines per individual, censored observations are light grey dots at 0.1 near days 56 and 84, and an orange vertical line at time 0 marks the dose. Legend at the bottom lists Observations, Censored observations and Time of doses.
R

  
  # changing preferences for mean and bin limits
  plotNCAData(settings=list(dots=F, lines=F, legend=T, binLimits=T, grid=F),
              preferences=list(observationStatistics=list(color="#161617",
                                                          whiskersWidth=3,
                                                          lineWidth=0.7,
                                                          lineType="solid",
                                                          legend="mean and standard deviation over bins"),
                               binsValues=list(color="#cdced1",
                                               lineWidth=0.5,
                                               lineType="dashed",
                                               legend="bins")))
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's linetype values.

plotNCAData plot with customized mean and bin preferences, no grid. Concentration in mg per L versus time in days. A thick black line shows the mean with wide standard deviation whiskers per bin, peaking at about 37 around days 3 to 7 and declining to near 0 by day 84. Grey dashed vertical lines mark the bins. Legend reads mean and standard deviation over bins, and bins.
R

  
  # color and split by DOSE_mg but grouping two doses levels together
  plotNCAData(settings=list(mean=F,error=F,ylim=c(0,120)),
              stratify = list(groups=list(name="DOSE_mg",definition=list(c("150mg"), c("300mg","800mg"))),
                              color="DOSE_mg",
                              split="DOSE_mg"))
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's linetype values.

plotNCAData plot colored and split by DOSE_mg with redefined groups, in two panels titled DOSE_mg 150mg and DOSE_mg 300mg-800mg. Concentration in mg per L versus time in days, y axis 0 to 125. The 150mg panel shows blue profiles peaking below about 20. The 300mg-800mg panel shows dark grey profiles peaking up to about 116. Red dots mark censored data.
R

  
  
  #============= projects with several covariates
project <- file.path(getDemoPath(), "/2.case_studies/project_Theo_extravasc_SD.pkx")
loadProject(project)
runNCAEstimation()

# defining groups for AGE and HT, coloring by HT and filtering by AGE
plotNCAData(settings=list(mean=F,error=F),
            stratify = list(groups=list(list(name="AGE", definition=c(24, 34)),
                                        list(name="HT", definition=c(184.5))),
                            color="HT",
                            colors=c("#cdced1","#161617"),
                            filter=list("AGE",c(1,3))))
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's linetype values.

plotNCAData plot for the Theo_extravasc_SD project with groups defined for AGE and HT, colored by HT and filtered by AGE. Concentration in mg per L versus time in hours, 0 to about 72. Profiles appear in black or light grey for the two HT groups, peaking at about 4 to 11.5 between about 5 and 12 hours. Red dots at early times mark censored data.
R


# filter to keep only second sequence (TR) and FORM=test
plotNCAData(settings=list(mean=F,error=F),
            stratify = list(filter=list(list("SEQ",2),list("FORM","test"))))
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's linetype values.

plotNCAData plot filtered to keep only the second sequence SEQ, TR, and FORM equals test. Concentration in mg per L versus time in hours. About 10 blue individual profiles peak at about 4 to 10 between about 5 and 14 hours and decline toward zero by 48 to 72 hours. Red dots at early times mark censored data.
R


  
  
  #============= project with sparse calculations
  project <- paste0(getDemoPath(), "/1.basic_examples/project_sparse.pkx")
  loadProject(project)
  runNCAEstimation()
  
  # mean profiles are already calculated for each stratification group used for the sparse calculations
  # stratify argument cannot be used
  plotNCAData()
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's linetype values.

plotNCAData default plot for a project with sparse NCA calculations. Concentration versus nominal time, 0 to about 504. Dots show observations and lines with standard deviation bars show mean profiles for five groups by dose group DGROUP and STUDY, as listed in the Observed data legend. The two DGROUP 10 profiles are highest, up to about 50000, and only DGROUP 10 STUDY1 extends to about 504.
R

  
  # displaying only the averaged profiles, without individual dots and without error bars
  plotNCAData(settings=list(dots=F,
                            error=F))
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's linetype values.

plotNCAData plot for the sparse project showing only the averaged profiles, without individual dots or error bars. Concentration versus nominal time, 0 to about 504. Five mean profile lines, one per DGROUP and STUDY group, as in the Observed data legend. Two profiles start near 40000 and decline, one extending to about 504, while the other three stay below about 10000.
R

Last updated: