Skip to contents

[Stable] 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 spaces

pull_callable

(CallableFunction)
function with necessary arguments set to fetch data from connection.

keys

optional, (character)
vector of dataset primary keys column names

label

(character)
Label to describe the dataset.

code

(character)
A character string defining code to modify raw_data from this dataset. To modify current dataset code should contain at least one assignment to object defined in dataname argument. For example if dataname = ADSL example code should contain ADSL <- <some R code>. Can't be used simultaneously with script

vars

(named list))
In case when this object code depends on other TealDataset 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 needs ADSL object we should specify vars = list(ADSL = <adsl object>). It's recommended to include TealDataset or TealDatasetConnector objects to the vars list to preserve reproducibility. Please note that vars are included to this object as local vars and they cannot be modified within another dataset.

metadata

(named list, NULL or CallableFunction)
Field containing either the metadata about the dataset (each element of the list should be atomic and length one) or a CallableFuntion to pull the metadata from a connection. This should return a list or an object which can be converted to a list with as.list.


Method print()

Prints this TealDatasetConnector.

Usage

TealDatasetConnector$print(...)

Arguments

...

additional arguments to the printing method

Returns

invisibly self


Method get_dataname()

Get dataname of dataset

Usage

TealDatasetConnector$get_dataname()

Returns

dataname of the dataset


Method get_datanames()

Get dataname of dataset

Usage

TealDatasetConnector$get_datanames()

Returns

character dataname of the dataset


Method get_dataset_label()

Get label of dataset

Usage

TealDatasetConnector$get_dataset_label()

Returns

character dataset label


Method get_keys()

Get primary keys of dataset

Usage

TealDatasetConnector$get_keys()

Returns

character vector with dataset primary keys


Method get_join_keys()

Get JoinKeys object with keys used for joining.

Usage

TealDatasetConnector$get_join_keys()

Returns

(JoinKeys)


Method get_code()

Get code to get data

Usage

TealDatasetConnector$get_code(deparse = TRUE)

Arguments

deparse

(logical)
whether return deparsed form of a call

Returns

optionally deparsed call object


Method get_code_class()

Get internal CodeClass object

Usage

TealDatasetConnector$get_code_class()

Returns

CodeClass


Method get_pull_args()

Derive the arguments this connector will pull with

Usage

TealDatasetConnector$get_pull_args()

Returns

list of pull function fixed arguments


Method get_dataset()

Get dataset

Usage

TealDatasetConnector$get_dataset()

Returns

dataset (TealDataset)


Method get_error_message()

Get error message from last pull

Usage

TealDatasetConnector$get_error_message()

Returns

character object with error message or character(0) if last pull was successful.


Method get_pull_callable()

Get pull function

Usage

TealDatasetConnector$get_pull_callable()

Returns

CallableFunction


Method get_raw_data()

Get raw data from dataset

Usage

TealDatasetConnector$get_raw_data()

Returns

data.frame or MultiAssayExperiment data


Method get_var_r6()

Get the list of dependencies that are TealDataset or TealDatasetConnector objects

Usage

TealDatasetConnector$get_var_r6()

Returns

list


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.

Usage

TealDatasetConnector$reassign_datasets_vars(datasets)

Arguments

datasets

(named list of TealDataset(s) or TealDatasetConnector(s))
objects with valid pointers.

Returns

NULL invisible


Method set_dataset_label()

Set label of the dataset object

Usage

TealDatasetConnector$set_dataset_label(label)

Arguments

label

(character)
Label to describe the dataset.

Returns

(self) invisibly for chaining


Method set_keys()

Set new keys

Usage

TealDatasetConnector$set_keys(keys)

Arguments

keys

optional, (character)
vector of dataset primary keys column names

Returns

(self) invisibly for chaining.


Method set_join_keys()

set join_keys for a given dataset and self

Usage

TealDatasetConnector$set_join_keys(x)

Arguments

x

list of JoinKeySet objects (which are created using the join_key function) or single JoinKeySet objects

Returns

(self) invisibly for chaining


Method mutate_join_keys()

mutate the join_keys for a given dataset and self

Usage

TealDatasetConnector$mutate_join_keys(dataset, val)

Arguments

dataset

(character) dataset for which join_keys are to be set against self

val

(named character) column names used to join

Returns

(self) invisibly for chaining


Method pull()

Pull the data (and metadata if it is a Callable)

Read or create data using pull_callable specified in the constructor.

Usage

TealDatasetConnector$pull(args = NULL, try = FALSE)

Arguments

args

(NULL or named list)
additional dynamic arguments for pull function. args can be omitted if pull_callable from constructor already contains all necessary arguments to pull data. One can try to execute pull_callable directly by x$pull_callable$run() or to get code using x$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 inside try clause

Returns

(self) if successful.


Method set_args()

Set arguments to the pulling function

Usage

TealDatasetConnector$set_args(args)

Arguments

args

(NULL or named list) dynamic arguments to function

Returns

(self) invisibly for chaining


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 modify raw_data from this dataset. To modify current dataset code should contain at least one assignment to object defined in dataname argument. For example if dataname = ADSL example code should contain ADSL <- <some R code>. Can't be used simultaneously with script

vars

(named list))
In case when this object code depends on other TealDataset 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 needs ADSL object we should specify vars = list(ADSL = <adsl object>). It's recommended to include TealDataset or TealDatasetConnector objects to the vars list to preserve reproducibility. Please note that vars are included to this object as local vars and they cannot be modified within another dataset.

Returns

(self) invisibly for chaining.


Method is_failed()

Check if pull has not failed.

Usage

TealDatasetConnector$is_failed()

Returns

TRUE if pull failed, else FALSE


Method is_pulled()

Check if dataset has already been pulled.

Usage

TealDatasetConnector$is_pulled()

Returns

TRUE if connector has been already pulled, else FALSE


Method is_mutate_delayed()

Check if dataset has mutations that are delayed

Usage

TealDatasetConnector$is_mutate_delayed()

Returns

logical


Method check()

Check to determine if the raw data is reproducible from the get_code() code.

Usage

TealDatasetConnector$check()

Returns

TRUE always for all connectors to avoid evaluating the same code multiple times.


Method set_ui_input()

Sets the shiny UI according to the given inputs. Inputs must provide only scalar (length of 1) variables.

Usage

TealDatasetConnector$set_ui_input(inputs = NULL)

Arguments

inputs

(function) A shiny module UI function with single argument ns. This function needs to return a list of shiny inputs with their inputId wrapped in function ns. The inputId must match exactly the argument name to be set. See example. Nested lists are not allowed.

Returns

(self) invisibly for chaining.

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 get_ui()

Get shiny ui function

Usage

TealDatasetConnector$get_ui(id)

Arguments

id

(character) namespace id

Returns

shiny UI in given namespace id


Method get_server()

Get shiny server function

Usage

TealDatasetConnector$get_server()

Returns

shiny server function


Method launch()

Launches a shiny app.

Usage

TealDatasetConnector$launch()

Returns

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()
}


Method clone()

The objects of this class are cloneable with this method.

Usage

TealDatasetConnector$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

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()
}