Managing FilteredData states
filter_state_api.RdUsage
set_filter_state(datasets, filter)
get_filter_state(datasets)
remove_filter_state(datasets, filter)
clear_filter_states(datasets)Arguments
- datasets
(
FilteredData)
object to store filter state and filtered datasets, shared across modules. For more details seeFilteredData- filter
-
(
list)
You can define filters that show when the app starts. List names should be named according to datanames passed to thedataargument. In case of data.frame` the list should be composed as follows:list(<dataname1> = list(<varname1> = ..., <varname2> = ...), <dataname2> = list(...), ...)For example, filters for variable
Sepal.Lengthiniriscan be specified as follows:list(iris = list(Sepal.Length = list(selected = c(5.0, 7.0)))) # or list(iris = list(Sepal.Length = c(5.0, 7.0)))In case developer would like to include
NAandInfvalues in the filtered dataset.list(Species = list(selected = c(5.0, 7.0), keep_na = TRUE, keep_inf = TRUE)) list(Species = c(c(5.0, 7.0), NA, Inf))To initialize with specific variable filter with all values on start, one can use
list(Species = list())filtershould be set with respect to the class of the column:numeric:selectedshould be a two elements vector defining the range of the filter.Date:selectedshould be a two elements vector defining the date-range of the filterPOSIXct:selectedshould be a two elements vector defining thedatetimerange of the filtercharacterandfactor:selectedshould be a vector of any length defining initial values selected to filter.MultiAssayExperimentfiltershould be specified in slightly different way. SinceMultiAssayExperiment::MultiAssayExperiment()contains patient data (SummarizedExperiment::colData()) with list of experiments (MultiAssayExperiment::ExperimentList()),filterlist should be named in the following name.
list( <MAE dataname> = list( subjects = list(<column in colData> = ..., <column in colData> = ...), <experiment name> = list( subset = list(<column in rowData of experiment> = ..., <column in rowData of experiment> = ...), select = list(<column in colData of experiment> = ..., <column in colData of experiment> = ...) ) ) )filteris ignored if the app is restored from a bookmarked state.
Value
set, remove and clear returns
NULLget returns named
listof the same structure as described infilterargument.
Examples
utils::data(miniACC, package = "MultiAssayExperiment")
datasets <- init_filtered_data(
x = list(
iris = list(dataset = iris),
mae = list(dataset = 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))
)
)
)
# set initial filter state
set_filter_state(datasets, filter = fs)
# get filter state
get_filter_state(datasets)
#> $iris
#> $iris$Sepal.Length
#> $iris$Sepal.Length$selected
#> [1] 5.1 6.4
#>
#> $iris$Sepal.Length$keep_na
#> [1] TRUE
#>
#> $iris$Sepal.Length$keep_inf
#> [1] FALSE
#>
#>
#> $iris$Species
#> $iris$Species$selected
#> [1] "setosa" "versicolor"
#>
#> $iris$Species$keep_na
#> [1] FALSE
#>
#>
#>
#> $mae
#> $mae$subjects
#> $mae$subjects$years_to_birth
#> $mae$subjects$years_to_birth$selected
#> [1] 30 50
#>
#> $mae$subjects$years_to_birth$keep_na
#> [1] TRUE
#>
#> $mae$subjects$years_to_birth$keep_inf
#> [1] FALSE
#>
#>
#> $mae$subjects$vital_status
#> $mae$subjects$vital_status$selected
#> [1] "1"
#>
#> $mae$subjects$vital_status$keep_na
#> [1] FALSE
#>
#>
#> $mae$subjects$gender
#> $mae$subjects$gender$selected
#> [1] "female"
#>
#> $mae$subjects$gender$keep_na
#> [1] TRUE
#>
#>
#>
#> $mae$RPPAArray
#> $mae$RPPAArray$subset
#> $mae$RPPAArray$subset$ARRAY_TYPE
#> $mae$RPPAArray$subset$ARRAY_TYPE$selected
#> [1] ""
#>
#> $mae$RPPAArray$subset$ARRAY_TYPE$keep_na
#> [1] TRUE
#>
#>
#>
#>
#>
#> attr(,"formatted")
#> [1] "Filters for dataset: iris\n Filtering on: Sepal.Length\n Selected range: 5.100 - 6.400\n Include missing values: TRUE\n Filtering on: Species\n Selected values: setosa versicolor\n Include missing values: FALSE\nFilters for dataset: mae\n Subject filters:\n Filtering on: years_to_birth\n Selected range: 30.000 - 50.000\n Include missing values: TRUE\n Filtering on: vital_status\n Selected values: 1\n Include missing values: FALSE\n Filtering on: gender\n Selected values: female\n Include missing values: TRUE\nNULL"
# modify filter state
set_filter_state(
datasets,
filter = list(iris = list(Species = list(selected = "setosa", keep_na = TRUE)))
)
# remove specific filters
remove_filter_state(datasets,
filter = list(
iris = "Species",
mae = list(
subjects = c("years_to_birth", "vital_status")
)
)
)
# remove all states
clear_filter_states(datasets)