| FilterStates | R Documentation |
FilterStates R6 classAbstract class that manages adding and removing FilterState objects
and builds a subset expression.
A FilterStates object tracks all condition calls
(logical predicates that limit observations) associated with a given dataset
and composes them into a single reproducible R expression
that will assign a subset of the original data to a new variable.
This expression is hereafter referred to as subset expression.
The subset expression is constructed differently for different
classes of the underlying data object and FilterStates sub-classes.
Currently implemented for data.frame, matrix,
SummarizedExperiment, and MultiAssayExperiment.
new()Initializes FilterStates object by setting
dataname, and datalabel.
FilterStates$new( data, data_reactive = function(sid = "") NULL, dataname, datalabel = NULL )
data(data.frame or MultiAssayExperiment or SummarizedExperiment or matrix)
the R object which subset function is applied on.
data_reactive(function(sid))
should return an object of the same type as data object or NULL.
This object is needed for the FilterState counts being updated
on a change in filters. If function returns NULL then filtered counts are not shown.
Function has to have sid argument being a character.
dataname(character(1))
name of the dataset, used in the subset expression.
Passed to the function argument attached to this FilterStates.
datalabel(character(1)) optional
text label.
Object of class FilterStates, invisibly.
format()Returns a formatted string representing this FilterStates object.
FilterStates$format(show_all = FALSE, trim_lines = TRUE)
show_all(logical(1)) passed to format.teal_slices
trim_lines(logical(1)) passed to format.teal_slices
character(1) the formatted string
get_call()Filter call
Builds subset expression from condition calls generated by FilterState.
The lhs of the expression is a dataname_prefixed, where word prefixed refers to
situation when call is evaluated on elements of the original data, for example dataname[[x]].
By default dataname_prefixed = dataname and it's not alterable through class methods.
Customization of private$dataname_prefixed is done through inheriting classes.
The rhs is a call to private$fun with following arguments:
dataname_prefixed
list of logical expressions generated by FilterState objects
stored in private$state_list. Each logical predicate is combined with & operator.
Variables in these logical expressions by default are not prefixed but this can be changed
by setting private$extract_type (change in the similar way as dataname_prefixed)
Possible call outputs depending on a custom fields/options:
# default dataname <- subset(dataname, col == "x") # fun = dplyr::filter dataname <- dplyr::filter(dataname, col == "x") # fun = MultiAssayExperiment::subsetByColData; extract_type = "list" dataname <- MultiAssayExperiment::subsetByColData(dataname, dataname$col == "x") # teal_slice objects having `arg = "subset"` and `arg = "select"` dataname <- subset(dataname, subset = row_col == "x", select = col_col == "x") # dataname = dataname[[element]] dataname[[element]] <- subset(dataname[[element]], subset = col == "x")
If no filters are applied, NULL is returned to avoid no-op calls such as dataname <- dataname.
FilterStates$get_call(sid = "")
sid(character)
when specified then method returns code containing condition calls (logical predicates) of
FilterState objects which "sid" attribute is different than this sid argument.
call or NULL
print()Prints this FilterStates object.
FilterStates$print(...)
...additional arguments passed to format.
remove_filter_state()Remove one or more FilterStates from the state_list along with their UI elements.
FilterStates$remove_filter_state(state)
state(teal_slices)
specifying FilterState objects to remove;
teal_slices may contain only dataname and varname, other elements are ignored
NULL, invisibly.
get_filter_state()Gets reactive values from active FilterState objects.
Get active filter state from FilterState objects stored in state_list(s).
The output is a list compatible with input to self$set_filter_state.
FilterStates$get_filter_state()
Object of class teal_slices.
set_filter_state()Sets active FilterState objects.
FilterStates$set_filter_state(state)
state(teal_slices)
Function that raises an error.
clear_filter_states()Remove all FilterState objects from this FilterStates object.
FilterStates$clear_filter_states(force = FALSE)
force(logical(1))
flag specifying whether to include anchored filter states.
NULL, invisibly.
ui_active()shiny UI definition that stores FilterState UI elements.
Populated with elements created with renderUI in the module server.
FilterStates$ui_active(id)
id(character(1))
shiny module instance id.
shiny.tag
srv_active()shiny server module.
FilterStates$srv_active(id)
id(character(1))
shiny module instance id.
NULL.
ui_add()shiny UI module to add filter variable.
FilterStates$ui_add(id)
id(character(1))
shiny module instance id.
shiny.tag
srv_add()shiny server module to add filter variable.
This module controls available choices to select as a filter variable. Once selected, a variable is removed from available choices. Removing a filter variable adds it back to available choices.
FilterStates$srv_add(id)
id(character(1))
shiny module instance id.
NULL.
finalize()Object cleanup.
Destroy inputs and observers stored in private$session_bindings
Clean state_list
FilterStates$finalize()
NULL, invisibly.
clone()The objects of this class are cloneable with this method.
FilterStates$clone(deep = FALSE)
deepWhether to make a deep clone.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.