-
-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Implement a new API #187
Comments
Implementation should keep supporting current way of specification (using lists). Specifying a list instead of |
Here is how I see this: The structure is:
A If a A
Per @gogonzo's design, this allows things like
What do you think? |
Once a
If a |
The |
Could you elaborate more about locked? Is it alternative to "filterable"? |
"locked" means non-filterable |
Agree, It makes more sense because by default all columns are filterable and we only substract from this set. But I suggest attribute name containing P.S. Feel free to remove |
Yes, "locked" was a placeholder name. I will go with "exclude". |
Should be reviewed together / with regard to #222 Closes #232 Problems to solve: - when initializing `FilterState` using FilterPanel API with choices, when parameter choices limits the number of possible values to select from, `is_any_filtered` should be set to TRUE to notice that the filter is applied always, therefore it must appear in the call. - test could not run due to different errors, mostly `argument "dataname" missing` - remove class `InteractiveFilterState` and `FilterState-abstract`, as they are not needed anymore (fixed filter will be set using `fixed` parameter) ``` state <- ChoicesFilterState$new( letters[c(1, 2)], x_reactive = reactive(NULL), "test", "var", choices = c("a", "b"), selected = c("a", "b"), ) shiny::isolate(state$get_state()) state$.__enclos_env__$private$is_choice_limited state <- ChoicesFilterState$new( letters, x_reactive = reactive(NULL), "test", "var", choices = c("a", "b"), selected = c("a", "b"), ) shiny::isolate(state$get_state()) state$.__enclos_env__$private$is_choice_limited ``` # Pull Request Part of #187 --------- Signed-off-by: Marek Blazewicz <110387997+BLAZEWIM@users.noreply.github.com> Co-authored-by: Blazewicz <blazewim@emea.roche.com> Co-authored-by: Dawid Kałędkowski <6959016+gogonzo@users.noreply.github.com> Co-authored-by: Aleksander Chlebowski <114988527+chlebowa@users.noreply.github.com>
This PR contains work towards a new filter panel API as outlined in #187. **TESTING class methods**: 1. preparations ``` # get FilteredData object on demand utils::data(miniACC, package = "MultiAssayExperiment") get_fd <- function() { init_filtered_data( x = list( iris = list(dataset = iris), mtcars = list(dataset = mtcars), mae = list(dataset = miniACC) ) ) } # specify filter states (old way) fss <- list( iris = list( "Species" = list(selected = "setosa"), "Sepal.Length" = list(selected = c(5, 6)) ), mtcars = list( "disp" = list(selected = c(0, 280)), "cyl" = list(selected = 6) ), 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) ) ) ) ) # specify filter states (new way) tss <- filter_settings( filter_var("iris", "Species", selected = "setosa"), filter_var("iris", "Sepal.Length", selected = c(5, 6)), filter_var("mtcars", "disp", selected = c(0, 280)), filter_var("mtcars", "cyl", selected = 6), filter_var("mae", "years_to_birth", selected = c(30, 50), keep_na = TRUE, keep_inf = FALSE, datalabel = "subjects", target = "y"), filter_var("mae", "vital_status", selected = "1", keep_na = FALSE, datalabel = "subjects", target = "y"), filter_var("mae", "gender", selected = "female", keep_na = TRUE, datalabel = "subjects", target = "y"), filter_var("mae", "ARRAY_TYPE", selected = "", keep_na = TRUE, datalabel = "RPPAArray", target = "subset") ) ``` 2. convert old states specification to new one ``` fss_new <- as.teal_slices(fss) identical(fss, tss) identical(fss_new, tss) ``` :point_up: this happens in `FilteredData$set_filter_state` with a warning Note `as.teal_slices` does not perform any validation, so a list-like filter state that specifies filters on columns of `MAE@colData` that is not wrapped as `list(MAE = list(...))` but is only `list(var = list(...))` will be interpreted as a `data.frame` filter. 3. set states as list ``` # create FilteredData fd <- get_fd() # apply filter states fd$set_filter_state(fss) # see calls fd$get_call("iris") %>% isolate fd$get_call("mtcars") %>% isolate fd$get_call("mae") %>% isolate #recover filter states fd$get_filter_state() %>% isolate ``` 4. set states as `teal_slices` ``` # create FilteredData fd <- get_fd() # apply filter states fd$set_filter_state(tss) # see calls fd$get_call("iris") %>% isolate fd$get_call("mtcars") %>% isolate fd$get_call("mae") %>% isolate #recover filter states fd$get_filter_state() %>% isolate ``` Note that calls are not generated. This is these filters are instantiated and constructors don't know how to handle choices yet, so by default they are created with everything selected, hence no calls. 5. modify states as `teal_slices` ``` fd$set_filter_state(tss) # see calls fd$get_call("iris") %>% isolate fd$get_call("mtcars") %>% isolate fd$get_call("mae") %>% isolate #recover filter states fd$get_filter_state() %>% isolate ``` **TESTING wrapper functions**: ``` datasets <- init_filtered_data( x = list( iris = list(dataset = iris), mae = list(dataset = miniACC) ) ) fs <- filter_settings( filter_var("iris", "Species", selected = c("setosa", "versicolor")), filter_var("iris", "Sepal.Length", selected = c(5.1, 6.4)), filter_var("mae", "years_to_birth", selected = c(30, 50), keep_na = TRUE, keep_inf = FALSE, datalabel = "subjects", target = "y"), filter_var("mae", "vital_status", selected = "1", keep_na = FALSE, datalabel = "subjects", target = "y"), filter_var("mae", "gender", selected = "female", keep_na = TRUE, datalabel = "subjects", target = "y"), filter_var("mae", "ARRAY_TYPE", selected = "", keep_na = TRUE, datalabel = "RPPAArray", target = "subset") ) # set initial filter state set_filter_state(datasets, filter = fs) fd$.__enclos_env__$private$get_filter_count() %>% isolate # get filter state get_filter_state(datasets) fd$.__enclos_env__$private$get_filter_count() %>% isolate # modify filter state set_filter_state( datasets, filter_settings( filter_var("iris", "Species", selected = "setosa", keep_na = TRUE) ) ) fd$.__enclos_env__$private$get_filter_count() %>% isolate # remove specific filters remove_filter_state( datasets, filter_settings( filter_var("iris", "Species"), filter_var("mae", "years_to_birth"), filter_var("mae", "vital_status") ) ) fd$.__enclos_env__$private$get_filter_count() %>% isolate # remove all states clear_filter_states(datasets) fd$.__enclos_env__$private$get_filter_count() %>% isolate ``` --------- Signed-off-by: Marek Blazewicz <110387997+BLAZEWIM@users.noreply.github.com> Co-authored-by: Marek Blazewicz <110387997+BLAZEWIM@users.noreply.github.com> Co-authored-by: Blazewicz <blazewim@emea.roche.com> Co-authored-by: Dawid Kałędkowski <6959016+gogonzo@users.noreply.github.com>
Initial work for the #138
Check
?filter_state_api
. There areset_filter_state
,get_filter_state
,remove_filter_state
andget_filter_state
. They are exported functions which calls methods of the same name in theFilteredData
.They passing the instructions to the classes to manage FilterState in the
filter_state_list
. Currently this communication is done by passing the list, for exampleWe need to introduce a different way of passing this informations through the classes. Currently nested list shown above is transfered through
FilteredData$set_filter_state -> FilteredDataset$set_filter_state -> FilterStates$set_filter_state -> FilterState$set_state
. While passed from class to class list get unnested andFilterState
.We want to introduce something like this, which can be easily extended in the future by new type of filters or by new "arguments" which can cause some specific behavour of the filter-state within state_list.
Comparing to the current API, in the new one we should be able also to specify "choices" which will limit number of choices in the initialized filter-state.
Arguments of the filter_var
character(1))
name of the datasetcharacter(1))
name of the column in datasetvector
) values of the column which should define range/set of the choicesvector
) values of the choices being a default/initial selectioncharacter(1)
) text describing the filterArguments of the filter_settings
filter_var
,mae_patient_var
,mae_gene_subset
,mae_gene_select
)list
) named after datasets, containing character vectors containing columns which can be chosen to filter. Same as current implementation on main.Because
choices
hasn't been yet implemented in the class it might be skipped if you found it difficult to just sneak-in in this PR.The text was updated successfully, but these errors were encountered: