VBE_safe_space_plot: Make dissolution safe-space plots

View source: R/VBE_safe_space_plot.R

VBE_safe_space_plotR Documentation

Make dissolution safe-space plots

Description

VBE_safe_space_plot makes dissolution safe-space plots comparing predicted dissolution values to observed and includes shading to indicate the safe space for bioequivalence.

Usage

VBE_safe_space_plot(
  VBE_dataframe,
  color_set = NA,
  safe_space_color = NA,
  safe_space_trans = NA,
  linetypes = NA,
  linewidths = NA,
  point_shapes = NA,
  point_sizes = NA,
  save_graph = NA,
  fig_height = NA,
  fig_width = NA
)

Arguments

VBE_dataframe

a data.frame of virtual bioequivalence dissolution data with the following columns:

Type

the type of formulation being tested. In the graph, you can change the color of the lines based on the values in the column "Type".

SorO

Are the data simulated or observed? The values in this column can be anything you prefer as long as there are only two of them, e.g., "simulated" and "observed" or "hypothetical" and "actual". In the graph, you can change the point shape and the line type based on the values in the column "SorO".

Time

the time in hours

Dissolution

the percent dissolution. This should be specified as, e.g., 0.5 for 50%.

Limit

This column will be used for specifying which data sets are the upper and lower limits of the safe space. Data sets that do not describe the upper or lower limits should have NA in this column, and the upper- and lower-limit datasets should be specified as "upper" and "lower".

For an example, please view the object "VBE_disso_example" and set up your data like that.

color_set

the set of colors to use. Options:

"default"

a set of colors from Cynthia Brewer et al. from Penn State that are friendly to those with red-green colorblindness. The first three colors are green, orange, and purple. This can also be referred to as "Brewer set 2". If there are only two unique values in the "Type" column, then Brewer set 1 will be used since red and blue are still easily distinguishable but also more aesthetically pleasing than green and orange.

"Brewer set 1"

colors selected from the Brewer palette "set 1". The first three colors are red, blue, and green.

"ggplot2 default"

the default set of colors used in ggplot2 graphs (ggplot2 is an R package for graphing.)

"rainbow"

colors selected from a rainbow palette. The default palette is limited to something like 6 colors, so if you have more than that, that's when this palette is most useful. It's not very useful when you only need a couple of colors.

"blue-green"

a set of blues fading into greens. This palette can be especially useful if you are comparing a systematic change in some continuous variable – for example, increasing dose or predicting how a change in intrinsic solubility will affect concentration-time profiles – because the direction of the trend will be clear.

"blues"

a set of blues fading from sky to navy. Like "blue-green", this palette can be especially useful if you are comparing a systematic change in some continuous variable.

"greens"

a set of greens fading from chartreuse to forest. Great for showing systematic changes in a continuous variable.

"purples"

a set of purples fading from lavender to aubergine. Great for showing systematic changes in a continuous variable.

"reds"

a set of reds from pink to brick. Great for showing systematic changes in a continuous variable.

"Tableau"

uses the standard Tableau palette; requires the "ggthemes" package

"viridis"

from the eponymous package by Simon Garnier and ranges colors from purple to blue to green to yellow in a manner that is "printer-friendly, perceptually uniform and easy to read by those with colorblindness", according to the package author

a character vector of colors

If you'd prefer to set all the colors yourself to exactly the colors you want, you can specify those colors here. An example of how the syntax should look: color_set = c("dodgerblue3", "purple", "#D8212D") or, if you want to specify exactly which item in Type gets which color, you can supply a named vector. For example, you could do this: color_set = c("Formulation A" = "dodgerblue3", "Formulation B" = "purple", "Test 1" = "#D8212D"). If you'd like help creating a specific gradation of colors, please talk to a member of the R Working Group about how to do that using colorRampPalette.

safe_space_color

color to use for indicating the safe space; any color that's acceptable in R will be acceptable here.

safe_space_trans

transparency to use for the safe space from 0 (fully transparent, i.e., invisible) to 1 (fully opaque)

linetypes

the line type(s) to use for the graph. Possible options can be seen by typing ggpubr::show_line_types() into the console.

linewidths

the line widths to use (numeric)

point_shapes

the point shape(s) to use for the graph. Possible options can be seen by typing ggpubr::show_point_shapes() into the console.

point_sizes

the point sizes (numeric)

save_graph

optionally save the output graph by supplying a file name in quotes here, e.g., "Demographics comparisons.png". Acceptable graphical file extensions are "eps", "ps", "jpeg", "jpg", "tiff", "png", "bmp", or "svg". Do not include any slashes, dollar signs, or periods in the file name. Leaving this as NA means the file will not be saved to disk.

fig_height

figure height in inches; default is 6

fig_width

figure width in inches; default is 8

Value

a ggplot2 graph

Examples

# Using example data included in the package 
VBE_safe_space_plot(VBE_dataframe = VBE_disso_example)

# Setting some colors for actual and hypothetical datasets
MyColors_actual <- reds(4)
names(MyColors_actual) <- c("Formulation A",
                            "Formulation B",
                            "Formulation C", 
                            "Formulation D")

MyColors_hyp <- blues(6)
names(MyColors_hyp) <- paste("Test", 1:6)

MyColors <- c(MyColors_actual, MyColors_hyp)

VBE_safe_space_plot(VBE_dataframe = VBE_disso_example,
                    color_set = MyColors,
                    safe_space_color = "gray80",
                    linetypes = c("solid", "longdash"),
                    save_graph = "VBE safe space.png",
                    fig_height = 4, fig_width = 6)



shirewoman2/Consultancy documentation built on June 1, 2025, 6:05 p.m.