fm_treemap: For comparing fm values, make a treemap as opposed to the...

View source: R/fm_treemap.R

fm_treemapR Documentation

For comparing fm values, make a treemap as opposed to the standard and arguably inferior pie chart

Description

Create a treemap – filled rectangles – to indicate the fraction of metabolism due to various pathways. Rectangles are proportional in size to the fm values and include labels for the drug-metabolizing enzyme involved and the percentage that enzyme is responsible for. Any rectangles that would be smaller than some user-specified cutoff (see argument "label_fm_cutoff") will be pulled out underneath the graph for readability. Why bother with a treemap as opposed to a pie chart? Rectangles are easier to compare visually than the sizes of pie slices, making a treemap easier to understand and interpret (reference: "The Visual Display of Quantitative Information" by Edward Tufte, Professor Emeritus of Political Science, Statistics, and Computer Science at Yale University).

Usage

fm_treemap(
  fm_dataframe,
  pathway_column,
  fm_column,
  DDI_option = "baseline only",
  show_numbers_on_graph = TRUE,
  rounding = NA,
  color_set = "default",
  label_fm_cutoff = 0.05,
  legend_nrow = NA,
  biggest_box_position = "top left",
  graph_title = NA,
  graph_title_size = 14,
  save_graph = NA,
  fig_height = 3,
  fig_width = 4
)

Arguments

fm_dataframe

a data.frame containing columns for the drug-metabolizing enzyme and the fm, the fraction metabolized. If you ran extractFmFe to get these data, be sure to only get the data you want. For example, if this was a DDI simulation, you would want to use only the data in the absense of a perpetrator or only in the presence of one; summing up both numbers wouldn't make sense.

pathway_column

the name of the column that contains the names of the pathways. If you ran extractFmFe to get these data, set this to pathway_column = Enzyme

fm_column

the name of the column that contains the fm values. If you ran extractFmFe to get these data, set this to fm_column = Max if you want the maximum fm value for each. Note that this should be the values as decimals, e.g., 0.8 for 80%. The total area occupied by boxes in your treemap will sum to 100%, even if these numbers do not, so pay attention to what data you're graphing and make sure things sum to 1.

DDI_option

If the fm_dataframe included fm and fe values for when any DDI perpetrator drugs are present, then you've got some options for how to display this. Acceptable options are: "baseline only" (default) to show only fm values at baseline, "DDI only", to show only fm values in the presence of the perpetrator drug(s), or "facet by DDI" to show two graphs, broken up by whether there is a DDI.

show_numbers_on_graph

TRUE (default) or FALSE for whether to list the numerical fm value for each pathway on the graph

rounding

option for what rounding to perform, if any. Options are:

"none"

No rounding will be performed.

"significant X" where "X" is a number

Output will be rounded to X significant figures. rounding = "signif X" also works fine. If you leave rounding as NA, the default is "significant 3".

"round X" where "X" is a number

Output will be rounded to X digits

color_set

the set of colors to use. Options are "default", which matches Simcyp colors in PowerPoint presentations and is rather nice, "set 1" for Brewer set 1, "set 2" for Brewer set 2 (colorblind friendly), "rainbow", which works well when there are a LOT of fm's to visualize, "blue-green", which makes a pretty gradient of blues and greens, "blues", which makes a graident of blues, or "viridis", which is 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.

label_fm_cutoff

cutoff to use for having a label show up underneath the graph; default is 0.05. You may want to play around with this a bit in the final graphic file because how this graph looks is extremely dependent on its dimensions.

legend_nrow

optionally specify the number of rows to use for the legend. If left as NA, there will be 1 row.

biggest_box_position

where to put the biggest box. Defaults to "top left", and other options are "bottom left", "bottom right", and "top right".

graph_title

optionally specify a title that will be centered across your graph

graph_title_size

the font size for the graph title if it's included

save_graph

optionally save the output graph by supplying a file name in quotes here, e.g., "My conc time graph.png". If you do not designate a file extension, it will be saved as a png file, but if you specify a different file extension, it will be saved as that file format. Acceptable 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 3

fig_width

figure width in inches; default is 4

Value

a ggplot2 graph

Examples


Lenv_fm <- data.frame(DME = c("CYP3A4", "other CYPs", "aldehyde oxidase"),
                      fm = c(0.79, 0.20, 0.01))
fm_treemap(fm_dataframe = Lenv_fm,
           pathway_column = DME, 
           fm_column = fm)

fm_treemap(fm_dataframe = Lenv_fm,
           pathway_column = DME, 
           fm_column = fm, 
           color_set = "blue-green", 
           label_fm_cutoff = 0.01)


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