Skip to content

Commit

Permalink
clean up after pre-release-cleanup (#537)
Browse files Browse the repository at this point in the history
Proof reading documentation and code comments.

---------

Signed-off-by: Aleksander Chlebowski <[email protected]>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: André Veríssimo <[email protected]>
Co-authored-by: 27856297+dependabot-preview[bot]@users.noreply.github.com <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Pawel Rucki <[email protected]>
  • Loading branch information
5 people authored Jan 30, 2024
1 parent d108440 commit 37c351d
Show file tree
Hide file tree
Showing 77 changed files with 1,121 additions and 1,334 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Authors@R: c(
person("Junlue", "Zhao", role = "aut"),
person("F. Hoffmann-La Roche AG", role = c("cph", "fnd"))
)
Description: Module containing filter panel for 'teal' applications.
Description: Data filtering module for 'teal' applications.
Allows for interactive filtering of data stored in 'data.frame' and
'MultiAssayExperiment' objects. Also displays filtered and unfiltered
observation counts.
Expand Down
6 changes: 1 addition & 5 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,13 @@ S3method(init_filtered_dataset,data.frame)
S3method(init_filtered_dataset,default)
S3method(print,teal_slice)
S3method(print,teal_slices)
S3method(variable_types,DFrame)
S3method(variable_types,DataTable)
S3method(variable_types,data.frame)
S3method(variable_types,default)
S3method(variable_types,matrix)
export(FilterPanelAPI)
export(as.teal_slice)
export(as.teal_slices)
export(clear_filter_states)
export(get_filter_expr)
export(get_filter_state)
export(get_supported_filter_varnames)
export(init_filter_states)
export(init_filtered_data)
export(init_filtered_dataset)
Expand Down
8 changes: 4 additions & 4 deletions R/FilterPanelAPI.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#' filter panel API.
#'
#' @examples
#' fd <- init_filtered_data(list(iris = list(dataset = iris)))
#' fd <- init_filtered_data(list(iris = iris))
#' fpa <- FilterPanelAPI$new(fd)
#'
#' # get the actual filter state --> empty named list
Expand Down Expand Up @@ -71,7 +71,7 @@ FilterPanelAPI <- R6::R6Class( # nolint
#' Sets active filter states.
#' @param filter (`teal_slices`)
#'
#' @return `NULL` invisibly
#' @return `NULL`, invisibly.
#'
set_filter_state = function(filter) {
private$filtered_data$set_filter_state(filter)
Expand All @@ -85,7 +85,7 @@ FilterPanelAPI <- R6::R6Class( # nolint
#' specifying `FilterState` objects to remove;
#' `teal_slice`s may contain only `dataname` and `varname`, other elements are ignored
#'
#' @return `NULL` invisibly
#' @return `NULL`, invisibly.
#'
remove_filter_state = function(filter) {
private$filtered_data$remove_filter_state(filter)
Expand All @@ -99,7 +99,7 @@ FilterPanelAPI <- R6::R6Class( # nolint
#' `datanames` to remove their `FilterStates`;
#' omit to remove all `FilterStates` in the `FilteredData` object
#'
#' @return `NULL` invisibly
#' @return `NULL`, invisibly.
#'
clear_filter_states = function(datanames) {
datanames_to_remove <- if (missing(datanames)) private$filtered_data$datanames() else datanames
Expand Down
30 changes: 17 additions & 13 deletions R/FilterState-utils.R
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
#' Initializes `FilterState`
#' Initialize `FilterState`
#'
#' Initializes `FilterState` depending on a variable class.
#' Initializes a `FilterState` object corresponding to the class of the filtered variable.
#'
#' @param x (`vector`)
#' values of the variable used in filter
#' variable to be filtered.
#' @param x_reactive (`reactive`)
#' returning vector of the same type as `x`. Is used to update
#' counts following the change in values of the filtered dataset.
#' If it is set to `reactive(NULL)` then counts based on filtered
#' dataset are not shown.
#' @param slice (`teal_slice`)
#' object created using [teal_slice()].
#' specification of this filter state.
#' `teal_slice` is stored in the object and `set_state` directly manipulates values within `teal_slice`.
#' `get_state` returns `teal_slice` object which can be reused in other places.
#' Note that `teal_slice` is a `reactiveValues`, which means it has reference semantics, i.e.
#' changes made to an object are automatically reflected in all places that refer to the same `teal_slice`.
#' @param extract_type (`character`)
#' specifying whether condition calls should be prefixed by `dataname`. Possible values:
#' - `character(0)` (default) `varname` in the condition call will not be prefixed
#' - `"list"` `varname` in the condition call will be returned as `<dataname>$<varname>`
#' - `"matrix"` `varname` in the condition call will be returned as `<dataname>[, <varname>]`
#' @param ... additional arguments to be saved as a list in `private$extras` field
#'
#' @examples
#' # use non-exported function from teal.slice
#' include_js_files <- getFromNamespace("include_js_files", "teal.slice")
#' init_filter_state <- getFromNamespace("init_filter_state", "teal.slice")
#'
#' filter_state <- init_filter_state(
#' x = c(1:10, NA, Inf),
#' x_reactive = reactive(c(1:10, NA, Inf)),
#' slice = teal_slice(
#' varname = "x",
#' varname = "varname",
#' dataname = "dataname"
#' ),
#' extract_type = "matrix"
Expand Down Expand Up @@ -218,11 +220,7 @@ init_filter_state.POSIXlt <- function(x,
#' Initialize a `FilterStateExpr` object
#'
#' @param slice (`teal_slice_expr`)
#' object created using [teal_slice()]. `teal_slice` is stored
#' in the class and `set_state` directly manipulates values within `teal_slice`. `get_state`
#' returns `teal_slice` object which can be reused in other places. Beware, that `teal_slice`
#' is a `reactiveValues` which means that changes in particular object are automatically
#' reflected in all places which refer to the same `teal_slice`.
#' specifying this filter state.
#'
#' @return `FilterStateExpr` object
#' @keywords internal
Expand All @@ -241,6 +239,13 @@ init_filter_state_expr <- function(slice) {
#' set to NULL to omit adding the alpha channel
#'
#' @return Named `character(1)` containing a hexadecimal color representation.
#'
#' @examples
#' fetch_bs_color <- getFromNamespace("fetch_bs_color", "teal.slice")
#' fetch_bs_color("primary")
#' fetch_bs_color("danger", 0.35)
#' fetch_bs_color("danger", "80")
#'
#' @keywords internal
#'
fetch_bs_color <- function(color, alpha = NULL) {
Expand All @@ -251,7 +256,6 @@ fetch_bs_color <- function(color, alpha = NULL) {
)

# locate file that describes the current theme
## TODO this is not ideal
sass_file <- if (utils::packageVersion("bslib") < as.package_version("0.5.1.9000")) {
bslib::bs_theme()[["layers"]][[2]][["defaults"]][[1]]
} else {
Expand Down
Loading

0 comments on commit 37c351d

Please sign in to comment.