addPlots {OmicNavigator}R Documentation

Add custom plotting functions

Description

Include custom plots that the app will display when a feature is selected by the user.

Usage

addPlots(study, plots, reset = FALSE)

Arguments

study

An OmicNavigator study created with createStudy

plots

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

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.

Details

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.

Value

Returns the original onStudy object passed to the argument study, but modified to include the newly added data

See Also

getPlottingData, plotStudy


[Package OmicNavigator version 1.13.13 Index]