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.keys
optional, (
character
)
vector of dataset primary keys column nameslabel
(
character
)
Label to describe the dataset.code
(
character
)
A character string defining code to modifyraw_data
from this dataset. To modify current dataset code should contain at least one assignment to object defined indataname
argument. For example ifdataname = ADSL
example code should containADSL <- <some R code>
. Can't be used simultaneously withscript
vars
(named
list
))
In case when this object code depends on otherTealDataset
object(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 needsADSL
object we should specifyvars = list(ADSL = <adsl object>)
. It's recommended to includeTealDataset
orTealDatasetConnector
objects to thevars
list to preserve reproducibility. Please note thatvars
are included to this object as localvars
and they cannot be modified within another dataset.metadata
(named
list
,NULL
orCallableFunction
)
Field containing either the metadata about the dataset (each element of the list should be atomic and length one) or aCallableFuntion
to pull the metadata from a connection. This should return alist
or 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 pull()
Pull the data (and metadata if it is a Callable
)
Read or create data using pull_callable
specified in the constructor.
Arguments
args
(
NULL
or namedlist
)
additional dynamic arguments for pull function.args
can be omitted ifpull_callable
from constructor already contains all necessary arguments to pull data. One can try to executepull_callable
directly byx$pull_callable$run()
or to get code usingx$pull_callable$get_code()
.args
specified in pull are used temporary to get data but not saved in code.try
(
logical
value)
whether perform function evaluation insidetry
clause
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_data
from this dataset. To modify current dataset code should contain at least one assignment to object defined indataname
argument. For example ifdataname = ADSL
example code should containADSL <- <some R code>
. Can't be used simultaneously withscript
vars
(named
list
))
In case when this object code depends on otherTealDataset
object(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 needsADSL
object we should specifyvars = list(ADSL = <adsl object>)
. It's recommended to includeTealDataset
orTealDatasetConnector
objects to thevars
list to preserve reproducibility. Please note thatvars
are included to this object as localvars
and 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 theirinputId
wrapped in functionns
. TheinputId
must 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()
}