A light-weight container that describes one analysis as a handful of plain
functions. The analysis never stores a pipeline: the 'RAVE' dashboard (the
controller) passes the pipeline, the shiny session, or the values of
the prerequisite pipeline targets to the methods that need them. Methods
whose names start with @ are called by the controller (the
dashboard or the pipeline), not by analysis developers.
When a pipeline is compiled, every analysis defined at the top level of a
R/shared-*.R script becomes the pipeline target named
results_target_name, plus the target
analysis_cleaned_inputs_<name> when the analysis has a custom
pipeline collector. The pipeline settings file must contain the key
inputs_settings_name; its value can start as an empty list.
Active bindings
nameanalysis name, read-only
input_namesnames of the registered inputs, read-only
optionsnamed list of options passed to the analyze and visualize steps; assigning replaces the whole list and must be a named list (
list()clears it). Useset_optionto change individual optionspipeline_targetsnames of the pipeline targets whose values the
preprocessstep receives, read-only; seeset_preprocessinputs_settings_namename of the pipeline settings that holds the saved input values, read-only
results_target_namename of the pipeline target that holds the analysis result, read-only
@nsshiny namespace function:
ns(id)adds the namespace prefix toid, andns(NULL)returns the prefix
Methods
RAVEPipelineAnalysis$set_option()
Set options one key at a time; this is how to change
individual options, since analysis$options$key <- value is not
reliable on an active binding
Usage
RAVEPipelineAnalysis$set_option(..., .list = list(), .clear_first = FALSE)RAVEPipelineAnalysis$new()
Constructor
Usage
RAVEPipelineAnalysis$new(
name,
namespace,
description = gsub("[_]+", " ", name)
)Arguments
nameanalysis name, a single string of letters, digits, and underscores that starts with a letter; used as the prefix of the input identifiers
namespaceshiny module namespace under which the inputs are rendered, usually the module ID; a single non-empty string
descriptiona short text describing the analysis; default is the name with underscores replaced by spaces
RAVEPipelineAnalysis$get_id()
Get the identifier of an input or output element
RAVEPipelineAnalysis$set_input_ui()
Register the function that renders an input
RAVEPipelineAnalysis$@render_input()
Render an input registered by set_input_ui
Arguments
input_nameinput name
pipelinea
PipelineToolsinstance from which the saved input values are restored, see@collect_inputs_from_pipeline
RAVEPipelineAnalysis$render_inputs()
Render all registered inputs, each showing the input values saved in the pipeline; requires htmltools
Arguments
pipelinea
PipelineToolsinstance from which the saved input values are restored
RAVEPipelineAnalysis$set_collect_inputs_from_shiny()
Register the function that collects the input values from shiny
Arguments
collect_funcfunction(session)returning the input values as a named list, wheresessionis scoped to the analysisnamespace;NULLrestores the default, which reads the registered inputs withinshiny::isolate(). A custom function is called as is, so it should isolate its own reads if it may run outside of a reactive context
RAVEPipelineAnalysis$@collect_inputs_from_shiny()
Collect the input values from a shiny session
RAVEPipelineAnalysis$set_collect_inputs_from_pipeline()
Register the function that restores the input values from a pipeline
Arguments
collect_funcfunction(pipeline_settings)returning the input values as a named list, wherepipeline_settingsis the named list of pipeline settings;NULLrestores the default, which reads the settings namedinputs_settings_name. The settings are resolved in the dashboard and when the pipeline is compiled, but come straight from the settings file when the pipeline runs, so settings stored as external data differ between the two
RAVEPipelineAnalysis$@collect_inputs_from_pipeline()
Restore the input values saved in a pipeline
Arguments
pipeline_settingsnamed list of pipeline settings, or a
PipelineToolsinstance whose settings are used
RAVEPipelineAnalysis$set_store_inputs_to_pipeline()
Register the function that converts the input values before they are saved to a pipeline
Arguments
store_funcfunction(inputs, pipeline)returning the named list to save as the pipeline settings namedinputs_settings_name; its value is always saved.NULLrestores the default, which saves the input values unchanged. This is the only step that receives the pipeline, so it may save some values as other settings; those are not part of the saved inputs, so list them in thepipeline_targetsofset_preprocessif the analysis depends on them
RAVEPipelineAnalysis$@store_inputs_to_pipeline()
Save the input values to the pipeline settings named
inputs_settings_name
Arguments
inputsinput values, usually from
@collect_inputs_from_shinypipelinea
PipelineToolsinstance
RAVEPipelineAnalysis$@test_roundtrip_pipeline_inputs()
Check that the input values survive being saved to a
settings file and read back; the check uses a temporary copy of the
pipeline, so pipeline is not changed
Arguments
pipelinea
PipelineToolsinstance holding the input values to check
RAVEPipelineAnalysis$@shiny_server()
Start the shiny module server registered by
set_shiny_server
RAVEPipelineAnalysis$set_preprocess()
Register the preprocess step
Arguments
preprocess_funcfunction(value, pipeline_targets)returning the processed values, which must hold everything the analyze step needs, orNULLto remove the steppipeline_targetsnames of the pipeline targets that must be built before the
preprocessstep; their values are passed to thepreprocessstep only. Default isNULL(none)
RAVEPipelineAnalysis$@preprocess_data()
Process the collected input values before the analysis
RAVEPipelineAnalysis$set_analyze()
Register the analyze step
RAVEPipelineAnalysis$@analyze_data()
Run the analysis with the current options; this
method does not call @preprocess_data, so pass its result in.
The analyze step receives only the processed values and the options
RAVEPipelineAnalysis$set_visualize()
Register the visualize step
RAVEPipelineAnalysis$@visualize_data()
Visualize the analysis result with the current
options
RAVEPipelineAnalysis$run()
Run the analysis with a pipeline, without the 'RAVE' dashboard
Arguments
pipelinea
PipelineToolsinstancestepwhere to stop:
"inputs"returns the collected input values,"preprocess"the processed values, and"analyze"the analysis result;"all"and"visualize"are the same, and also run the visualize stepeval_method"run"saves the input values to the pipeline and builds the targetresults_target_name, which must exist;"debug"computes the analysis in this session without that target, for analyses not yet compiled into the pipeline, and does not save the input values. In debug mode, and forstepset to"preprocess", the prerequisite targets are read from the pipeline, so they must have been builtsessionshiny session to collect the input values from; default is
NULL, which restores them from the pipeline settingsvisualization_method"direct"calls the visualize step;"html"renders it as anHTMLfragment, which requires rmarkdown...passed to the
runmethod of the pipeline wheneval_methodis"run"
RAVEPipelineAnalysis$run_as_task()
Save the input values to the pipeline, then build the
target results_target_name as a shiny extended task
Arguments
pipelinea
PipelineToolsinstancesessionshiny session to collect the input values from; default is
NULL, which restores them from the pipeline settings...passed to the
run_as_taskmethod of the pipeline
RAVEPipelineAnalysis$@build_targets()
Create the pipeline target specifications for this analysis; called when the pipeline is compiled