From a1f45335a3308b0935fdecf51220cb689a225165 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ver=C3=ADssimo?= <211358+averissimo@users.noreply.github.com> Date: Thu, 21 Dec 2023 08:15:57 +0000 Subject: [PATCH] fix: change dispatch method to S3 instead of custom --- NAMESPACE | 4 ++++ R/methods-get_filter_call.R | 28 +++++++++------------------ man/default_filter_panel_internals.Rd | 16 +++++++-------- 3 files changed, 21 insertions(+), 27 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 809f5e380..ff3d28908 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -6,6 +6,10 @@ S3method(as.list,teal_slices) S3method(c,teal_slices) S3method(format,teal_slice) S3method(format,teal_slices) +S3method(get_filter_call,MultiAssayExperiment) +S3method(get_filter_call,SummarizedExperiment) +S3method(get_filter_call,array.Matrix) +S3method(get_filter_call,data.frame) S3method(get_filter_call,default) S3method(get_filter_overview,default) S3method(get_slice_variable,default) diff --git a/R/methods-get_filter_call.R b/R/methods-get_filter_call.R index e7b7e5660..1286a576c 100644 --- a/R/methods-get_filter_call.R +++ b/R/methods-get_filter_call.R @@ -13,22 +13,12 @@ get_filter_call <- function(data, states_list) { #' @rdname get_filter_call #' @export get_filter_call.default <- function(data, states_list) { - if (inherits(data, "data.frame")) { - get_filter_call_data.frame(data, states_list) - } else if (inherits(data, c("array", "Matrix"))) { - get_filter_call_array(data, states_list) - } else if (inherits(data, "SummarizedExperiment")) { - get_filter_call_SummarizedExperiment(data, states_list) - } else if (inherits(data, "MultiAssayExperiment")) { - get_filter_call_MultiAssayExperiment(data, states_list) - } else { - stop("get_filter_call not implemented for class ", class(data), call. = FALSE) - } + stop("get_filter_call not implemented for class ", class(data), call. = FALSE) } #' @rdname default_filter_panel_internals -#' @keywords internal -get_filter_call_data.frame <- function(data, states_list) { +#' @export +get_filter_call.data.frame <- function(data, states_list) { dataname_lang <- str2lang(states_list[[1L]]$get_state()$dataname) states_predicate <- lapply(states_list, function(state) state$get_call()) combined_predicate <- calls_combine_by(states_predicate, "&") @@ -41,8 +31,8 @@ get_filter_call_data.frame <- function(data, states_list) { } #' @rdname default_filter_panel_internals -#' @keywords internal -get_filter_call_array <- function(data, states_list) { +#' @export +get_filter_call.array.Matrix <- function(data, states_list) { dataname_lang <- str2lang(states_list[[1L]]$get_state()$dataname) states_predicate <- lapply(states_list, function(state) state$get_call()) combined_predicate <- calls_combine_by(states_predicate, "&") @@ -55,8 +45,8 @@ get_filter_call_array <- function(data, states_list) { } #' @rdname default_filter_panel_internals -#' @keywords internal -get_filter_call_MultiAssayExperiment <- function(data, states_list) { +#' @export +get_filter_call.MultiAssayExperiment <- function(data, states_list) { states_grouped <- split( states_list, sapply(states_list, function(x) if (is.null(x$get_state()$experiment)) "_subjects_" else x$get_state()$experiment) @@ -96,8 +86,8 @@ get_filter_call_MultiAssayExperiment <- function(data, states_list) { } #' @rdname default_filter_panel_internals -#' @keywords internal -get_filter_call_SummarizedExperiment <- function(data, states_list) { +#' @export +get_filter_call.SummarizedExperiment <- function(data, states_list) { state_list_grouped <- split( states_list, sapply(states_list, function(x) x$get_state()$arg) diff --git a/man/default_filter_panel_internals.Rd b/man/default_filter_panel_internals.Rd index 94d7c88ad..30275923c 100644 --- a/man/default_filter_panel_internals.Rd +++ b/man/default_filter_panel_internals.Rd @@ -5,10 +5,10 @@ % R/methods-module_overview.R \name{default_filter_panel_internals} \alias{default_filter_panel_internals} -\alias{get_filter_call_data.frame} -\alias{get_filter_call_array} -\alias{get_filter_call_MultiAssayExperiment} -\alias{get_filter_call_SummarizedExperiment} +\alias{get_filter_call.data.frame} +\alias{get_filter_call.array.Matrix} +\alias{get_filter_call.MultiAssayExperiment} +\alias{get_filter_call.SummarizedExperiment} \alias{get_merge_call} \alias{get_slice_variable_array} \alias{get_slice_variable_MultiAssayExperiment} @@ -31,13 +31,13 @@ \alias{get_filter_overview_SummarizedExperiment} \title{Default methods for supported datasets} \usage{ -get_filter_call_data.frame(data, states_list) +\method{get_filter_call}{data.frame}(data, states_list) -get_filter_call_array(data, states_list) +\method{get_filter_call}{array.Matrix}(data, states_list) -get_filter_call_MultiAssayExperiment(data, states_list) +\method{get_filter_call}{MultiAssayExperiment}(data, states_list) -get_filter_call_SummarizedExperiment(data, states_list) +\method{get_filter_call}{SummarizedExperiment}(data, states_list) get_merge_call(join_keys)