plotResponseSurface: Plot response surface

View source: R/plotReponseSurface.R

plotResponseSurfaceR Documentation

Plot response surface

Description

Plot the 3-dimensional response surface predicted by one of the null models. This plot allows for a visual comparison between the null model prediction and observed points. This function is mainly used as the workhorse of plot.ResponseSurface method.

Usage

plotResponseSurface(
  data,
  fitResult = NULL,
  transforms = fitResult$transforms,
  predSurface = NULL,
  null_model = c("loewe", "hsa", "bliss", "loewe2"),
  colorPalette = c("red", "grey70", "blue"),
  colorPaletteNA = "grey70",
  colorBy = "none",
  addPoints = TRUE,
  colorPoints = c("black", "sandybrown", "brown", "white"),
  breaks,
  radius = 4,
  logScale = TRUE,
  colorfun = median,
  zTransform = function(x) x,
  add = FALSE,
  main = "",
  legend = FALSE,
  xat = "actual",
  yat = "actual",
  plotfun = NULL,
  gradient = TRUE,
  width = 800,
  height = 800,
  title = "",
  digitsFunc = function(x) {
     x
 },
  ...
)

Arguments

data

Object "data" from the output of fitSurface

fitResult

Object "fitResult" from the output of fitSurface

transforms

Object "transforms" from the output of fitSurface

predSurface

Vector of all predicted responses based on expand.grid(uniqueDoses). If not supplied, it will be computed with predictOffAxis function.

null_model

If predSurface is not supplied, it is computed using one of the available null models, i.e. "loewe", "hsa", "bliss" and "loewe2". See also fitSurface.

colorPalette

Vector of color names for surface

colorPaletteNA

Color used in the matrix of colours when the combination of doses doesn't exist (NA)

colorBy

This parameter determines values on which coloring is based for the 3-dimensional surface. If matrix or a data frame with d1 and d2 columns is supplied, dose combinations from colorBy will be matched automatically to the appropriate dose combinations in data. Unmatched dose combinations will be set to 0. This is especially useful for plotting results for off-axis estimates only, e.g. off-axis Z-scores or maxR test statistics. If colorBy = "colors", surface will be colored using colors in colorPalette argument.

addPoints

Boolean whether the dose points should be included

colorPoints

Colors for off-axis and on-axis points. Character vector of length four with colors for 1) off-axis points; 2) on-axis points of the first drug (i.e. second drug is dosed at zero); 3) on-axis points of the second drug; 4) on-axis points where both drugs are dosed at zero.

breaks

Numeric vector with numerical breaks. To be used in conjunction with colorPalette argument. If named, the labels will be displayed in the legend

radius

Size of spheres (default is 4)

logScale

Draw doses on log-scale (setting zeroes to be finite constant)

colorfun

If replicates in colorBy variable are present, these will be aggregated using colorfun function. This can also be a custom function returning a scalar.

zTransform

Optional transformation function for z-axis. By default, identity function is used.

add

(deprecated) Add the predicted response surface to an existing plot. Will not draw any points, just the surface. Must be called after another call to plotResponseSurface.

main

Fixed non-moving title for the 3D plot

legend

Whether legend should be added (default FALSE)

xat

x-axis ticks: "pretty", "actual" or a numeric vector

yat

y-axis ticks: "pretty", "actual" or a numeric vector

plotfun

If replicates for dose combinations in data are available, points can be aggregated using plotfun function. Typically, it will be mean, median, min or max but a custom-defined function returning a scalar from a vector is also possible.

gradient

Boolean indicating whether colours should be interpolated between breaks (default TRUE). If FALSE, colorPalette must contain length(breaks)-1 colours

width

Width in pixels (optional, defaults to 800px).

height

Height in pixels (optional, defaults to 800px).

title

String title (default "")

digitsFunc

Function to be applied to the axis values

...

Further arguments to format axis labels

Value

Plotly plot

Examples

## Not run: 
  data <- subset(directAntivirals, experiment == 1)
  ## Data must contain d1, d2 and effect columns
  fitResult <- fitMarginals(data)
  data_mean <- aggregate(effect ~ d1 + d2, data = data[, c("d1", "d2", "effect")],
                         FUN = mean)

  ## Construct the surface from marginal fit estimates based on HSA
  ## model and color it by mean effect level
  plotResponseSurface(data, fitResult, null_model = "hsa",
                      colorBy = data_mean, breaks = 10^(c(0, 3, 4, 6)),
                      colorPalette = c("grey", "blue", "green"))

  ## Response surface based on Loewe additivity model and colored with
  ## rainbow colors.
  plotResponseSurface(data, fitResult, null_model = "loewe", breaks = c(-Inf, 0, Inf),
                      colorBy = "colors", colorPalette = rainbow(6))

## End(Not run)

BIGL documentation built on July 9, 2023, 7:15 p.m.