Inherited methods
}
\itemize{
\item \out{}\href{../../teal.slice/html/FilterStates.html#method-get_call}{\code{teal.slice::FilterStates$get_call()}}\out{}
+\item \out{}\href{../../teal.slice/html/FilterStates.html#method-get_datalabel}{\code{teal.slice::FilterStates$get_datalabel()}}\out{}
+\item \out{}\href{../../teal.slice/html/FilterStates.html#method-print}{\code{teal.slice::FilterStates$print()}}\out{}
\item \out{}\href{../../teal.slice/html/FilterStates.html#method-queue_empty}{\code{teal.slice::FilterStates$queue_empty()}}\out{}
\item \out{}\href{../../teal.slice/html/FilterStates.html#method-queue_get}{\code{teal.slice::FilterStates$queue_get()}}\out{}
\item \out{}\href{../../teal.slice/html/FilterStates.html#method-queue_initialize}{\code{teal.slice::FilterStates$queue_initialize()}}\out{}
@@ -103,6 +65,13 @@ shiny::isolate(dffs$get_filter_state())
\if{html}{\out{}}
\if{latex}{\out{\hypertarget{method-new}{}}}
\subsection{Method \code{new()}}{
+Initializes \code{DFFilterStates} object
+
+Initializes \code{DFFilterStates} object by setting \code{input_dataname},
+\code{output_dataname} and initializing \code{ReactiveQueue}. This class contains a
+single \code{ReactiveQueue} with no specified name which means that
+when calling the function associated to this class (\code{dplyr::filter}), a list of
+conditions are passed to unnamed arguments (\code{...}).
\subsection{Usage}{
\if{html}{\out{}}\preformatted{DFFilterStates$new(input_dataname, output_dataname, datalabel, varlabels, keys)}\if{html}{\out{
}}
}
@@ -124,19 +93,39 @@ text label value.}
labels of the variables used in this object}
\item{\code{keys}}{(\code{character})\cr
-key columns names
-Get function name
+key columns names}
+}
+\if{html}{\out{}}
+}
+}
+\if{html}{\out{
}}
+\if{html}{\out{}}
+\if{latex}{\out{\hypertarget{method-format}{}}}
+\subsection{Method \code{format()}}{
+Returns the formatted string representing this \code{FilterStates} object.
+\subsection{Usage}{
+\if{html}{\out{}}\preformatted{DFFilterStates$format(indent = 0)}\if{html}{\out{
}}
+}
-Get function name used to create filter call.
-For \code{DFFilterStates} \code{dplyr::filter} is used}
+\subsection{Arguments}{
+\if{html}{\out{}}
+\describe{
+\item{\code{indent}}{(\code{numeric(1)}) the number of spaces before each line of the representation}
}
\if{html}{\out{
}}
}
+\subsection{Returns}{
+\code{character(1)} the formatted string
+}
}
\if{html}{\out{
}}
\if{html}{\out{}}
\if{latex}{\out{\hypertarget{method-get_fun}{}}}
\subsection{Method \code{get_fun()}}{
+Get function name
+
+Get function name used to create filter call.
+For \code{DFFilterStates} \code{dplyr::filter} is used
\subsection{Usage}{
\if{html}{\out{}}\preformatted{DFFilterStates$get_fun()}\if{html}{\out{
}}
}
diff --git a/man/DateFilterState.Rd b/man/DateFilterState.Rd
index 503778783..3482f11c2 100644
--- a/man/DateFilterState.Rd
+++ b/man/DateFilterState.Rd
@@ -45,6 +45,7 @@ filter$set_selected(c(date + 1, date + 2))
\subsection{Public methods}{
\itemize{
\item \href{#method-new}{\code{DateFilterState$new()}}
+\item \href{#method-format}{\code{DateFilterState$format()}}
\item \href{#method-is_any_filtered}{\code{DateFilterState$is_any_filtered()}}
\item \href{#method-get_call}{\code{DateFilterState$get_call()}}
\item \href{#method-ui}{\code{DateFilterState$ui()}}
@@ -63,6 +64,7 @@ filter$set_selected(c(date + 1, date + 2))
\item \out{}\href{../../teal.slice/html/FilterState.html#method-get_state}{\code{teal.slice::FilterState$get_state()}}\out{}
\item \out{}\href{../../teal.slice/html/FilterState.html#method-get_varlabel}{\code{teal.slice::FilterState$get_varlabel()}}\out{}
\item \out{}\href{../../teal.slice/html/FilterState.html#method-get_varname}{\code{teal.slice::FilterState$get_varname()}}\out{}
+\item \out{}\href{../../teal.slice/html/FilterState.html#method-print}{\code{teal.slice::FilterState$print()}}\out{}
\item \out{}\href{../../teal.slice/html/FilterState.html#method-set_keep_na}{\code{teal.slice::FilterState$set_keep_na()}}\out{}
\item \out{}\href{../../teal.slice/html/FilterState.html#method-set_keep_na_reactive}{\code{teal.slice::FilterState$set_keep_na_reactive()}}\out{}
\item \out{}\href{../../teal.slice/html/FilterState.html#method-set_na_rm}{\code{teal.slice::FilterState$set_na_rm()}}\out{}
@@ -114,6 +116,27 @@ whether condition calls should be prefixed by dataname. Possible values:
}
}
\if{html}{\out{
}}
+\if{html}{\out{}}
+\if{latex}{\out{\hypertarget{method-format}{}}}
+\subsection{Method \code{format()}}{
+Returns a formatted string representing this \code{DateFilterState}.
+\subsection{Usage}{
+\if{html}{\out{}}\preformatted{DateFilterState$format(indent = 0)}\if{html}{\out{
}}
+}
+
+\subsection{Arguments}{
+\if{html}{\out{}}
+\describe{
+\item{\code{indent}}{(\code{numeric(1)}) the number of spaces before after each new line character of the formatted string.
+Default: 0}
+}
+\if{html}{\out{
}}
+}
+\subsection{Returns}{
+\code{character(1)} the formatted string
+}
+}
+\if{html}{\out{
}}
\if{html}{\out{}}
\if{latex}{\out{\hypertarget{method-is_any_filtered}{}}}
\subsection{Method \code{is_any_filtered()}}{
diff --git a/man/DatetimeFilterState.Rd b/man/DatetimeFilterState.Rd
index 90d55fd39..feaf0c80e 100644
--- a/man/DatetimeFilterState.Rd
+++ b/man/DatetimeFilterState.Rd
@@ -45,6 +45,7 @@ filter$set_selected(c(date + 1, date + 2))
\subsection{Public methods}{
\itemize{
\item \href{#method-new}{\code{DatetimeFilterState$new()}}
+\item \href{#method-format}{\code{DatetimeFilterState$format()}}
\item \href{#method-is_any_filtered}{\code{DatetimeFilterState$is_any_filtered()}}
\item \href{#method-get_call}{\code{DatetimeFilterState$get_call()}}
\item \href{#method-ui}{\code{DatetimeFilterState$ui()}}
@@ -63,6 +64,7 @@ filter$set_selected(c(date + 1, date + 2))
\item \out{}\href{../../teal.slice/html/FilterState.html#method-get_state}{\code{teal.slice::FilterState$get_state()}}\out{}
\item \out{}\href{../../teal.slice/html/FilterState.html#method-get_varlabel}{\code{teal.slice::FilterState$get_varlabel()}}\out{}
\item \out{}\href{../../teal.slice/html/FilterState.html#method-get_varname}{\code{teal.slice::FilterState$get_varname()}}\out{}
+\item \out{}\href{../../teal.slice/html/FilterState.html#method-print}{\code{teal.slice::FilterState$print()}}\out{}
\item \out{}\href{../../teal.slice/html/FilterState.html#method-set_keep_na}{\code{teal.slice::FilterState$set_keep_na()}}\out{}
\item \out{}\href{../../teal.slice/html/FilterState.html#method-set_keep_na_reactive}{\code{teal.slice::FilterState$set_keep_na_reactive()}}\out{}
\item \out{}\href{../../teal.slice/html/FilterState.html#method-set_na_rm}{\code{teal.slice::FilterState$set_na_rm()}}\out{}
@@ -118,6 +120,27 @@ whether condition calls should be prefixed by dataname. Possible values:
}
}
\if{html}{\out{
}}
+\if{html}{\out{}}
+\if{latex}{\out{\hypertarget{method-format}{}}}
+\subsection{Method \code{format()}}{
+Returns a formatted string representing this \code{DatetimeFilterState}.
+\subsection{Usage}{
+\if{html}{\out{}}\preformatted{DatetimeFilterState$format(indent = 0)}\if{html}{\out{
}}
+}
+
+\subsection{Arguments}{
+\if{html}{\out{}}
+\describe{
+\item{\code{indent}}{(\code{numeric(1)}) the number of spaces before after each new line character of the formatted string.
+Default: 0}
+}
+\if{html}{\out{
}}
+}
+\subsection{Returns}{
+\code{character(1)} the formatted string
+}
+}
+\if{html}{\out{
}}
\if{html}{\out{}}
\if{latex}{\out{\hypertarget{method-is_any_filtered}{}}}
\subsection{Method \code{is_any_filtered()}}{
diff --git a/man/DefaultFilteredDataset.Rd b/man/DefaultFilteredDataset.Rd
index 338c4023d..2c6f9f030 100644
--- a/man/DefaultFilteredDataset.Rd
+++ b/man/DefaultFilteredDataset.Rd
@@ -66,6 +66,7 @@ shiny::isolate(dataset$get_filter_state())
\item \out{}\href{../../teal.slice/html/FilteredDataset.html#method-get_filter_states}{\code{teal.slice::FilteredDataset$get_filter_states()}}\out{}
\item \out{}\href{../../teal.slice/html/FilteredDataset.html#method-get_filterable_varnames}{\code{teal.slice::FilteredDataset$get_filterable_varnames()}}\out{}
\item \out{}\href{../../teal.slice/html/FilteredDataset.html#method-get_filtered_dataname}{\code{teal.slice::FilteredDataset$get_filtered_dataname()}}\out{}
+\item \out{}\href{../../teal.slice/html/FilteredDataset.html#method-get_formatted_filter_state}{\code{teal.slice::FilteredDataset$get_formatted_filter_state()}}\out{}
\item \out{}\href{../../teal.slice/html/FilteredDataset.html#method-get_hash}{\code{teal.slice::FilteredDataset$get_hash()}}\out{}
\item \out{}\href{../../teal.slice/html/FilteredDataset.html#method-get_join_keys}{\code{teal.slice::FilteredDataset$get_join_keys()}}\out{}
\item \out{}\href{../../teal.slice/html/FilteredDataset.html#method-get_keys}{\code{teal.slice::FilteredDataset$get_keys()}}\out{}
@@ -114,16 +115,16 @@ applies to one argument (\code{...}) in \code{dplyr::filter} call.
\subsection{Returns}{
filter \code{call} or \code{list} of filter calls
-Gets the reactive values from the active \code{FilterState} objects.
-
-Get all active filters from this dataset in form of the nested list.
-The output list is a compatible input to \code{self$set_filter_state}.
}
}
\if{html}{\out{
}}
\if{html}{\out{}}
\if{latex}{\out{\hypertarget{method-get_filter_state}{}}}
\subsection{Method \code{get_filter_state()}}{
+Gets the reactive values from the active \code{FilterState} objects.
+
+Get all active filters from this dataset in form of the nested list.
+The output list is a compatible input to \code{self$set_filter_state}.
\subsection{Usage}{
\if{html}{\out{}}\preformatted{DefaultFilteredDataset$get_filter_state()}\if{html}{\out{
}}
}
diff --git a/man/EmptyFilterState.Rd b/man/EmptyFilterState.Rd
index f980b1a74..a0ba1fa13 100644
--- a/man/EmptyFilterState.Rd
+++ b/man/EmptyFilterState.Rd
@@ -42,11 +42,13 @@ isolate(filter_state$get_call())
\out{Inherited methods
}
\itemize{
\item \out{}\href{../../teal.slice/html/FilterState.html#method-destroy_observers}{\code{teal.slice::FilterState$destroy_observers()}}\out{}
+\item \out{}\href{../../teal.slice/html/FilterState.html#method-format}{\code{teal.slice::FilterState$format()}}\out{}
\item \out{}\href{../../teal.slice/html/FilterState.html#method-get_dataname}{\code{teal.slice::FilterState$get_dataname()}}\out{}
\item \out{}\href{../../teal.slice/html/FilterState.html#method-get_keep_na}{\code{teal.slice::FilterState$get_keep_na()}}\out{}
\item \out{}\href{../../teal.slice/html/FilterState.html#method-get_selected}{\code{teal.slice::FilterState$get_selected()}}\out{}
\item \out{}\href{../../teal.slice/html/FilterState.html#method-get_varlabel}{\code{teal.slice::FilterState$get_varlabel()}}\out{}
\item \out{}\href{../../teal.slice/html/FilterState.html#method-get_varname}{\code{teal.slice::FilterState$get_varname()}}\out{}
+\item \out{}\href{../../teal.slice/html/FilterState.html#method-print}{\code{teal.slice::FilterState$print()}}\out{}
\item \out{}\href{../../teal.slice/html/FilterState.html#method-set_keep_na}{\code{teal.slice::FilterState$set_keep_na()}}\out{}
\item \out{}\href{../../teal.slice/html/FilterState.html#method-set_keep_na_reactive}{\code{teal.slice::FilterState$set_keep_na_reactive()}}\out{}
\item \out{}\href{../../teal.slice/html/FilterState.html#method-set_na_rm}{\code{teal.slice::FilterState$set_na_rm()}}\out{}
diff --git a/man/FilterState.Rd b/man/FilterState.Rd
index 06659864b..889213bbe 100644
--- a/man/FilterState.Rd
+++ b/man/FilterState.Rd
@@ -57,6 +57,7 @@ or using \code{set_selected}, \code{set_keep_na} or \code{set_keep_inf}
\itemize{
\item \href{#method-new}{\code{FilterState$new()}}
\item \href{#method-destroy_observers}{\code{FilterState$destroy_observers()}}
+\item \href{#method-format}{\code{FilterState$format()}}
\item \href{#method-get_call}{\code{FilterState$get_call()}}
\item \href{#method-get_dataname}{\code{FilterState$get_dataname()}}
\item \href{#method-get_keep_na}{\code{FilterState$get_keep_na()}}
@@ -64,6 +65,7 @@ or using \code{set_selected}, \code{set_keep_na} or \code{set_keep_inf}
\item \href{#method-get_varname}{\code{FilterState$get_varname()}}
\item \href{#method-get_selected}{\code{FilterState$get_selected()}}
\item \href{#method-get_state}{\code{FilterState$get_state()}}
+\item \href{#method-print}{\code{FilterState$print()}}
\item \href{#method-set_keep_na}{\code{FilterState$set_keep_na()}}
\item \href{#method-set_keep_na_reactive}{\code{FilterState$set_keep_na_reactive()}}
\item \href{#method-set_na_rm}{\code{FilterState$set_na_rm()}}
@@ -127,6 +129,27 @@ Destroy observers stored in \code{private$observers}.
\if{html}{\out{}}\preformatted{FilterState$destroy_observers()}\if{html}{\out{
}}
}
+}
+\if{html}{\out{
}}
+\if{html}{\out{}}
+\if{latex}{\out{\hypertarget{method-format}{}}}
+\subsection{Method \code{format()}}{
+Returns a formatted string representing this \code{FilterState}.
+\subsection{Usage}{
+\if{html}{\out{}}\preformatted{FilterState$format(indent = 0)}\if{html}{\out{
}}
+}
+
+\subsection{Arguments}{
+\if{html}{\out{}}
+\describe{
+\item{\code{indent}}{(\code{numeric(1)}) the number of spaces before after each new line character of the formatted string.
+Default: 0}
+}
+\if{html}{\out{
}}
+}
+\subsection{Returns}{
+\code{character(1)} the formatted string
+}
}
\if{html}{\out{
}}
\if{html}{\out{}}
@@ -240,6 +263,23 @@ Returns the filtering state.
}
}
\if{html}{\out{
}}
+\if{html}{\out{}}
+\if{latex}{\out{\hypertarget{method-print}{}}}
+\subsection{Method \code{print()}}{
+Prints this \code{FilterState} object
+\subsection{Usage}{
+\if{html}{\out{}}\preformatted{FilterState$print(...)}\if{html}{\out{
}}
+}
+
+\subsection{Arguments}{
+\if{html}{\out{}}
+\describe{
+\item{\code{...}}{additional arguments to this method}
+}
+\if{html}{\out{
}}
+}
+}
+\if{html}{\out{
}}
\if{html}{\out{}}
\if{latex}{\out{\hypertarget{method-set_keep_na}{}}}
\subsection{Method \code{set_keep_na()}}{
diff --git a/man/FilterStates.Rd b/man/FilterStates.Rd
index ea303ed6d..3924005e4 100644
--- a/man/FilterStates.Rd
+++ b/man/FilterStates.Rd
@@ -45,7 +45,10 @@ isolate(filter_states$get_call())
\subsection{Public methods}{
\itemize{
\item \href{#method-new}{\code{FilterStates$new()}}
+\item \href{#method-get_datalabel}{\code{FilterStates$get_datalabel()}}
+\item \href{#method-format}{\code{FilterStates$format()}}
\item \href{#method-get_call}{\code{FilterStates$get_call()}}
+\item \href{#method-print}{\code{FilterStates$print()}}
\item \href{#method-get_fun}{\code{FilterStates$get_fun()}}
\item \href{#method-queue_empty}{\code{FilterStates$queue_empty()}}
\item \href{#method-queue_get}{\code{FilterStates$queue_get()}}
@@ -87,6 +90,39 @@ text label value.}
}
}
\if{html}{\out{
}}
+\if{html}{\out{}}
+\if{latex}{\out{\hypertarget{method-get_datalabel}{}}}
+\subsection{Method \code{get_datalabel()}}{
+Returns the label of the dataset
+\subsection{Usage}{
+\if{html}{\out{}}\preformatted{FilterStates$get_datalabel()}\if{html}{\out{
}}
+}
+
+\subsection{Returns}{
+(\code{character(1)}) the label
+}
+}
+\if{html}{\out{
}}
+\if{html}{\out{}}
+\if{latex}{\out{\hypertarget{method-format}{}}}
+\subsection{Method \code{format()}}{
+Returns the formatted string representing this \code{FilterStates} object.
+\subsection{Usage}{
+\if{html}{\out{}}\preformatted{FilterStates$format(indent)}\if{html}{\out{
}}
+}
+
+\subsection{Arguments}{
+\if{html}{\out{}}
+\describe{
+\item{\code{indent}}{(\code{numeric(1)}) the number of spaces before each line of the representation}
+}
+\if{html}{\out{
}}
+}
+\subsection{Returns}{
+\code{character(1)} the formatted string
+}
+}
+\if{html}{\out{
}}
\if{html}{\out{}}
\if{latex}{\out{\hypertarget{method-get_call}{}}}
\subsection{Method \code{get_call()}}{
@@ -108,6 +144,23 @@ no-op call such as \code{x <- x}.
}
}
\if{html}{\out{
}}
+\if{html}{\out{}}
+\if{latex}{\out{\hypertarget{method-print}{}}}
+\subsection{Method \code{print()}}{
+Prints this \code{FilterStates} object
+\subsection{Usage}{
+\if{html}{\out{}}\preformatted{FilterStates$print(...)}\if{html}{\out{
}}
+}
+
+\subsection{Arguments}{
+\if{html}{\out{}}
+\describe{
+\item{\code{...}}{additional arguments to this method}
+}
+\if{html}{\out{
}}
+}
+}
+\if{html}{\out{
}}
\if{html}{\out{}}
\if{latex}{\out{\hypertarget{method-get_fun}{}}}
\subsection{Method \code{get_fun()}}{
diff --git a/man/FilteredData.Rd b/man/FilteredData.Rd
index 1c190df3f..509f03d93 100644
--- a/man/FilteredData.Rd
+++ b/man/FilteredData.Rd
@@ -72,6 +72,34 @@ isolate(datasets$get_filter_overview("mtcars"))
isolate(datasets$get_call("iris"))
isolate(datasets$get_call("mtcars"))
+## ------------------------------------------------
+## Method `FilteredData$get_formatted_filter_state`
+## ------------------------------------------------
+
+datasets <- teal.slice:::FilteredData$new()
+datasets$set_dataset(teal.data::dataset("iris", iris))
+utils::data(miniACC, package = "MultiAssayExperiment")
+datasets$set_dataset(teal.data::dataset("mae", miniACC))
+fs <- list(
+ iris = list(
+ Sepal.Length = list(selected = c(5.1, 6.4), keep_na = TRUE, keep_inf = FALSE),
+ Species = list(selected = c("setosa", "versicolor"), keep_na = FALSE)
+ ),
+ mae = list(
+ subjects = list(
+ years_to_birth = list(selected = c(30, 50), keep_na = TRUE, keep_inf = FALSE),
+ vital_status = list(selected = "1", keep_na = FALSE),
+ gender = list(selected = "female", keep_na = TRUE)
+ ),
+ RPPAArray = list(
+ subset = list(ARRAY_TYPE = list(selected = "", keep_na = TRUE))
+ )
+ )
+)
+datasets$set_filter_state(state = fs)
+cat(shiny::isolate(datasets$get_formatted_filter_state()))
+
+
## ------------------------------------------------
## Method `FilteredData$set_filter_state`
## ------------------------------------------------
@@ -125,6 +153,7 @@ shiny::isolate(datasets$get_filter_state())
\item \href{#method-set_check}{\code{FilteredData$set_check()}}
\item \href{#method-set_code}{\code{FilteredData$set_code()}}
\item \href{#method-get_filter_state}{\code{FilteredData$get_filter_state()}}
+\item \href{#method-get_formatted_filter_state}{\code{FilteredData$get_formatted_filter_state()}}
\item \href{#method-set_filter_state}{\code{FilteredData$set_filter_state()}}
\item \href{#method-remove_filter_state}{\code{FilteredData$remove_filter_state()}}
\item \href{#method-remove_all_filter_states}{\code{FilteredData$remove_all_filter_states()}}
@@ -599,6 +628,49 @@ The output list is a compatible input to \code{self$set_filter_state}.
\code{list} with named elements corresponding to \code{FilteredDataset} objects
with active filters.
}
+}
+\if{html}{\out{
}}
+\if{html}{\out{}}
+\if{latex}{\out{\hypertarget{method-get_formatted_filter_state}{}}}
+\subsection{Method \code{get_formatted_filter_state()}}{
+Returns the filter state formatted for printing to an \code{IO} device.
+\subsection{Usage}{
+\if{html}{\out{}}\preformatted{FilteredData$get_formatted_filter_state()}\if{html}{\out{
}}
+}
+
+\subsection{Returns}{
+\code{character} the pre-formatted filter state
+}
+\subsection{Examples}{
+\if{html}{\out{}}
+\preformatted{datasets <- teal.slice:::FilteredData$new()
+datasets$set_dataset(teal.data::dataset("iris", iris))
+utils::data(miniACC, package = "MultiAssayExperiment")
+datasets$set_dataset(teal.data::dataset("mae", miniACC))
+fs <- list(
+ iris = list(
+ Sepal.Length = list(selected = c(5.1, 6.4), keep_na = TRUE, keep_inf = FALSE),
+ Species = list(selected = c("setosa", "versicolor"), keep_na = FALSE)
+ ),
+ mae = list(
+ subjects = list(
+ years_to_birth = list(selected = c(30, 50), keep_na = TRUE, keep_inf = FALSE),
+ vital_status = list(selected = "1", keep_na = FALSE),
+ gender = list(selected = "female", keep_na = TRUE)
+ ),
+ RPPAArray = list(
+ subset = list(ARRAY_TYPE = list(selected = "", keep_na = TRUE))
+ )
+ )
+)
+datasets$set_filter_state(state = fs)
+cat(shiny::isolate(datasets$get_formatted_filter_state()))
+
+}
+\if{html}{\out{
}}
+
+}
+
}
\if{html}{\out{
}}
\if{html}{\out{}}
diff --git a/man/FilteredDataset.Rd b/man/FilteredDataset.Rd
index ac0316f98..f1dd33abe 100644
--- a/man/FilteredDataset.Rd
+++ b/man/FilteredDataset.Rd
@@ -15,6 +15,7 @@ components of the \code{TealDataset}.
\subsection{Public methods}{
\itemize{
\item \href{#method-new}{\code{FilteredDataset$new()}}
+\item \href{#method-get_formatted_filter_state}{\code{FilteredDataset$get_formatted_filter_state()}}
\item \href{#method-add_to_eval_env}{\code{FilteredDataset$add_to_eval_env()}}
\item \href{#method-queues_empty}{\code{FilteredDataset$queues_empty()}}
\item \href{#method-get_call}{\code{FilteredDataset$get_call()}}
@@ -59,6 +60,19 @@ single dataset for which filters are rendered}
}
}
\if{html}{\out{
}}
+\if{html}{\out{}}
+\if{latex}{\out{\hypertarget{method-get_formatted_filter_state}{}}}
+\subsection{Method \code{get_formatted_filter_state()}}{
+Returns a string representation of the filter state in this \code{FilteredDataset}.
+\subsection{Usage}{
+\if{html}{\out{}}\preformatted{FilteredDataset$get_formatted_filter_state()}\if{html}{\out{
}}
+}
+
+\subsection{Returns}{
+\code{character(1)} the formatted string representing the filter state
+}
+}
+\if{html}{\out{
}}
\if{html}{\out{}}
\if{latex}{\out{\hypertarget{method-add_to_eval_env}{}}}
\subsection{Method \code{add_to_eval_env()}}{
diff --git a/man/LogicalFilterState.Rd b/man/LogicalFilterState.Rd
index a2687d15f..a8fbb364b 100644
--- a/man/LogicalFilterState.Rd
+++ b/man/LogicalFilterState.Rd
@@ -56,12 +56,14 @@ filter$set_selected(TRUE)
\out{Inherited methods
}
\itemize{
\item \out{}\href{../../teal.slice/html/FilterState.html#method-destroy_observers}{\code{teal.slice::FilterState$destroy_observers()}}\out{}
+\item \out{}\href{../../teal.slice/html/FilterState.html#method-format}{\code{teal.slice::FilterState$format()}}\out{}
\item \out{}\href{../../teal.slice/html/FilterState.html#method-get_dataname}{\code{teal.slice::FilterState$get_dataname()}}\out{}
\item \out{}\href{../../teal.slice/html/FilterState.html#method-get_keep_na}{\code{teal.slice::FilterState$get_keep_na()}}\out{}
\item \out{}\href{../../teal.slice/html/FilterState.html#method-get_selected}{\code{teal.slice::FilterState$get_selected()}}\out{}
\item \out{}\href{../../teal.slice/html/FilterState.html#method-get_state}{\code{teal.slice::FilterState$get_state()}}\out{}
\item \out{}\href{../../teal.slice/html/FilterState.html#method-get_varlabel}{\code{teal.slice::FilterState$get_varlabel()}}\out{}
\item \out{}\href{../../teal.slice/html/FilterState.html#method-get_varname}{\code{teal.slice::FilterState$get_varname()}}\out{}
+\item \out{}\href{../../teal.slice/html/FilterState.html#method-print}{\code{teal.slice::FilterState$print()}}\out{}
\item \out{}\href{../../teal.slice/html/FilterState.html#method-set_keep_na}{\code{teal.slice::FilterState$set_keep_na()}}\out{}
\item \out{}\href{../../teal.slice/html/FilterState.html#method-set_keep_na_reactive}{\code{teal.slice::FilterState$set_keep_na_reactive()}}\out{}
\item \out{}\href{../../teal.slice/html/FilterState.html#method-set_na_rm}{\code{teal.slice::FilterState$set_na_rm()}}\out{}
diff --git a/man/MAEFilterStates.Rd b/man/MAEFilterStates.Rd
index 94d117602..c5c333c0a 100644
--- a/man/MAEFilterStates.Rd
+++ b/man/MAEFilterStates.Rd
@@ -2,16 +2,11 @@
% Please edit documentation in R/FilterStates.R
\name{MAEFilterStates}
\alias{MAEFilterStates}
-\title{Specialization of \code{FilterStates} for \code{MultiAssayExperiment}.}
+\title{\code{MAEFilterStates}}
\description{
-Specialization of \code{FilterStates} for \code{MultiAssayExperiment}.
-
Specialization of \code{FilterStates} for \code{MultiAssayExperiment}.
}
-\keyword{Initialize}
-\keyword{`MAEFilterStates`}
\keyword{internal}
-\keyword{object}
\section{Super class}{
\code{\link[teal.slice:FilterStates]{teal.slice::FilterStates}} -> \code{MAEFilterStates}
}
@@ -19,6 +14,7 @@ Specialization of \code{FilterStates} for \code{MultiAssayExperiment}.
\subsection{Public methods}{
\itemize{
\item \href{#method-new}{\code{MAEFilterStates$new()}}
+\item \href{#method-format}{\code{MAEFilterStates$format()}}
\item \href{#method-get_fun}{\code{MAEFilterStates$get_fun()}}
\item \href{#method-server}{\code{MAEFilterStates$server()}}
\item \href{#method-get_filter_state}{\code{MAEFilterStates$get_filter_state()}}
@@ -33,6 +29,8 @@ Specialization of \code{FilterStates} for \code{MultiAssayExperiment}.
\out{Inherited methods
}
\itemize{
\item \out{}\href{../../teal.slice/html/FilterStates.html#method-get_call}{\code{teal.slice::FilterStates$get_call()}}\out{}
+\item \out{}\href{../../teal.slice/html/FilterStates.html#method-get_datalabel}{\code{teal.slice::FilterStates$get_datalabel()}}\out{}
+\item \out{}\href{../../teal.slice/html/FilterStates.html#method-print}{\code{teal.slice::FilterStates$print()}}\out{}
\item \out{}\href{../../teal.slice/html/FilterStates.html#method-queue_empty}{\code{teal.slice::FilterStates$queue_empty()}}\out{}
\item \out{}\href{../../teal.slice/html/FilterStates.html#method-queue_get}{\code{teal.slice::FilterStates$queue_get()}}\out{}
\item \out{}\href{../../teal.slice/html/FilterStates.html#method-queue_initialize}{\code{teal.slice::FilterStates$queue_initialize()}}\out{}
@@ -46,6 +44,9 @@ Specialization of \code{FilterStates} for \code{MultiAssayExperiment}.
\if{html}{\out{}}
\if{latex}{\out{\hypertarget{method-new}{}}}
\subsection{Method \code{new()}}{
+Initializes \code{MAEFilterStates} object
+
+Initialize \code{MAEFilterStates} object
\subsection{Usage}{
\if{html}{\out{}}\preformatted{MAEFilterStates$new(
input_dataname,
@@ -73,20 +74,37 @@ text label value.}
labels of the variables used in this object}
\item{\code{keys}}{(\code{character})\cr
-key columns names
-Get function name
+key columns names}
+}
+\if{html}{\out{
}}
+}
+}
+\if{html}{\out{
}}
+\if{html}{\out{}}
+\if{latex}{\out{\hypertarget{method-format}{}}}
+\subsection{Method \code{format()}}{
+Returns the formatted string representing this \code{MAEFilterStates} object.
+\subsection{Usage}{
+\if{html}{\out{}}\preformatted{MAEFilterStates$format(indent = 0)}\if{html}{\out{
}}
+}
-Get function name used to create filter call.
-For \code{MAEFilterStates}
-\code{MultiAssayExperiment::subsetByColData} is used.}
+\subsection{Arguments}{
+\if{html}{\out{}}
+\describe{
+\item{\code{indent}}{(\code{numeric(1)}) the number of spaces before each line of the representation}
}
\if{html}{\out{
}}
}
+\subsection{Returns}{
+\code{character(1)} the formatted string
+}
}
\if{html}{\out{
}}
\if{html}{\out{}}
\if{latex}{\out{\hypertarget{method-get_fun}{}}}
\subsection{Method \code{get_fun()}}{
+Returns function name used to create filter call.
+For \code{MAEFilterStates} \code{MultiAssayExperiment::subsetByColData} is used.
\subsection{Usage}{
\if{html}{\out{}}\preformatted{MAEFilterStates$get_fun()}\if{html}{\out{
}}
}
@@ -164,7 +182,7 @@ column in \code{colData(data)}.}
\if{html}{\out{}}
\if{latex}{\out{\hypertarget{method-remove_filter_state}{}}}
\subsection{Method \code{remove_filter_state()}}{
-Remove a variable from the \code{ReactiveQueue} and its corresponding UI element.
+Removes a variable from the \code{ReactiveQueue} and its corresponding UI element.
\subsection{Usage}{
\if{html}{\out{}}\preformatted{MAEFilterStates$remove_filter_state(element_id)}\if{html}{\out{
}}
}
diff --git a/man/MAEFilteredDataset.Rd b/man/MAEFilteredDataset.Rd
index fd5cc43a1..53471ce4f 100644
--- a/man/MAEFilteredDataset.Rd
+++ b/man/MAEFilteredDataset.Rd
@@ -60,6 +60,7 @@ shiny::isolate(dataset$get_filter_state())
\item \out{}\href{../../teal.slice/html/FilteredDataset.html#method-get_filter_state}{\code{teal.slice::FilteredDataset$get_filter_state()}}\out{}
\item \out{}\href{../../teal.slice/html/FilteredDataset.html#method-get_filter_states}{\code{teal.slice::FilteredDataset$get_filter_states()}}\out{}
\item \out{}\href{../../teal.slice/html/FilteredDataset.html#method-get_filtered_dataname}{\code{teal.slice::FilteredDataset$get_filtered_dataname()}}\out{}
+\item \out{}\href{../../teal.slice/html/FilteredDataset.html#method-get_formatted_filter_state}{\code{teal.slice::FilteredDataset$get_formatted_filter_state()}}\out{}
\item \out{}\href{../../teal.slice/html/FilteredDataset.html#method-get_hash}{\code{teal.slice::FilteredDataset$get_hash()}}\out{}
\item \out{}\href{../../teal.slice/html/FilteredDataset.html#method-get_join_keys}{\code{teal.slice::FilteredDataset$get_join_keys()}}\out{}
\item \out{}\href{../../teal.slice/html/FilteredDataset.html#method-get_keys}{\code{teal.slice::FilteredDataset$get_keys()}}\out{}
diff --git a/man/MatrixFilterStates.Rd b/man/MatrixFilterStates.Rd
index 6504872ae..200cd79ba 100644
--- a/man/MatrixFilterStates.Rd
+++ b/man/MatrixFilterStates.Rd
@@ -2,16 +2,11 @@
% Please edit documentation in R/FilterStates.R
\name{MatrixFilterStates}
\alias{MatrixFilterStates}
-\title{Specialization of \code{FilterStates} for a base matrix.}
+\title{\code{MatrixFilterStates}}
\description{
-Specialization of \code{FilterStates} for a base matrix.
-
Specialization of \code{FilterStates} for a base matrix.
}
-\keyword{Initialize}
-\keyword{`MatrixFilterStates`}
\keyword{internal}
-\keyword{object}
\section{Super class}{
\code{\link[teal.slice:FilterStates]{teal.slice::FilterStates}} -> \code{MatrixFilterStates}
}
@@ -19,6 +14,7 @@ Specialization of \code{FilterStates} for a base matrix.
\subsection{Public methods}{
\itemize{
\item \href{#method-new}{\code{MatrixFilterStates$new()}}
+\item \href{#method-format}{\code{MatrixFilterStates$format()}}
\item \href{#method-server}{\code{MatrixFilterStates$server()}}
\item \href{#method-get_filter_state}{\code{MatrixFilterStates$get_filter_state()}}
\item \href{#method-set_filter_state}{\code{MatrixFilterStates$set_filter_state()}}
@@ -32,7 +28,9 @@ Specialization of \code{FilterStates} for a base matrix.
\out{Inherited methods
}
\itemize{
\item \out{}\href{../../teal.slice/html/FilterStates.html#method-get_call}{\code{teal.slice::FilterStates$get_call()}}\out{}
+\item \out{}\href{../../teal.slice/html/FilterStates.html#method-get_datalabel}{\code{teal.slice::FilterStates$get_datalabel()}}\out{}
\item \out{}\href{../../teal.slice/html/FilterStates.html#method-get_fun}{\code{teal.slice::FilterStates$get_fun()}}\out{}
+\item \out{}\href{../../teal.slice/html/FilterStates.html#method-print}{\code{teal.slice::FilterStates$print()}}\out{}
\item \out{}\href{../../teal.slice/html/FilterStates.html#method-queue_empty}{\code{teal.slice::FilterStates$queue_empty()}}\out{}
\item \out{}\href{../../teal.slice/html/FilterStates.html#method-queue_get}{\code{teal.slice::FilterStates$queue_get()}}\out{}
\item \out{}\href{../../teal.slice/html/FilterStates.html#method-queue_initialize}{\code{teal.slice::FilterStates$queue_initialize()}}\out{}
@@ -46,6 +44,9 @@ Specialization of \code{FilterStates} for a base matrix.
\if{html}{\out{}}
\if{latex}{\out{\hypertarget{method-new}{}}}
\subsection{Method \code{new()}}{
+Initialize \code{MatrixFilterStates} object
+
+Initialize \code{MatrixFilterStates} object
\subsection{Usage}{
\if{html}{\out{}}\preformatted{MatrixFilterStates$new(input_dataname, output_dataname, datalabel)}\if{html}{\out{
}}
}
@@ -67,6 +68,26 @@ text label value.}
}
}
\if{html}{\out{
}}
+\if{html}{\out{}}
+\if{latex}{\out{\hypertarget{method-format}{}}}
+\subsection{Method \code{format()}}{
+Returns the formatted string representing this \code{MatrixFilterStates} object.
+\subsection{Usage}{
+\if{html}{\out{}}\preformatted{MatrixFilterStates$format(indent = 0)}\if{html}{\out{
}}
+}
+
+\subsection{Arguments}{
+\if{html}{\out{}}
+\describe{
+\item{\code{indent}}{(\code{numeric(1)}) the number of spaces before each line of the representation}
+}
+\if{html}{\out{
}}
+}
+\subsection{Returns}{
+\code{character(1)} the formatted string
+}
+}
+\if{html}{\out{
}}
\if{html}{\out{}}
\if{latex}{\out{\hypertarget{method-server}{}}}
\subsection{Method \code{server()}}{
diff --git a/man/RangeFilterState.Rd b/man/RangeFilterState.Rd
index 010c8ad03..eb48df770 100644
--- a/man/RangeFilterState.Rd
+++ b/man/RangeFilterState.Rd
@@ -45,6 +45,7 @@ filter$set_selected(c(2, 3))
\subsection{Public methods}{
\itemize{
\item \href{#method-new}{\code{RangeFilterState$new()}}
+\item \href{#method-format}{\code{RangeFilterState$format()}}
\item \href{#method-is_any_filtered}{\code{RangeFilterState$is_any_filtered()}}
\item \href{#method-get_call}{\code{RangeFilterState$get_call()}}
\item \href{#method-get_keep_inf}{\code{RangeFilterState$get_keep_inf()}}
@@ -68,6 +69,7 @@ filter$set_selected(c(2, 3))
\item \out{}\href{../../teal.slice/html/FilterState.html#method-get_selected}{\code{teal.slice::FilterState$get_selected()}}\out{}
\item \out{}\href{../../teal.slice/html/FilterState.html#method-get_varlabel}{\code{teal.slice::FilterState$get_varlabel()}}\out{}
\item \out{}\href{../../teal.slice/html/FilterState.html#method-get_varname}{\code{teal.slice::FilterState$get_varname()}}\out{}
+\item \out{}\href{../../teal.slice/html/FilterState.html#method-print}{\code{teal.slice::FilterState$print()}}\out{}
\item \out{}\href{../../teal.slice/html/FilterState.html#method-set_keep_na}{\code{teal.slice::FilterState$set_keep_na()}}\out{}
\item \out{}\href{../../teal.slice/html/FilterState.html#method-set_keep_na_reactive}{\code{teal.slice::FilterState$set_keep_na_reactive()}}\out{}
\item \out{}\href{../../teal.slice/html/FilterState.html#method-set_na_rm}{\code{teal.slice::FilterState$set_na_rm()}}\out{}
@@ -117,6 +119,27 @@ whether condition calls should be prefixed by dataname. Possible values:
}
}
\if{html}{\out{
}}
+\if{html}{\out{}}
+\if{latex}{\out{\hypertarget{method-format}{}}}
+\subsection{Method \code{format()}}{
+Returns a formatted string representing this \code{LogicalFilterState}.
+\subsection{Usage}{
+\if{html}{\out{}}\preformatted{RangeFilterState$format(indent = 0)}\if{html}{\out{
}}
+}
+
+\subsection{Arguments}{
+\if{html}{\out{}}
+\describe{
+\item{\code{indent}}{(\code{numeric(1)}) the number of spaces before after each new line character of the formatted string.
+Default: 0}
+}
+\if{html}{\out{
}}
+}
+\subsection{Returns}{
+\code{character(1)} the formatted string
+}
+}
+\if{html}{\out{
}}
\if{html}{\out{}}
\if{latex}{\out{\hypertarget{method-is_any_filtered}{}}}
\subsection{Method \code{is_any_filtered()}}{
diff --git a/man/SEFilterStates.Rd b/man/SEFilterStates.Rd
index c970579ab..89550d7f2 100644
--- a/man/SEFilterStates.Rd
+++ b/man/SEFilterStates.Rd
@@ -2,16 +2,11 @@
% Please edit documentation in R/FilterStates.R
\name{SEFilterStates}
\alias{SEFilterStates}
-\title{Specialization of \code{FilterStates} for \code{SummaryExperiment}.}
+\title{\code{SEFilterStates}}
\description{
-Specialization of \code{FilterStates} for \code{SummaryExperiment}.
-
Specialization of \code{FilterStates} for \code{SummaryExperiment}.
}
-\keyword{Initialize}
-\keyword{`SEFilterStates`}
\keyword{internal}
-\keyword{object}
\section{Super class}{
\code{\link[teal.slice:FilterStates]{teal.slice::FilterStates}} -> \code{SEFilterStates}
}
@@ -19,6 +14,7 @@ Specialization of \code{FilterStates} for \code{SummaryExperiment}.
\subsection{Public methods}{
\itemize{
\item \href{#method-new}{\code{SEFilterStates$new()}}
+\item \href{#method-format}{\code{SEFilterStates$format()}}
\item \href{#method-server}{\code{SEFilterStates$server()}}
\item \href{#method-get_filter_state}{\code{SEFilterStates$get_filter_state()}}
\item \href{#method-set_filter_state}{\code{SEFilterStates$set_filter_state()}}
@@ -32,7 +28,9 @@ Specialization of \code{FilterStates} for \code{SummaryExperiment}.
\out{Inherited methods
}
\itemize{
\item \out{}\href{../../teal.slice/html/FilterStates.html#method-get_call}{\code{teal.slice::FilterStates$get_call()}}\out{}
+\item \out{}\href{../../teal.slice/html/FilterStates.html#method-get_datalabel}{\code{teal.slice::FilterStates$get_datalabel()}}\out{}
\item \out{}\href{../../teal.slice/html/FilterStates.html#method-get_fun}{\code{teal.slice::FilterStates$get_fun()}}\out{}
+\item \out{}\href{../../teal.slice/html/FilterStates.html#method-print}{\code{teal.slice::FilterStates$print()}}\out{}
\item \out{}\href{../../teal.slice/html/FilterStates.html#method-queue_empty}{\code{teal.slice::FilterStates$queue_empty()}}\out{}
\item \out{}\href{../../teal.slice/html/FilterStates.html#method-queue_get}{\code{teal.slice::FilterStates$queue_get()}}\out{}
\item \out{}\href{../../teal.slice/html/FilterStates.html#method-queue_initialize}{\code{teal.slice::FilterStates$queue_initialize()}}\out{}
@@ -46,6 +44,9 @@ Specialization of \code{FilterStates} for \code{SummaryExperiment}.
\if{html}{\out{}}
\if{latex}{\out{\hypertarget{method-new}{}}}
\subsection{Method \code{new()}}{
+Initialize \code{SEFilterStates} object
+
+Initialize \code{SEFilterStates} object
\subsection{Usage}{
\if{html}{\out{}}\preformatted{SEFilterStates$new(input_dataname, output_dataname, datalabel)}\if{html}{\out{
}}
}
@@ -67,6 +68,26 @@ text label value.}
}
}
\if{html}{\out{
}}
+\if{html}{\out{}}
+\if{latex}{\out{\hypertarget{method-format}{}}}
+\subsection{Method \code{format()}}{
+Returns the formatted string representing this \code{MAEFilterStates} object.
+\subsection{Usage}{
+\if{html}{\out{}}\preformatted{SEFilterStates$format(indent = 0)}\if{html}{\out{
}}
+}
+
+\subsection{Arguments}{
+\if{html}{\out{}}
+\describe{
+\item{\code{indent}}{(\code{numeric(1)}) the number of spaces before each line of the representation}
+}
+\if{html}{\out{
}}
+}
+\subsection{Returns}{
+\code{character(1)} the formatted string
+}
+}
+\if{html}{\out{
}}
\if{html}{\out{}}
\if{latex}{\out{\hypertarget{method-server}{}}}
\subsection{Method \code{server()}}{
diff --git a/tests/testthat/test-DFFilterStates.R b/tests/testthat/test-DFFilterStates.R
index ea4e0e5b5..4c98cb8a1 100644
--- a/tests/testthat/test-DFFilterStates.R
+++ b/tests/testthat/test-DFFilterStates.R
@@ -255,3 +255,49 @@ testthat::test_that(
testthat::expect_identical(dffs$ui_add_filter_state("id", data.frame(A = numeric(0))), div("no samples available"))
}
)
+
+# Format
+testthat::test_that("$format() is a method of DFFilterStates", {
+ testthat::expect_error(DFFilterStates$new(
+ input_dataname = "test",
+ output_dataname = "test",
+ datalabel = character(0),
+ varlabels = "test",
+ keys = "test"
+ )$format(), NA)
+})
+
+testthat::test_that("$format() asserts the indent argument is a number", {
+ testthat::expect_error(
+ DFFilterStates$new(
+ input_dataname = "test",
+ output_dataname = "test",
+ datalabel = character(0),
+ varlabels = "test",
+ keys = "test"
+ )$format(indent = "wrong type"),
+ regexp = "Assertion on 'indent' failed: Must be of type 'number'"
+ )
+})
+
+testthat::test_that("$format() concatenates its FilterState elements using \\n without additional indent", {
+ dffs <- DFFilterStates$new(
+ input_dataname = "iris",
+ output_dataname = "iris_filtered",
+ datalabel = character(0),
+ varlabels = character(0),
+ keys = character(0)
+ )
+ fs <- list(
+ Sepal.Length = list(selected = c(5.1, 6.4), keep_na = TRUE, keep_inf = TRUE),
+ Species = list(selected = c("setosa", "versicolor"), keep_na = FALSE)
+ )
+ dffs$set_filter_state(state = fs, data = iris)
+
+ sepal_filter <- dffs$queue_get(1L)[[1]]
+ species_filter <- dffs$queue_get(1L)[[2]]
+ shiny::isolate(testthat::expect_equal(
+ dffs$format(),
+ paste(sepal_filter$format(indent = 0), species_filter$format(indent = 0), sep = "\n")
+ ))
+})
diff --git a/tests/testthat/test-DateFilterState.R b/tests/testthat/test-DateFilterState.R
index 3a36b5735..33dad5208 100644
--- a/tests/testthat/test-DateFilterState.R
+++ b/tests/testthat/test-DateFilterState.R
@@ -199,3 +199,50 @@ testthat::test_that(
)
}
)
+
+# Format
+testthat::test_that("$format() is a FilterStates's method that accepts indent", {
+ test_date <- as.Date("13/07/2013", format = "%d/%m/%y")
+ filter_state <- DateFilterState$new(test_date, varname = "test_date")
+ testthat::expect_error(shiny::isolate(filter_state$format(indent = 0)), regexp = NA)
+})
+
+testthat::test_that("$format() asserts that indent is numeric", {
+ test_date <- as.Date("13/07/2013", format = "%d/%m/%y")
+ filter_state <- DateFilterState$new(test_date, varname = "test_date")
+ testthat::expect_error(
+ filter_state$format(indent = "wrong type"),
+ regexp = "Assertion on 'indent' failed: Must be of type 'number'"
+ )
+})
+
+testthat::test_that("$format() returns a string representation the FilterState object", {
+ test_date <- as.Date("13/07/2013", format = "%d/%m/%y")
+ filter_state <- DateFilterState$new(test_date, varname = "test")
+ filter_state$set_state(list(selected = c(test_date, test_date)))
+ testthat::expect_equal(
+ shiny::isolate(filter_state$format(indent = 0)),
+ paste(
+ "Filtering on: test",
+ " Selected range: 2020-07-13 - 2020-07-13",
+ " Include missing values: FALSE",
+ sep = "\n"
+ )
+ )
+})
+
+testthat::test_that("$format() prepends spaces to every line of the returned string", {
+ test_date <- as.Date("13/07/2013", format = "%d/%m/%y")
+ filter_state <- DateFilterState$new(test_date, varname = "test")
+ filter_state$set_state(list(selected = c(test_date, test_date)))
+ for (i in 1:3) {
+ whitespace_indent <- paste0(rep(" ", i), collapse = "")
+ testthat::expect_equal(
+ shiny::isolate(filter_state$format(indent = !!(i))),
+ sprintf(
+ "%sFiltering on: test\n%1$s Selected range: 2020-07-13 - 2020-07-13\n%1$s Include missing values: FALSE",
+ format("", width = i)
+ )
+ )
+ }
+})
diff --git a/tests/testthat/test-DatetimeFilterState.R b/tests/testthat/test-DatetimeFilterState.R
index a5d1f690b..dec4cacdf 100644
--- a/tests/testthat/test-DatetimeFilterState.R
+++ b/tests/testthat/test-DatetimeFilterState.R
@@ -211,3 +211,55 @@ testthat::test_that(
)
}
)
+
+# Format
+testthat::test_that("$format() is a FilterStates's method that accepts indent", {
+ object <- as.POSIXct(8, origin = "1900/01/01", tz = "GMT")
+ filter_state <- DatetimeFilterState$new(object, varname = "test")
+ testthat::expect_error(shiny::isolate(filter_state$format(indent = 0)), regexp = NA)
+})
+
+testthat::test_that("$format() asserts that indent is numeric", {
+ object <- as.POSIXct(8, origin = "1900/01/01", tz = "GMT")
+ filter_state <- DatetimeFilterState$new(object, varname = "test")
+ testthat::expect_error(
+ filter_state$format(indent = "wrong type"),
+ regexp = "Assertion on 'indent' failed: Must be of type 'number'"
+ )
+})
+
+testthat::test_that("$format() returns a string representation the FilterState object", {
+ object <- as.POSIXct(8, origin = "1900/01/01", tz = "GMT")
+ filter_state <- DatetimeFilterState$new(object, varname = "test")
+ filter_state$set_state(list(selected = c(object, object)))
+ testthat::expect_equal(
+ shiny::isolate(filter_state$format(indent = 0)),
+ paste(
+ "Filtering on: test",
+ " Selected range: 1900-01-01 00:00:08 - 1900-01-01 00:00:08",
+ " Include missing values: FALSE",
+ sep = "\n"
+ )
+ )
+})
+
+testthat::test_that("$format() prepends spaces to every line of the returned string", {
+ object <- as.POSIXct(8, origin = "1900/01/01", tz = "GMT")
+ filter_state <- DatetimeFilterState$new(object, varname = "test")
+ filter_state$set_state(list(selected = c(object, object)))
+ for (i in 1:3) {
+ whitespace_indent <- paste0(rep(" ", i), collapse = "")
+ testthat::expect_equal(
+ shiny::isolate(filter_state$format(indent = !!(i))),
+ sprintf(
+ paste(
+ "%sFiltering on: test",
+ "%1$s Selected range: 1900-01-01 00:00:08 - 1900-01-01 00:00:08",
+ "%1$s Include missing values: FALSE",
+ sep = "\n"
+ ),
+ format("", width = i)
+ )
+ )
+ }
+})
diff --git a/tests/testthat/test-FilterState.R b/tests/testthat/test-FilterState.R
index 853914d71..958e3da8e 100644
--- a/tests/testthat/test-FilterState.R
+++ b/tests/testthat/test-FilterState.R
@@ -199,3 +199,44 @@ testthat::test_that(
)
}
)
+
+# Format
+testthat::test_that("$format() is a FilterStates's method that accepts indent", {
+ testthat::expect_error(shiny::isolate(FilterState$new(c(7), varname = "test")$format(indent = 0)), regexp = NA)
+})
+
+testthat::test_that("$format() asserts that indent is numeric", {
+ testthat::expect_error(
+ FilterState$new(c(7), varname = "test")$format(indent = "wrong type"),
+ regexp = "Assertion on 'indent' failed: Must be of type 'number'"
+ )
+})
+
+testthat::test_that("$format() returns a string representation the FilterState object", {
+ filter_state <- FilterState$new(c(7), varname = "test")
+ filter_state$set_state(list(selected = c(7, 7)))
+ testthat::expect_equal(
+ shiny::isolate(filter_state$format(indent = 0)),
+ paste(
+ "Filtering on: test",
+ " Selected values: 7.000 7.000",
+ " Include missing values: FALSE",
+ sep = "\n"
+ )
+ )
+})
+
+testthat::test_that("$format() prepends spaces to every line of the returned string", {
+ filter_state <- FilterState$new(c(7), varname = "test")
+ filter_state$set_state(list(selected = c(7, 7)))
+ for (i in 1:3) {
+ whitespace_indent <- paste0(rep(" ", i), collapse = "")
+ testthat::expect_equal(
+ shiny::isolate(filter_state$format(indent = !!(i))),
+ sprintf(
+ "%sFiltering on: test\n%1$s Selected values: 7.000 7.000\n%1$s Include missing values: FALSE",
+ format("", width = i)
+ )
+ )
+ }
+})
diff --git a/tests/testthat/test-FilteredDataset.R b/tests/testthat/test-FilteredDataset.R
index 6a456a87a..f5374ee26 100644
--- a/tests/testthat/test-FilteredDataset.R
+++ b/tests/testthat/test-FilteredDataset.R
@@ -140,3 +140,19 @@ testthat::test_that("get_metadata returns the metadata of the data passed to the
)
testthat::expect_null(filtered_dataset$get_metadata())
})
+
+# Format
+testthat::test_that("$get_formatted_filter_state returns a string representation of filters", {
+ dataset <- DefaultFilteredDataset$new(teal.data::dataset("iris", iris))
+ fs <- list(
+ Sepal.Length = list(selected = c(5.1, 6.4), keep_na = TRUE, keep_inf = TRUE),
+ Species = list(selected = c("setosa", "versicolor"), keep_na = FALSE)
+ )
+ dataset$set_filter_state(state = fs)
+ states <- dataset$get_filter_states()[[1]]
+
+ testthat::expect_equal(
+ shiny::isolate(dataset$get_formatted_filter_state()),
+ paste("Filters for dataset: iris", shiny::isolate(states$format(indent = 2)), sep = "\n")
+ )
+})
diff --git a/tests/testthat/test-MAEFilterStates.R b/tests/testthat/test-MAEFilterStates.R
index d4452acc5..64b81a5e2 100644
--- a/tests/testthat/test-MAEFilterStates.R
+++ b/tests/testthat/test-MAEFilterStates.R
@@ -283,3 +283,58 @@ testthat::test_that(
)
}
)
+
+# Format
+testthat::test_that("$format() is a method of DFFilterStates", {
+ testthat::expect_error(MAEFilterStates$new(
+ input_dataname = "iris",
+ output_dataname = "iris_filtered",
+ datalabel = character(0),
+ varlabels = character(0),
+ keys = character(0)
+ )$format(), NA)
+})
+
+testthat::test_that("$format() asserts the indent argument is a number", {
+ testthat::expect_error(
+ MAEFilterStates$new(
+ input_dataname = "iris",
+ output_dataname = "iris_filtered",
+ datalabel = character(0),
+ varlabels = character(0),
+ keys = character(0)
+ )$format(indent = "wrong type"),
+ regexp = "Assertion on 'indent' failed: Must be of type 'number'"
+ )
+})
+
+testthat::test_that("$format() concatenates its FilterState elements using \\n and indents the FilterState objects", {
+ utils::data(miniACC, package = "MultiAssayExperiment")
+ maefs <- MAEFilterStates$new(
+ input_dataname = "test",
+ output_dataname = "test_filtered",
+ datalabel = character(0),
+ varlabels = character(0),
+ keys = character(0)
+ )
+
+ maefs$set_filter_state(
+ state = list(
+ years_to_birth = c(30, 50),
+ vital_status = 1
+ ),
+ data = miniACC
+ )
+
+ years_to_birth_filter <- maefs$queue_get(1L)[[1]]
+ vital_status_filter <- maefs$queue_get(1L)[[2]]
+ shiny::isolate(testthat::expect_equal(
+ maefs$format(),
+ paste(
+ "Subject filters:",
+ years_to_birth_filter$format(indent = 2),
+ vital_status_filter$format(indent = 2),
+ sep = "\n"
+ )
+ ))
+})
diff --git a/tests/testthat/test-RangeFilterState.R b/tests/testthat/test-RangeFilterState.R
index 70e20e538..3d748a394 100644
--- a/tests/testthat/test-RangeFilterState.R
+++ b/tests/testthat/test-RangeFilterState.R
@@ -255,3 +255,45 @@ testthat::test_that(
)
}
)
+
+
+# Format
+testthat::test_that("$format() is a FilterStates's method that accepts indent", {
+ filter_state <- RangeFilterState$new(7, varname = "test")
+ testthat::expect_error(shiny::isolate(filter_state$format(indent = 0)), regexp = NA)
+})
+
+testthat::test_that("$format() asserts that indent is numeric", {
+ testthat::expect_error(
+ RangeFilterState$new(c(7), varname = "test")$format(indent = "wrong type"),
+ regexp = "Assertion on 'indent' failed: Must be of type 'number'"
+ )
+})
+
+testthat::test_that("$format() returns a string representation the FilterState object", {
+ filter_state <- RangeFilterState$new(c(7), varname = "test")
+ filter_state$set_state(list(selected = c(7, 7)))
+ testthat::expect_equal(
+ shiny::isolate(filter_state$format(indent = 0)),
+ paste(
+ "Filtering on: test",
+ " Selected range: 7.000 - 7.000",
+ " Include missing values: FALSE",
+ sep = "\n"
+ )
+ )
+})
+
+testthat::test_that("$format() prepends spaces to every line of the returned string", {
+ filter_state <- RangeFilterState$new(c(7), varname = "test")
+ filter_state$set_state(list(selected = c(7, 7)))
+ for (i in 1:3) {
+ testthat::expect_equal(
+ shiny::isolate(filter_state$format(indent = !!(i))),
+ sprintf(
+ "%sFiltering on: test\n%1$s Selected range: 7.000 - 7.000\n%1$s Include missing values: FALSE",
+ format("", width = i)
+ )
+ )
+ }
+})
diff --git a/tests/testthat/test-SEFilterStates.R b/tests/testthat/test-SEFilterStates.R
index c79352a6d..b1fce8bc6 100644
--- a/tests/testthat/test-SEFilterStates.R
+++ b/tests/testthat/test-SEFilterStates.R
@@ -412,3 +412,55 @@ testthat::test_that(
)
}
)
+
+# Format
+testthat::test_that("$format() is a method of SEFilterStates", {
+ testthat::expect_error(
+ SEFilterStates$new(
+ input_dataname = "test",
+ output_dataname = "test_filtered",
+ datalabel = character(0)
+ )$format(),
+ NA
+ )
+})
+
+testthat::test_that("$format() asserts the indent argument is a number", {
+ testthat::expect_error(
+ SEFilterStates$new(
+ input_dataname = "test",
+ output_dataname = "test_filtered",
+ datalabel = character(0)
+ )$format(indent = "wrong type"),
+ regexp = "Assertion on 'indent' failed: Must be of type 'number'"
+ )
+})
+
+testthat::test_that("$format() concatenates its FilterState elements using \\n and indents the FilterState strings", {
+ test <- get_test_data()
+ sefs <- SEFilterStates$new(
+ input_dataname = "test",
+ output_dataname = "test_filtered",
+ datalabel = "Label"
+ )
+
+ fs <- list(
+ select = list(Treatment = "ChIP"),
+ subset = list(feature_id = c("ID001", "ID002"))
+ )
+ sefs$set_filter_state(state = fs, data = test)
+
+ treatment_filter <- sefs$queue_get("select")[[1]]
+ feature_filter <- sefs$queue_get("subset")[[1]]
+ shiny::isolate(testthat::expect_equal(
+ sefs$format(),
+ paste(
+ "Assay Label filters:",
+ " Subsetting:",
+ feature_filter$format(indent = 4),
+ " Selecting:",
+ treatment_filter$format(indent = 4),
+ sep = "\n"
+ )
+ ))
+})
diff --git a/tests/testthat/test-init_filter_state.R b/tests/testthat/test-init_filter_state.R
index 8fd907fbc..253f94e0c 100644
--- a/tests/testthat/test-init_filter_state.R
+++ b/tests/testthat/test-init_filter_state.R
@@ -19,8 +19,6 @@ test_that("'extract_type' must be specified with 'input_dataname'", {
)
})
-
-
testthat::test_that("init_filter_state accepts, name or call as input_dataname", {
testthat::expect_error(
init_filter_state(7, varname = "test", input_dataname = NULL),
@@ -98,3 +96,8 @@ testthat::test_that("init_filter_state return a LogicalFilterState, if passed a
testthat::expect_error(fs <- init_filter_state(c(TRUE), varname = "test"), NA)
testthat::expect_true(is(fs, "LogicalFilterState"))
})
+
+testthat::test_that("init_filter_state default accepts a list", {
+ fs <- init_filter_state(list(1, 2, 3), varname = "test")
+ testthat::expect_true(inherits(fs, "FilterState"))
+})