From f76f78845df43f99068f91031a4d1488c78c6a20 Mon Sep 17 00:00:00 2001 From: go_gonzo Date: Fri, 11 Aug 2023 11:34:10 +0200 Subject: [PATCH 1/5] commit 1 --- R/FilteredData-utils.R | 1 - R/FilteredData.R | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/R/FilteredData-utils.R b/R/FilteredData-utils.R index 73dd94fd4..85b7657b0 100644 --- a/R/FilteredData-utils.R +++ b/R/FilteredData-utils.R @@ -55,7 +55,6 @@ init_filtered_data.TealData <- function(x, # nolint #' @export init_filtered_data.default <- function(x, join_keys = teal.data::join_keys(), code = NULL, check = FALSE) { # nolint checkmate::assert_list(x, any.missing = FALSE, names = "unique") - mapply(validate_dataset_args, x, names(x)) checkmate::assert_class(code, "CodeClass", null.ok = TRUE) checkmate::assert_class(join_keys, "JoinKeys") checkmate::assert_flag(check) diff --git a/R/FilteredData.R b/R/FilteredData.R index 193021b08..25ec85c4b 100644 --- a/R/FilteredData.R +++ b/R/FilteredData.R @@ -95,7 +95,6 @@ FilteredData <- R6::R6Class( # nolint for (dataname in ordered_datanames) { ds_object <- data_objects[[dataname]] - validate_dataset_args(ds_object, dataname) if (inherits(ds_object, c("data.frame", "MultiAssayExperiment"))) { self$set_dataset( data = ds_object, @@ -104,6 +103,7 @@ FilteredData <- R6::R6Class( # nolint } else { # custom support for TealData object which pass metadata and label also # see init_filtered_data.TealData + validate_dataset_args(ds_object, dataname) self$set_dataset( data = ds_object$dataset, dataname = dataname, @@ -327,7 +327,7 @@ FilteredData <- R6::R6Class( # nolint #' Label to describe the dataset #' @return (`self`) invisibly this `FilteredData` #' - set_dataset = function(data, dataname, metadata, label) { + set_dataset = function(data, dataname, metadata = attr(data, "metadata"), label = attr(data, "label")) { logger::log_trace("FilteredData$set_dataset setting dataset, name: { dataname }") # to include it nicely in the Show R Code; # the UI also uses `datanames` in ids, so no whitespaces allowed From 2b1a77ee5f81acaaf699b7c9d26a95d471601b13 Mon Sep 17 00:00:00 2001 From: go_gonzo Date: Tue, 15 Aug 2023 08:58:27 +0200 Subject: [PATCH 2/5] up --- NAMESPACE | 1 + R/FilteredData-utils.R | 30 +++++++++--------------------- man/FilteredData.Rd | 7 ++++++- 3 files changed, 16 insertions(+), 22 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 082fe0b30..5bc0bbdbf 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -23,6 +23,7 @@ S3method(init_filter_states,data.frame) S3method(init_filter_states,matrix) S3method(init_filtered_data,TealData) S3method(init_filtered_data,default) +S3method(init_filtered_data,tdata) S3method(init_filtered_dataset,MultiAssayExperiment) S3method(init_filtered_dataset,data.frame) S3method(print,teal_slice) diff --git a/R/FilteredData-utils.R b/R/FilteredData-utils.R index 85b7657b0..f18d1824c 100644 --- a/R/FilteredData-utils.R +++ b/R/FilteredData-utils.R @@ -26,31 +26,19 @@ init_filtered_data <- function(x, join_keys, code, check) { #' @keywords internal #' @export -init_filtered_data.TealData <- function(x, # nolint - join_keys = x$get_join_keys(), - code = x$get_code_class(), - check = x$get_check()) { - data_objects <- lapply( - x$get_datanames(), - function(dataname) { - dataset <- x$get_dataset(dataname) - list( - dataset = dataset$get_raw_data(), - metadata = dataset$get_metadata(), - label = dataset$get_dataset_label() - ) - } - ) - names(data_objects) <- x$get_datanames() - - init_filtered_data( - x = data_objects, - join_keys = join_keys, - code = code, +init_filtered_data.tdata <- function(x, join_keys = teal.data::join_keys(), code = NULL, check = FALSE) { # nolint + checkmate::assert_class(code, "CodeClass", null.ok = TRUE) + checkmate::assert_class(join_keys, "JoinKeys") + checkmate::assert_flag(check) + FilteredData$new( + as.list(x@env), + join_keys = x@join_keys, + code = teal.data:::CodeClass$new(code = teal.code::get_code(x), dataname = teal.data::get_dataname(x)), check = check ) } + #' @keywords internal #' @export init_filtered_data.default <- function(x, join_keys = teal.data::join_keys(), code = NULL, check = FALSE) { # nolint diff --git a/man/FilteredData.Rd b/man/FilteredData.Rd index 5cba73af1..e4b6a91c1 100644 --- a/man/FilteredData.Rd +++ b/man/FilteredData.Rd @@ -425,7 +425,12 @@ Get keys for the dataset. \subsection{Method \code{set_dataset()}}{ Adds a dataset to this \code{FilteredData}. \subsection{Usage}{ -\if{html}{\out{
}}\preformatted{FilteredData$set_dataset(data, dataname, metadata, label)}\if{html}{\out{
}} +\if{html}{\out{
}}\preformatted{FilteredData$set_dataset( + data, + dataname, + metadata = attr(data, "metadata"), + label = attr(data, "label") +)}\if{html}{\out{
}} } \subsection{Arguments}{ From 450ddc001cba62d73c60bc2951c981c2a38a6084 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dawid=20Ka=C5=82=C4=99dkowski?= Date: Thu, 17 Aug 2023 07:36:18 +0200 Subject: [PATCH 3/5] fix --- R/FilteredData-utils.R | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/R/FilteredData-utils.R b/R/FilteredData-utils.R index f18d1824c..abf06c707 100644 --- a/R/FilteredData-utils.R +++ b/R/FilteredData-utils.R @@ -33,7 +33,10 @@ init_filtered_data.tdata <- function(x, join_keys = teal.data::join_keys(), code FilteredData$new( as.list(x@env), join_keys = x@join_keys, - code = teal.data:::CodeClass$new(code = teal.code::get_code(x), dataname = teal.data::get_dataname(x)), + code = teal.data:::CodeClass$new( + code = paste(teal.code::get_code(x), collapse = "\n"), + dataname = teal.data::get_dataname(x) + ), check = check ) } From a8dd3fdef3cb566636b68e398cdeecc16301e4e5 Mon Sep 17 00:00:00 2001 From: go_gonzo Date: Fri, 29 Sep 2023 15:21:52 +0200 Subject: [PATCH 4/5] tdata -> teal_data --- R/FilteredData-utils.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/FilteredData-utils.R b/R/FilteredData-utils.R index abf06c707..8e8677981 100644 --- a/R/FilteredData-utils.R +++ b/R/FilteredData-utils.R @@ -26,7 +26,7 @@ init_filtered_data <- function(x, join_keys, code, check) { #' @keywords internal #' @export -init_filtered_data.tdata <- function(x, join_keys = teal.data::join_keys(), code = NULL, check = FALSE) { # nolint +init_filtered_data.teal_data <- function(x, join_keys = teal.data::join_keys(), code = NULL, check = FALSE) { # nolint checkmate::assert_class(code, "CodeClass", null.ok = TRUE) checkmate::assert_class(join_keys, "JoinKeys") checkmate::assert_flag(check) From 79d756e5ae53c44dcbd32df141ebd8ebff01748b Mon Sep 17 00:00:00 2001 From: go_gonzo Date: Mon, 2 Oct 2023 09:26:00 +0200 Subject: [PATCH 5/5] export method for teal_data --- NAMESPACE | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 5bc0bbdbf..fc8f4bc57 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -21,9 +21,8 @@ S3method(init_filter_states,MultiAssayExperiment) S3method(init_filter_states,SummarizedExperiment) S3method(init_filter_states,data.frame) S3method(init_filter_states,matrix) -S3method(init_filtered_data,TealData) S3method(init_filtered_data,default) -S3method(init_filtered_data,tdata) +S3method(init_filtered_data,teal_data) S3method(init_filtered_dataset,MultiAssayExperiment) S3method(init_filtered_dataset,data.frame) S3method(print,teal_slice)