demog_plot_sim: Make plots for comparing populations across simulations

View source: R/demog_plot_sim.R

demog_plot_simR Documentation

Make plots for comparing populations across simulations

Description

UNDER CONSTRUCTION.

Usage

demog_plot_sim(
  demog_dataframe,
  sims_to_include = "all",
  demog_parameters = NA,
  variability_display = "kernel density",
  colorBy_column,
  color_set = "default",
  color_labels = NA,
  legend_label_color = NA,
  legend_position = "bottom",
  graph_title = "Demographics",
  alpha = 0.8,
  ncol = NULL,
  nrow = NULL,
  facet_by_sex = TRUE,
  facet_column_additional,
  border_facets = TRUE,
  graph_labels = TRUE,
  save_graph = NA,
  fig_height = 8,
  fig_width = 6
)

Arguments

demog_dataframe

the output from running extractDemog.

sims_to_include

optionally specify which simulations to include. These must be included in demog_dataframe in the column "File".

demog_parameters

demographic parameters to include. We're starting with a limited set:

  • Individual parameters, which will be displayed as either a kernel density plot or a boxplot depending on your choice for variability_display:

    • "Age" (age in years)

    • "AGP_gL" (alpha-1-acid glycoprotein in g/L; "AGP" is fine)

    • "BMI_kgm2" ("BMI" is fine)

    • "BrainWt_g" (brain weight; "Brain" is fine)

    • "BSA_m2" (body surface area in m2; "BSA" is fine)

    • "CardiacOut" (cardiac output in L/h; "Cardiac" is fine)

    • "Creatinine_umolL" (creatinine in umol/L; "Creatinine" is fine)

    • "GFR_mLminm2" (glomerular filtration rate in mL/min/m2; "GFR" is fine)

    • "Haematocrit" (haematocrit)

    • "Height_cm" (height in cm; "Height" is fine)

    • "HSA_gL" (human serum albumin in g/L; "HSA" is fine)

    • "KidneyWt_g" (kidney weight; "Kidney" is fine)

    • "LiverWt_g" (liver weight; "Liver" is fine)

    • "Sex" (graph shows the percent female by population)

    • "Weight_kg" (weight in kg; "Weight" is fine)

    • "RenalFunction" (renal function as calculated by the GFR in mL/min/m squared body surface area divided by the reference GFR for that sex: 120 for female subjects and 130 for male subjects as of V23 of the Simcyp Simulator)

    Comparisons of two parameters, which will create a scatter plot:

    • "Weight vs Height"

    • "Height vs Age"

    • "Weight vs Age"

    • "Sex vs Age"

If you want only a subset of those, list them in a character vector, e.g., demog_parameters = c("Age", "Height_cm", "Weight_kg"). Plots will be in the order you list.

variability_display

How should the variability be shown? Options are "kernel density" (default, a type of smoothed histogram) or "boxplot". Any demographic parameters requested in the form of "X vs Y", e.g., "weight vs height", will always be shown as scatter plots.

colorBy_column

the column in demog_dataframe that should be used for determining which color lines and/or points will be. This should be unquoted, e.g., colorBy_column = File. If left blank, we will color by the simulation file name.

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 colorBy_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. Like "blue-green", this palette can be especially useful if you are comparing a systematic change in some continuous variable.

"purples"

a set of purples fading from lavender to aubergine. Like "blue-green", this palette can be especially useful if you are comparing a systematic change in some 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 colorBy_column gets which color, you can supply a named vector. For example, if you're coloring the lines by the compound ID, you could do this: color_set = c("substrate" = "dodgerblue3", "inhibitor 1" = "purple", "primary metabolite 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.

color_labels

optionally specify a character vector for how you'd like the labels for whatever you choose for colorBy_column to show up in the legend. For example, use color_labels = c("file 1.xlsx" = "healthy subjects", "file 2.xlsx" = "renally impaired subjects") to indicate which simulations represent what. The order in the legend will match the order designated here.

legend_label_color

optionally indicate on the legend something explanatory about what the colors represent. For example, if colorBy_column = File and legend_label_color = "Population", that will make the label above the file names in the legend more explanatory than just "File". The default is to use whatever the column name is for colorBy_column. If you don't want a label for this legend item, set this to "none".

legend_position

specify where you want the legend to be. Options are "left", "right", "bottom" (default), "top", or "none" if you don't want one at all.

graph_title

title to use on the plots

alpha

how transparent to make the points, with 0 being completely transparent and invisible so I don't know why you'd want that but, hey, you do you, to 1, which is fully opaque.

ncol

optionally specify the number of columns. If left as NULL, a reasonable guess will be used.

nrow

optionally specify the number of rows. If left as NULL, a reasonable guess will be used.

facet_by_sex

TRUE or FALSE (default) for whether to break up the graphs into facets based on the sex of the subjects

facet_column_additional

optionally specify an additional column to facet the graphs by horizontally. If facet_by_sex is set to TRUE, the graphs will be broken up vertically by sex.

border_facets

TRUE (default) or FALSE for whether to include a border around the facets if the graphs are broken up by the sex of the subjects

graph_labels

TRUE or FALSE for whether to include labels (A, B, C, etc.) for each of the small graphs.

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 automatically saved to disk.

fig_height

figure height in inches; default is 8

fig_width

figure width in inches; default is 6

Value

a set of graphs. This does not yet save the graphs for you, so you'll need to run ggsave(...) to do that.

Examples

# none yet

shirewoman2/Consultancy documentation built on Feb. 18, 2025, 10 p.m.