gglogisticexpdist: Create a logistic fit plot

View source: R/gglogisticexpdist.R

gglogisticexpdistR Documentation

Create a logistic fit plot

Description

Produces a logistic fit plot with a facettable exposures/quantiles/distributions in ggplot2

Usage

gglogisticexpdist(
  data = effICGI,
  response = "response",
  endpoint = "Endpoint",
  DOSE = "DOSE",
  color_fill = "DOSE",
  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"),
  dose_plac_value = "Placebo",
  xlab = "Exposure Values",
  ylab = "Probability of Response",
  prob_text_size = 5,
  prob_obs_bydose = TRUE,
  N_text_size = 5,
  binlimits_text_size = 5,
  binlimits_ypos = 0,
  binlimits_color = "gray70",
  dist_position_scaler = 0.2,
  dist_offset = 0,
  lineranges_ypos = 0.2,
  lineranges_dodge = 0.15,
  yproj = TRUE,
  yproj_xpos = 0,
  yproj_dodge = 0.2,
  yaxis_position = c("left", "right"),
  facet_formula = NULL,
  theme_certara = TRUE
)

Arguments

data

Data to use with multiple endpoints stacked into Endpoint(endpoint name), response 0/1

response

name of the column holding the values response 0/1

endpoint

name of the column holding the name/key of the endpoint default to Endpoint

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

exposure_metrics

name(s) of the column(s) to be stacked into expname exptile and split into exposure_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

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

prob_text_size

probability text size default to 5

prob_obs_bydose

observed probability by dose TRUE/FALSE

N_text_size

N responders/Ntotal by exposure bin text size default to 5

binlimits_text_size

5 binlimits text size

binlimits_ypos

binlimits y position default to 0

binlimits_color

binlimits text color default to "gray70"

dist_position_scaler

space occupied by the distribution default to 0.2

dist_offset

offset where the distribution position starts 0

lineranges_ypos

where to put the lineranges -1

lineranges_dodge

lineranges vertical dodge value 1

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

Examples

# Example 1
library(ggplot2)
effICGI <- logistic_data |>
dplyr::filter(!is.na(ICGI))|>
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$ICGI2 <- effICGI$ICGI
effICGI <- tidyr::gather(effICGI,Endpoint,response,ICGI,ICGI2)
gglogisticexpdist(data = effICGI |>
                 dplyr::filter(Endpoint=="ICGI"),
                 response = "response",
                 endpoint = "Endpoint",
                 exposure_metrics = c("AUC"),
                 exposure_metric_split = c("quartile"),
                 exposure_metric_soc_value = -99,
                 exposure_metric_plac_value = 0,
                 exposure_distribution ="distributions",
                 yproj_xpos = -15,
                 yproj_dodge = 10,
                 dist_position_scaler = 0.1,
                 dist_offset = -0.1)
                 
# Example 2                
gglogisticexpdist(data = effICGI |>
                 dplyr::filter(Endpoint=="ICGI"),
                 response = "response",
                 endpoint = "Endpoint",
                 exposure_metrics = c("CMAX"),
                 exposure_metric_split = c("tertile"),
                 exposure_metric_soc_value = -99,
                 exposure_metric_plac_value = 0,
                 exposure_distribution ="lineranges",
                 lineranges_ypos = -0.2,
                 lineranges_dodge = 0.4,
                 prob_obs_bydose = TRUE,
                 yproj_xpos = -5,
                 yproj_dodge = 5,
                 dist_position_scaler = 0.1)


## Not run: 
#' # Example 3                
library(ggh4x)
gglogisticexpdist(data = effICGI |>
                 dplyr::filter(Endpoint=="ICGI"), 
                 response = "response",
                 endpoint = "Endpoint",
                 DOSE = "DOSE",
                 exposure_metrics = c("AUC"),
                 exposure_metric_split = c("quartile"),
                 exposure_distribution ="distributions",
                 exposure_metric_soc_value = -99,
                 exposure_metric_plac_value = 0,
                 dist_position_scaler = 0.15)+
 facet_grid2(Endpoint~expname+DOSE2,scales="free",
 margins = "DOSE2",strip = strip_nested())
# Example 4  
effICGI$SEX <- as.factor(effICGI$SEX)               
gglogisticexpdist(data = effICGI  |>
                 dplyr::filter(Endpoint=="ICGI"), 
                 response = "response",
                 endpoint = "Endpoint",
                 DOSE = "DOSE",
                 color_fill = "SEX",
                 exposure_metrics = c("AUC"),
                 exposure_metric_split = c("quartile"),
                 exposure_distribution ="distributions",
                 exposure_metric_soc_value = -99,
                 exposure_metric_plac_value = 0,
                 lineranges_ypos = -0.2,
                 yproj_xpos = -10,
                 yproj_dodge = 20,
                 prob_text_size = 6,
                 binlimits_text_size = 6,
                 N_text_size = 4,
                 dist_position_scaler = 0.15)+
                 ggplot2::scale_x_continuous(breaks = seq(0,350,50),
                 expand = ggplot2::expansion(add= c(0,0),mult=c(0,0)))+
                 ggplot2::coord_cartesian(xlim = c(-30,355))+
                 ggplot2::facet_grid(Endpoint~expname+color_fill2, margins ="color_fill2" )

#Example 4b
  effICGI$SEX <- as.factor(effICGI$SEX)
 gglogisticexpdist(data = effICGI |>
  dplyr::filter(Endpoint =="ICGI"),
                 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")
                 
#Example 5
gglogisticexpdist(data = effICGI |> dplyr::filter(Endpoint=="ICGI"), 
                  response = "response",
                  endpoint = "Endpoint",
                  DOSE = "DOSE",
                  exposure_metrics = c("AUC"),
                  exposure_metric_split = c("quartile"),
                  exposure_distribution ="distributions",
                  exposure_metric_soc_value = -99,
                  exposure_metric_plac_value = 0,
                  dist_position_scaler = 0.15)+
                 facet_grid(Endpoint~expname+exptile,scales="free",
                 margins = "exptile")
#Example 6
a <- gglogisticexpdist(data = effICGI, # 
                  response = "response",
                  endpoint = "Endpoint",
                  DOSE = "DOSE",yproj_dodge = 36,
                  exposure_metrics = c("AUC"),
                  exposure_metric_split = c("quartile"),
                  exposure_distribution ="lineranges",
                  exposure_metric_soc_value = -99,
                  exposure_metric_plac_value = 0) +
  facet_grid(Endpoint~expname,switch = "both")
b <-   gglogisticexpdist(data = effICGI, # 
                    response = "response",
                    endpoint = "Endpoint",
                    DOSE = "DOSE",yproj_dodge = 2,
                    exposure_metrics = c("CMAX"),
                    exposure_metric_split = c("quartile"),
                    exposure_distribution ="lineranges",
                    exposure_metric_soc_value = -99,
                    exposure_metric_plac_value = 0,
                    yaxis_position = "right")+
  facet_grid(Endpoint~expname,switch = "x")+
  theme(strip.text.y.right = element_blank(),
        strip.background.y = element_blank())
library(patchwork)
(a | b ) +
  plot_layout(guides = "collect")&
  theme(legend.position = "top")
                  

## End(Not run)

ggquickeda documentation built on June 22, 2024, 11:30 a.m.