A TealDatasetConnector class of objects
TealDatasetConnector.Rd
Objects of this class store the connection function to fetch a single dataset.
Note that for some specific connection types,
an object of class
TealDataConnection must be provided.
Data can be pulled via the pull method and accessed directly
through the dataset active binding.
Pulled data inherits from the class TealDataset
Methods
Method new()
Create a new TealDatasetConnector object. Set the pulling function
CallableFunction which returns a data.frame or MultiAssayExperiment,
e.g. by reading from a function or creating it on the fly.
Usage
TealDatasetConnector$new(
dataname,
pull_callable,
keys = character(0),
label = character(0),
code = character(0),
vars = list(),
metadata = NULL
)Arguments
dataname(
character)
A given name for the dataset it may not contain spacespull_callable(
CallableFunction)
function with necessary arguments set to fetch data from connection.keysoptional, (
character)
vector of dataset primary keys column nameslabel(
character)
Label to describe the dataset.code(
character)
A character string defining code to modifyraw_datafrom this dataset. To modify current dataset code should contain at least one assignment to object defined indatanameargument. For example ifdataname = ADSLexample code should containADSL <- <some R code>. Can't be used simultaneously withscriptvars(named
list))
In case when this object code depends on otherTealDatasetobject(s) or other constant value, this/these object(s) should be included as named element(s) of the list. For example if this object code needsADSLobject we should specifyvars = list(ADSL = <adsl object>). It's recommended to includeTealDatasetorTealDatasetConnectorobjects to thevarslist to preserve reproducibility. Please note thatvarsare included to this object as localvarsand they cannot be modified within another dataset.metadata(named
list,NULLorCallableFunction)
Field containing either the metadata about the dataset (each element of the list should be atomic and length one) or aCallableFuntionto pull the metadata from a connection. This should return alistor an object which can be converted to a list withas.list.
Method print()
Prints this TealDatasetConnector.
Method get_dataname()
Get dataname of dataset
Method get_dataset_label()
Get label of dataset
Method get_keys()
Get primary keys of dataset
Method get_code()
Get code to get data
Method get_dataset()
Get dataset
Method get_raw_data()
Get raw data from dataset
Method get_var_r6()
Get the list of dependencies that are TealDataset or TealDatasetConnector objects
Method reassign_datasets_vars()
Reassign vars in this object to keep references up to date after deep clone.
Update is done based on the objects passed in datasets argument. Reassignment
refers only to the provided datasets, other vars remains the same.
Method set_keys()
Set new keys
Method set_join_keys()
set join_keys for a given dataset and self
Method mutate_join_keys()
mutate the join_keys for a given dataset and self
Method pull()
Pull the data (and metadata if it is a Callable)
Read or create data using pull_callable specified in the constructor.
Arguments
args(
NULLor namedlist)
additional dynamic arguments for pull function.argscan be omitted ifpull_callablefrom constructor already contains all necessary arguments to pull data. One can try to executepull_callabledirectly byx$pull_callable$run()or to get code usingx$pull_callable$get_code().argsspecified in pull are used temporary to get data but not saved in code.try(
logicalvalue)
whether perform function evaluation insidetryclause
Method set_args()
Set arguments to the pulling function
Method mutate()
Dispatcher for either eager or delayed mutate methods
Either code or script must be provided, but not both.
Usage
TealDatasetConnector$mutate(code, vars = list())Arguments
code(
character)
A character string defining code to modifyraw_datafrom this dataset. To modify current dataset code should contain at least one assignment to object defined indatanameargument. For example ifdataname = ADSLexample code should containADSL <- <some R code>. Can't be used simultaneously withscriptvars(named
list))
In case when this object code depends on otherTealDatasetobject(s) or other constant value, this/these object(s) should be included as named element(s) of the list. For example if this object code needsADSLobject we should specifyvars = list(ADSL = <adsl object>). It's recommended to includeTealDatasetorTealDatasetConnectorobjects to thevarslist to preserve reproducibility. Please note thatvarsare included to this object as localvarsand they cannot be modified within another dataset.
Method is_pulled()
Check if dataset has already been pulled.
Method check()
Check to determine if the raw data is reproducible from the
get_code() code.
Method set_ui_input()
Sets the shiny UI according to the given inputs. Inputs must provide only scalar (length of 1) variables.
Arguments
inputs(
function) A shiny module UI function with single argumentns. This function needs to return a list of shiny inputs with theirinputIdwrapped in functionns. TheinputIdmust match exactly the argument name to be set. See example. Nested lists are not allowed.
Examples
ds <- dataset_connector("xyz", pull_callable = callable_function(data.frame))
ds$set_ui_input(
function(ns) {
list(sliderInput(ns("colA"), "Select value for colA", min = 0, max = 10, value = 3),
sliderInput(ns("colB"), "Select value for colB", min = 0, max = 10, value = 7))
}
)
\dontrun{
ds$launch()
}
Method launch()
Launches a shiny app.
Examples
ds <- dataset_connector("xyz", pull_callable = callable_function(data.frame))
ds$set_ui_input(
function(ns) {
list(sliderInput(ns("colA"), "Select value for colA", min = 0, max = 10, value = 3),
sliderInput(ns("colB"), "Select value for colB", min = 0, max = 10, value = 7))
}
)
\dontrun{
ds$launch()
}
Examples
## ------------------------------------------------
## Method `TealDatasetConnector$set_ui_input`
## ------------------------------------------------
ds <- dataset_connector("xyz", pull_callable = callable_function(data.frame))
ds$set_ui_input(
function(ns) {
list(sliderInput(ns("colA"), "Select value for colA", min = 0, max = 10, value = 3),
sliderInput(ns("colB"), "Select value for colB", min = 0, max = 10, value = 7))
}
)
if (FALSE) {
ds$launch()
}
## ------------------------------------------------
## Method `TealDatasetConnector$launch`
## ------------------------------------------------
ds <- dataset_connector("xyz", pull_callable = callable_function(data.frame))
ds$set_ui_input(
function(ns) {
list(sliderInput(ns("colA"), "Select value for colA", min = 0, max = 10, value = 3),
sliderInput(ns("colB"), "Select value for colB", min = 0, max = 10, value = 7))
}
)
if (FALSE) {
ds$launch()
}