Produces a logistic fit plot with a facettable exposures/quantiles/distributions in ggplot2
Usage
ggcontinuousexpdist(
data = effICGI,
response = "response",
endpoint = "Endpoint",
model_type = c("linear", "loess", "none"),
DOSE = "DOSE",
color_fill = "DOSE",
fit_by_color_fill = FALSE,
exposure_metrics = c("AUC", "CMAX"),
exposure_metric_split = c("median", "tertile", "quartile", "none"),
exposure_metric_soc_value = -99,
exposure_metric_plac_value = 0,
exposure_distribution = c("distributions", "lineranges", "none"),
exposure_distribution_percent = TRUE,
exposure_distribution_percent_text_size = 5,
dose_plac_value = "Placebo",
xlab = "Exposure Values",
ylab = "Response",
points_alpha = 0.2,
points_show = TRUE,
mean_obs_byexptile = TRUE,
mean_obs_byexptile_plac = TRUE,
mean_obs_byexptile_group = "none",
mean_text_size = 5,
mean_obs_bydose = TRUE,
mean_obs_bydose_plac = FALSE,
N_text_show = TRUE,
N_text_size = 5,
N_text_ypos = c("with means", "top"),
binlimits_show = TRUE,
binlimits_text_size = 5,
binlimits_ypos = -Inf,
binlimits_color = "#B3B3B380",
dist_position_scaler = 0.2,
dist_offset = 0,
dist_scale = 0.9,
lineranges_ypos = -1,
lineranges_dodge = 1,
lineranges_doselabel = FALSE,
proj_bydose = TRUE,
yproj = TRUE,
yproj_xpos = 0,
yproj_dodge = 0.2,
yaxis_position = c("left", "right"),
facet_formula = NULL,
theme_certara = TRUE,
return_list = FALSE
)
Arguments
- data
Data to use with multiple endpoints stacked into response (values), Endpoint(endpoint name)
- response
name of the column holding the response values
- endpoint
name of the column holding the name/key of the endpoint default to
Endpoint
- model_type
type of the trend fit one of "linear", "loess", "none"
- DOSE
name of the column holding the DOSE values default to
DOSE
- color_fill
name of the column to be used for color/fill default to DOSE column
- fit_by_color_fill
fit split by color? default
FALSE
- exposure_metrics
name(s) of the column(s) to be stacked into
expname
exptile
and split intoexposure_metric_split
- exposure_metric_split
one of "median", "tertile", "quartile", "none"
- exposure_metric_soc_value
special exposure code for standard of care default -99
- exposure_metric_plac_value
special exposure code for placebo default 0
- exposure_distribution
one of distributions, lineranges or none
- exposure_distribution_percent
show percent of distribution between binlimits
TRUE
/FALSE
- exposure_distribution_percent_text_size
distribution percentages text size default to 5
- dose_plac_value
string identifying placebo in DOSE column
- xlab
text to be used as x axis label
- ylab
text to be used as y axis label
- points_alpha
alpha transparency for points
- points_show
show the observations
TRUE
/FALSE
- mean_obs_byexptile
observed mean by exptile
TRUE
/FALSE
- mean_obs_byexptile_plac
observed mean by exptile placebo
TRUE
/FALSE
- mean_obs_byexptile_group
additional grouping for exptile probabilities default
none
- mean_text_size
mean text size default to 5
- mean_obs_bydose
observed mean by dose
TRUE
/FALSE
- mean_obs_bydose_plac
observed mean by placebo dose
TRUE
/FALSE
- N_text_show
show the N by exptile
TRUE
/FALSE
- N_text_size
N by exposure text size default to 5
- N_text_ypos
y position for N two text elements the first for by exptile and the second for by dose/color options include
with means
top
bottom
- binlimits_show
show the binlimits vertical lines
TRUE
/FALSE
- binlimits_text_size
binlimits text size default to 5
- binlimits_ypos
binlimits y position default to -Inf
- binlimits_color
binlimits text color default to alpha("gray70",0.5)
- dist_position_scaler
space occupied by the distribution default to 0.2
- dist_offset
offset where the distribution position starts default to 0
- dist_scale
scaling parameter for ggridges default to 0.9
- lineranges_ypos
where to put the lineranges -1
- lineranges_dodge
lineranges vertical dodge value 1
- lineranges_doselabel
TRUE
/FALSE
- proj_bydose
project the probabilities on logistic curve
TRUE
/FALSE
- yproj
project the probabilities on y axis
TRUE
/FALSE
- yproj_xpos
y projection x position 0
- yproj_dodge
y projection dodge value 0.2
- yaxis_position
where to put y axis "left" or "right"
- facet_formula
facet formula to be use otherwise
endpoint ~ expname
- theme_certara
apply certara colors and format for strips and default colour/fill
- return_list
What to return if True a list of the datasets and plot is returned instead of only the plot
Examples
# Example 1
library(ggplot2)
library(patchwork)
effICGI <- logistic_data |>
dplyr::filter(!is.na(ICGI7))|>
dplyr::filter(!is.na(AUC))
effICGI$DOSE <- factor(effICGI$DOSE,
levels=c("0", "600", "1200","1800","2400"),
labels=c("Placebo", "600 mg", "1200 mg","1800 mg","2400 mg"))
effICGI$STUDY <- factor(effICGI$STUDY)
effICGI <- tidyr::gather(effICGI,Endpoint,response,ICGI7,BRLS)
a <- ggcontinuousexpdist(data = effICGI |> dplyr::filter(Endpoint =="ICGI7"),
response = "response",
endpoint = "Endpoint",
exposure_metrics = c("AUC"),
exposure_metric_split = c("quartile"),
exposure_metric_soc_value = -99,
exposure_metric_plac_value = 0,
dist_position_scaler = 1, dist_offset = -1 ,
yproj_xpos = -20 ,
yproj_dodge = 20 ,
exposure_distribution ="distributions")
#> Joining with `by = join_by(loopvariable, DOSE, quant_10)`
#> Joining with `by = join_by(loopvariable, DOSE, quant_90)`
#> Joining with `by = join_by(loopvariable, DOSE, quant_25)`
#> Joining with `by = join_by(loopvariable, DOSE, quant_75)`
#> Joining with `by = join_by(loopvariable, DOSE, medexp)`
#> # A tibble: 5 × 17
#> loopvariable Endpoint expname DOSE DOSE2 minexp maxexp medexp meanexp Nmiss
#> <chr> <chr> <fct> <fct> <fct> <dbl> <dbl> <dbl> <dbl> <int>
#> 1 ICGI7_AUC ICGI7 AUC Placebo Plac… 0 0 0 0 0
#> 2 ICGI7_AUC ICGI7 AUC 600 mg 600 … 9.7 81.7 50.8 49.9 0
#> 3 ICGI7_AUC ICGI7 AUC 1200 mg 1200… 12.1 174. 94.2 96.5 0
#> 4 ICGI7_AUC ICGI7 AUC 1800 mg 1800… 67.2 238. 146. 148. 0
#> 5 ICGI7_AUC ICGI7 AUC 2400 mg 2400… 108. 343. 167. 176. 0
#> # ℹ 7 more variables: Ntot <int>, mean <dbl>, SE <dbl>, quant_25 <dbl>,
#> # quant_75 <dbl>, quant_90 <dbl>, quant_10 <dbl>
b <- ggcontinuousexpdist(data = effICGI |> dplyr::filter(Endpoint =="BRLS"),
response = "response",
endpoint = "Endpoint",
exposure_metrics = c("AUC"),
exposure_metric_split = c("quartile"),
exposure_metric_soc_value = -99,
exposure_metric_plac_value = 0,
dist_position_scaler = 4.2, dist_offset = 5 ,
yproj_xpos = -20 ,
yproj_dodge = 20 ,
exposure_distribution ="distributions",
return_list = FALSE)
#> Joining with `by = join_by(loopvariable, DOSE, quant_10)`
#> Joining with `by = join_by(loopvariable, DOSE, quant_90)`
#> Joining with `by = join_by(loopvariable, DOSE, quant_25)`
#> Joining with `by = join_by(loopvariable, DOSE, quant_75)`
#> Joining with `by = join_by(loopvariable, DOSE, medexp)`
#> # A tibble: 5 × 17
#> loopvariable Endpoint expname DOSE DOSE2 minexp maxexp medexp meanexp Nmiss
#> <chr> <chr> <fct> <fct> <fct> <dbl> <dbl> <dbl> <dbl> <int>
#> 1 BRLS_AUC BRLS AUC Placebo Plac… 0 0 0 0 0
#> 2 BRLS_AUC BRLS AUC 600 mg 600 … 9.7 81.7 50.8 49.9 0
#> 3 BRLS_AUC BRLS AUC 1200 mg 1200… 12.1 174. 94.2 96.5 0
#> 4 BRLS_AUC BRLS AUC 1800 mg 1800… 67.2 238. 146. 148. 0
#> 5 BRLS_AUC BRLS AUC 2400 mg 2400… 108. 343. 167. 176. 0
#> # ℹ 7 more variables: Ntot <int>, mean <dbl>, SE <dbl>, quant_25 <dbl>,
#> # quant_75 <dbl>, quant_90 <dbl>, quant_10 <dbl>
(a / b) +
plot_layout(guides = "collect") &
theme(legend.position = "top")
#> `geom_smooth()` using formula = 'y ~ x'
#> `geom_smooth()` using formula = 'y ~ x'
#> Picking joint bandwidth of 11.7
#> Warning: Removed 244 rows containing non-finite outside the scale range
#> (`stat_density_ridges()`).
#> Warning: Removed 1 row containing missing values or values outside the scale range
#> (`geom_pointrange()`).
#> `geom_smooth()` using formula = 'y ~ x'
#> Warning: Removed 4 rows containing non-finite outside the scale range (`stat_smooth()`).
#> `geom_smooth()` using formula = 'y ~ x'
#> Warning: Removed 4 rows containing non-finite outside the scale range (`stat_smooth()`).
#> Picking joint bandwidth of 11.7
#> Warning: Removed 244 rows containing non-finite outside the scale range
#> (`stat_density_ridges()`).
#> Warning: Removed 4 rows containing missing values or values outside the scale range
#> (`geom_point()`).
#> Warning: Removed 1 row containing missing values or values outside the scale range
#> (`geom_pointrange()`).
#Example 2
effICGI$SEX <- as.factor(effICGI$SEX)
ggcontinuousexpdist(data = effICGI |>
dplyr::filter(Endpoint =="ICGI7"),
response = "response",
endpoint = "Endpoint",
color_fill = "SEX",
exposure_metrics = c("AUC"),
exposure_metric_split = c("quartile"),
exposure_metric_soc_value = -99,
exposure_metric_plac_value = 0,
dist_position_scaler = 1, dist_offset = -1 ,
yproj_xpos = -20 ,
yproj_dodge = 20 ,
exposure_distribution ="lineranges")
#> Joining with `by = join_by(loopvariable, SEX, color_fill2, DOSE, quant_10)`
#> Joining with `by = join_by(loopvariable, SEX, color_fill2, DOSE, quant_90)`
#> Joining with `by = join_by(loopvariable, SEX, color_fill2, DOSE, quant_25)`
#> Joining with `by = join_by(loopvariable, SEX, color_fill2, DOSE, quant_75)`
#> Joining with `by = join_by(loopvariable, SEX, color_fill2, DOSE, medexp)`
#> # A tibble: 10 × 19
#> loopvariable Endpoint expname SEX color_fill2 DOSE DOSE2 minexp maxexp
#> <chr> <chr> <fct> <fct> <fct> <fct> <fct> <dbl> <dbl>
#> 1 ICGI7_AUC ICGI7 AUC 1 1 Placebo Placebo 0 0
#> 2 ICGI7_AUC ICGI7 AUC 1 1 600 mg 600 mg 11.9 60.1
#> 3 ICGI7_AUC ICGI7 AUC 1 1 1200 mg 1200 mg 12.1 154.
#> 4 ICGI7_AUC ICGI7 AUC 1 1 1800 mg 1800 mg 83.4 210.
#> 5 ICGI7_AUC ICGI7 AUC 1 1 2400 mg 2400 mg 111 343.
#> 6 ICGI7_AUC ICGI7 AUC 2 2 Placebo Placebo 0 0
#> 7 ICGI7_AUC ICGI7 AUC 2 2 600 mg 600 mg 9.7 81.7
#> 8 ICGI7_AUC ICGI7 AUC 2 2 1200 mg 1200 mg 13.9 174.
#> 9 ICGI7_AUC ICGI7 AUC 2 2 1800 mg 1800 mg 67.2 238.
#> 10 ICGI7_AUC ICGI7 AUC 2 2 2400 mg 2400 mg 108. 275.
#> # ℹ 10 more variables: medexp <dbl>, meanexp <dbl>, Nmiss <int>, Ntot <int>,
#> # mean <dbl>, SE <dbl>, quant_25 <dbl>, quant_75 <dbl>, quant_90 <dbl>,
#> # quant_10 <dbl>
#> `geom_smooth()` using formula = 'y ~ x'
#> `geom_smooth()` using formula = 'y ~ x'
#> Warning: Removed 2 rows containing missing values or values outside the scale range
#> (`geom_pointrange()`).
if (FALSE) { # \dontrun{
#Example 3
} # }