Draws data points and model curves, with or without a linearising transformation, and returns a ggplot that you can print, save or change further.
Usage
make_plot(
model,
data.df = NULL,
curve.df = NULL,
extra.curve = NULL,
plot.transformation = "standard",
conf.int = FALSE,
x.label = NULL,
y.label = NULL,
x.units = NULL,
y.units = NULL,
title = NULL,
legend.label = NULL,
palette = "Set1",
hide.legend = FALSE,
y.range = NULL,
show.grid = FALSE
)Arguments
- model
The model's code, one of VALID_MODELS, e.g.
"MM".- data.df
Data to draw as points: a data frame with the model's variables as columns, e.g. from
simulate_data()or your own data. Optional.- curve.df
A curve to draw as lines, from
make_curve(). Optional.- extra.curve
A second curve, drawn in black on top. EKA2 uses it for the true curve of simulated data. Optional.
- plot.transformation
"standard"(default),"log10","lineweaver","hanes","eadie"or"direct". See Details.- conf.int
If
TRUE, shade the parameter uncertainty envelope.curve.dfmust then come frommake_curve(..., conf.int = TRUE). DefaultFALSE.- x.label, y.label
Axis labels to use instead of the defaults. Units are still added.
- x.units, y.units
The units of the raw x and y variables, e.g.
"mM"and"mM/min", added to the axis labels.- title
A plot title to use instead of the default (the model's name and the transformation).
- legend.label
A legend title to use instead of the default (the extra variable's name).
- palette
A ColorBrewer palette from PLOT_COLOUR_PALETTES (default
"Set1").- hide.legend
If
TRUE, hide the legend. DefaultFALSE.- y.range
The y-axis limits, a numeric vector of two values. Values outside them aren't drawn. Default
NULL(automatic).- show.grid
If
TRUE, draw grid lines. DefaultFALSE.
Details
Transformations (plot.transformation). The data and the curves are
transformed in the same way, so a transformed plot shows the model's curve
rather than a straight line fitted to the transformed points.
"standard": v against a."log10": v against log10(a)."lineweaver": the Lineweaver-Burk plot, 1/v against 1/a. Each curve is extended to the 1/a axis, and a dotted line marks 1/a = 0."hanes": the Hanes plot, a/v against a."eadie": the Eadie-Hofstee plot, v against v/a. The envelope isn't drawn on this plot."direct": the direct linear plot, Michaelis-Menten only. Each data point (a, v) becomes a line through (-a, 0) and (0, v) in (Km, Vmax) space, and the lines meet near the best estimates. It needsdata.dfand ignores any curves.
Not every transformation suits every model: see BLOCKED_TRANSFORMATIONS. Points that a transformation makes infinite (e.g. 1/0) are dropped with a warning.
Colours. Models with an extra variable (I, B or R) get a colour
and a legend entry per value. Other models are drawn in one colour without
a legend. If the palette has too few colours, ggplot2's default palette is
used instead.
Axes. x.units and y.units are the units of the raw variables, and
the axis labels show the units of what is plotted (e.g. 1/mM on a
Lineweaver-Burk plot). For the binding models the y-axis shows 0 to 1
unless y.range is given.
See also
make_curve() for curves, make_residual_plot() for residuals,
update_plot_curve() to replace a plot's curve.
Examples
set.seed(1)
mm <- simulate_data("MM", list(Km = 0.5, Vmax = 2), x.min = 0.2, x.max = 5,
n.samples = 8)
curve <- make_curve("MM", list(Km = 0.5, Vmax = 2), x.min = 0.2, x.max = 5)
make_plot("MM", data.df = mm, curve.df = curve, x.units = "mM",
y.units = "mM/min")
# The same data and curve as a Lineweaver-Burk plot
make_plot("MM", data.df = mm, curve.df = curve,
plot.transformation = "lineweaver")
# The direct linear plot (data only)
make_plot("MM", data.df = mm, plot.transformation = "direct")
# The result is a ggplot, so it can be changed further
make_plot("MM", data.df = mm, curve.df = curve) + ggplot2::theme_bw()
