Skip to content

Commit

Permalink
Merge pull request #177 from Open-Systems-Pharmacology/adding_examples
Browse files Browse the repository at this point in the history
adding vignette urls to docs
  • Loading branch information
IndrajeetPatil committed Oct 12, 2021
2 parents 3ce8490 + 9f84416 commit be21543
Show file tree
Hide file tree
Showing 13 changed files with 540 additions and 342 deletions.
15 changes: 11 additions & 4 deletions R/plot-boxwhisker.R
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
#' @title plotBoxWhisker
#' @param data data.frame (or list of data.frames? TO BE DISCUSSED)
#'
#' @param data A data.frame (or list of data.frames? TO BE DISCUSSED)
#' containing the data to be used for the plot
#' @param metaData list of lists (structure TO BE DISCUSSED)
#' @param metaData A list of lists (structure TO BE DISCUSSED)
#' containing complementary information to data (e.g. unit)
#' @param outliers logical defining if outliers should be included in boxplot
#' @param dataMapping `BoxWhiskerDataMapping` object
#' mapping of x, y axes + mapping of colorGrouping, sizeGrouping, shapeGrouping
#' @param plotConfiguration `BoxWhiskerConfiguration` object
#' @param plotConfiguration A `BoxWhiskerConfiguration` object
#' Plot Configuration defining title, subtitle, xlabel, ylabel watermark, and legend
#' @param plotObject
#' ggplot object, if null creates new plot, if not add time profile layers to ggplot
#'
#' @description
#' plotBoxWhisker(data, metaData, dataMapping, plotConfiguration)
#' Producing box-and-whisker plots
#'
#' @return a ggplot graphical object
#'
#' @references For examples, see:
#' <https://www.open-systems-pharmacology.org/TLF-Library/articles/box-whisker-vignette.html>
#'
#' @export
plotBoxWhisker <- function(data,
metaData = NULL,
Expand Down
35 changes: 22 additions & 13 deletions R/plot-pkratio.R
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
#' @title plotPKRatio
#'
#' @param data data.frame containing the data to be used for the plot
#' @param metaData list of lists
#' containing complementary information to data (e.g. their unit and dimension).
#' This parameter is optional.
#' @param dataMapping
#' `PKRatioDataMapping` class or subclass mapping x and y variables to `data` variable names.
#' `dataMapping` provides also the values of the PK Ratio limits plotted as horizontal lines.
#' This parameter is optional: the `tlf` library provides a smart mapping if only `data` is provided
#' and default values of the PK Ratio limits.
#' @param plotConfiguration
#' `PKRatioPlotConfiguration` class or subclass defining labels, grid, background and watermark
#' This parameter is optional: the `tlf` library provides a default configuration according to the current theme
#' @param plotObject `ggplot` graphical object to which the PK Ratio plot layer is added
#' This parameter is optional: the `tlf` library will initialize an empty plot if the parameter is NULL or not provided
#' @param metaData list of lists containing complementary information to data
#' (e.g. their unit and dimension). This parameter is optional.
#' @param dataMapping A `PKRatioDataMapping` class or subclass mapping x and y
#' variables to `data` variable names. `dataMapping` provides also the values
#' of the PK Ratio limits plotted as horizontal lines. This parameter is
#' optional: the `tlf` library provides a smart mapping if only `data` is
#' provided and default values of the PK Ratio limits.
#' @param plotConfiguration A `PKRatioPlotConfiguration` class or subclass
#' defining labels, grid, background and watermark This parameter is optional:
#' the `tlf` library provides a default configuration according to the current
#' theme
#' @param plotObject `ggplot` graphical object to which the PK Ratio plot layer
#' is added This parameter is optional: the `tlf` library will initialize an
#' empty plot if the parameter is `NULL` or not provided.
#'
#' @description
#'
#' Add PK Ratio plot layers to a `ggplot` graphical object.
#' PK Ratio limits are plotted as horizontal lines.
#' PK Ratios are plotted as a scatter plot.
#'
#' @return A `ggplot` graphical object
#'
#' @references For examples, see:
#' <https://www.open-systems-pharmacology.org/TLF-Library/articles/pk-ratio-vignette.html>
#'
#' @export
plotPKRatio <- function(data,
metaData = NULL,
Expand Down
4 changes: 2 additions & 2 deletions R/themes.R
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ loadThemeFromJson <- function(jsonFile) {
}
propertyFields <- names(themeContent[[themeProperty]])
for (propertyField in propertyFields) {
if(isIncluded(themeProperty, "aestheticMaps")){
if (isIncluded(themeProperty, "aestheticMaps")) {
propertyExpression <- parse(text = paste0(
themeProperty, "$", propertyField, " <- themeContent$", themeProperty, "$", propertyField
))
Expand All @@ -549,7 +549,7 @@ loadThemeFromJson <- function(jsonFile) {
background$watermark <- themeContent$background$watermark
background$legendPosition <- themeContent$background$legendPosition
}

return(Theme$new(
fonts = fonts,
background = background,
Expand Down
6 changes: 3 additions & 3 deletions R/utilities-aesthetics.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ Linetypes <- enum(c(
#' @export
Shapes <- list(
"circle" = "circle",
"square" = 'square',
"square" = "square",
"diamond" = "diamond",
"triangle" = "triangle",
"triangleDown" = "triangle down filled",
"cross" = "cross",
"plus" = "plus",
"asterisk" = "asterisk",
"blank" = ' ',
"blank" = " ",
"dot" = "bullet",
"hollowCircle" = "circle open",
"hollowSquare" = "square open",
Expand Down Expand Up @@ -70,7 +70,7 @@ asPlotShape <- function(shapes) {
ggplotShapes <- NULL
for (shape in shapes) {
ggplotShape <- as.character(shape)
if(isIncluded(ggplotShape, names(Shapes))){
if (isIncluded(ggplotShape, names(Shapes))) {
ggplotShape <- Shapes[[shape]]
}
ggplotShapes <- c(ggplotShapes, ggplotShape)
Expand Down
4 changes: 2 additions & 2 deletions man/enum.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions man/plotBoxWhisker.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 18 additions & 11 deletions man/plotPKRatio.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vignettes/atom-plots.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ The output plot from *initializePlot()* is a regular `ggplot` object to which a
Since this method is at the core of every atom and molecule plots of the `tlf`-library, any plot generated using this package will include a *plotConfiguration* field.

Below are a few examples of use case of *initializePlot*:

```{r initializePlot}
# Inintialize an empty plot without specific configuration, use the current theme
emptyPlot <- initializePlot()
Expand Down
Loading

0 comments on commit be21543

Please sign in to comment.