Include custom plots that the app will display when a feature is selected by the user.
addPlots(study, plots, reset = FALSE)
Returns the original onStudy
object passed to the argument
study
, but modified to include the newly added data
An OmicNavigator study created with createStudy
Custom plotting functions for the study. The input object is a
nested list. The first list corresponds to the modelID(s). The second list
corresponds to the name(s) of the function(s) defined in the current R
session. The third list provides metadata to describe each plot. The only
required metadata element is displayName
, which controls how the
plot will be named in the app. You are encouraged to also specify the
plotType
, e.g. "singleFeature"
, "multiFeature"
,
"multiTest"
, "multiModel"
. PlotType accepts vector of
entries, whenever applicable, e.g., plotType = c("multiFeature"
,
"multiTest"
). If you do not specify the plotType
, the plot
will be assumed to be "singleFeature"
and "singleTest"
.
Optionally, if the plotting function requires external packages, these can
be defined in the element packages
. To share plots across multiple
models, use the modelID "default". To add a plotting function that returns
an interactive plotly plot, add "plotly" to the plotType
vector.
Reset the data prior to adding the new data (default:
FALSE
). The default is to add to or modify any previously added data
(if it exists). Setting reset = TRUE
enables you to remove existing
data you no longer want to include in the study.
Custom plotting functions are passed a list of data frames: assays
with the measurements, features
with the feature data,
samples
with the sample data, and results
with test results
data. Note that assays
, features
and results
only include data for the specified featureID(s) (and
re-ordered so their rows match). Thus your custom plotting function must have
at least one argument. It can have additional arguments if you wish, but
these must be provided with default values, because plotStudy
only
passes the plotting data to the first argument.
Note that any ggplot2 plots will require extra care. This is because the
plotting code will be inserted into a study package, and thus must follow the
best
practices for using ggplot2 within packages. Specifically, when you refer to
columns of the data frame, e.g. aes(x = group)
, you need to prefix it
with .data$
, so that it becomes aes(x = .data$group)
.
Fortunately this latter code will also run fine as you interactively develop
the function.
getPlottingData
, plotStudy