From d35c29a74e4789fddce13bee5175629af2ef46c6 Mon Sep 17 00:00:00 2001 From: A Wokaty Date: Wed, 29 Oct 2025 11:04:14 -0400 Subject: [PATCH 01/21] bump x.y.z version to odd y following creation of RELEASE_3_22 branch --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 5a7910c..2728f4f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: tidySummarizedExperiment Title: Brings SummarizedExperiment to the Tidyverse -Version: 1.20.0 +Version: 1.21.0 Authors@R: c(person("Stefano", "Mangiola", email = "mangiolastefano@gmail.com", role = c("aut", "cre")) ) Author: Stefano Mangiola [aut, cre] From d0aa78879a24679cd4d4ba8093a40d94adaae360 Mon Sep 17 00:00:00 2001 From: Stefano Mangiola Date: Wed, 11 Mar 2026 17:54:31 +1030 Subject: [PATCH 02/21] Update version to 1.20.4, add tidyprint dependency, and replace messages with tidy_message for improved consistency in user feedback. Enhance error handling in various functions to provide clearer guidance on usage and potential issues. --- DESCRIPTION | 3 +- NAMESPACE | 1 + R/dplyr_methods.R | 36 ++++++++-------- R/filter.R | 10 +++-- R/join.R | 9 ++-- R/mutate.R | 13 +++--- R/rename.R | 20 ++++----- R/select.R | 50 ++++++++++++----------- R/tidyr_methods.R | 81 ++++++++++++++++++------------------ R/utilities.R | 102 +++++++++++++++++++++++++++------------------- 10 files changed, 172 insertions(+), 153 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 8251d85..4690144 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: tidySummarizedExperiment Title: Brings SummarizedExperiment to the Tidyverse -Version: 1.20.3 +Version: 1.20.4 Authors@R: c(person("Stefano", "Mangiola", email = "mangiolastefano@gmail.com", role = c("aut", "cre")) ) Author: Stefano Mangiola [aut, cre] @@ -21,6 +21,7 @@ Depends: SummarizedExperiment, ttservice (>= 0.5.0) Imports: + tidyprint, dplyr, tibble (>= 3.0.4), magrittr, diff --git a/NAMESPACE b/NAMESPACE index 7d885c6..76bbe65 100755 --- a/NAMESPACE +++ b/NAMESPACE @@ -124,6 +124,7 @@ importFrom(tibble,as_tibble) importFrom(tibble,enframe) importFrom(tibble,rowid_to_column) importFrom(tibble,tibble) +importFrom(tidyprint,tidy_message) importFrom(tidyr,extract) importFrom(tidyr,gather) importFrom(tidyr,nest) diff --git a/R/dplyr_methods.R b/R/dplyr_methods.R index f72e4b7..e4c80b6 100755 --- a/R/dplyr_methods.R +++ b/R/dplyr_methods.R @@ -11,6 +11,7 @@ #' @importFrom SummarizedExperiment assays<- #' @importFrom S4Vectors SimpleList #' @importFrom ttservice bind_rows +#' @importFrom tidyprint tidy_message #' @importFrom lifecycle deprecate_warn #' @references #' Hutchison, W.J., Keyes, T.J., The tidyomics Consortium. et al. The tidyomics ecosystem: enhancing omic data analyses. Nat Methods 21, 1166–1170 (2024). https://doi.org/10.1038/s41592-024-02299-2 @@ -25,7 +26,7 @@ bind_rows.SummarizedExperiment <- function(..., .id=NULL, add.cell.ids=NULL) { tts <- flatten_if(dots_values(...), is_spliced) if (is_split_by_sample(tts) && is_split_by_transcript(tts)) { - stop("tidySummarizedExperiment says: bind_rows cannot be applied to splits both by sample- and feature-wise information") + tidy_stop("bind_rows cannot be applied to splits both by sample- and feature-wise information") } new_obj <- if (is_split_by_sample(tts)) { cbind(tts[[1]], tts[[2]]) @@ -38,8 +39,7 @@ bind_rows.SummarizedExperiment <- function(..., .id=NULL, add.cell.ids=NULL) { # If duplicated sample names if (new_obj |> colnames() |> duplicated() |> which() |> length() |> gt(0)) { - warning("tidySummarizedExperiment says:", - " you have duplicated sample names, they will be made unique.") + tidy_warning("you have duplicated sample names, they will be made unique.") } unique_colnames <- make.unique(colnames(new_obj), sep="_") @@ -91,8 +91,7 @@ append_samples.SummarizedExperiment <- function(x, ..., .id = NULL) { # If duplicated sample names if (any(duplicated(colnames(new_obj)))) { - warning("tidySummarizedExperiment says:", - " you have duplicated sample names, they will be made unique.") + tidy_warning("you have duplicated sample names, they will be made unique.") unique_colnames <- make.unique(colnames(new_obj), sep = "_") colnames(new_obj) <- unique_colnames @@ -176,7 +175,7 @@ bind_cols_internal <- function(..., .id=NULL, column_belonging=NULL) { ))) { update_SE_from_tibble(bound, tts[[1]], column_belonging = column_belonging) } else { - warning("tidySummarizedExperiment says: The new columns do not include pure sample-wise or feature-wise. A data frame is returned for independent data analysis.") + tidy_warning("The new columns do not include pure sample-wise or feature-wise. A data frame is returned for independent data analysis.") bound } } @@ -254,7 +253,7 @@ distinct.SummarizedExperiment <- function(.data, ..., .keep_all=FALSE) { #' @export group_by.SummarizedExperiment <- function(.data, ..., .add=FALSE, .drop=group_by_drop_default(.data)) { - message(data_frame_returned_message) + tidy_message(data_frame_returned_message) # Deprecation of special column names .cols <- enquos(..., .ignore_empty="all") %>% @@ -285,7 +284,7 @@ group_by.SummarizedExperiment <- function(.data, ..., #' Wickham, H., François, R., Henry, L., Müller, K., Vaughan, D. (2023). dplyr: A Grammar of Data Manipulation. R package version 2.1.4, https://CRAN.R-project.org/package=dplyr #' @export summarise.SummarizedExperiment <- function(.data, ...) { - message(data_frame_returned_message) + tidy_message(data_frame_returned_message) # Deprecation of special column names .cols <- enquos(..., .ignore_empty="all") %>% @@ -333,7 +332,7 @@ summarize.SummarizedExperiment <- summarise.SummarizedExperiment #' Wickham, H., François, R., Henry, L., Müller, K., Vaughan, D. (2023). dplyr: A Grammar of Data Manipulation. R package version 2.1.4, https://CRAN.R-project.org/package=dplyr #' @export rowwise.SummarizedExperiment <- function(data, ...) { - message(data_frame_returned_message) + tidy_message(data_frame_returned_message) data |> as_tibble() |> @@ -406,7 +405,7 @@ sample_n.SummarizedExperiment <- function(tbl, size, replace=FALSE, weight=NULL, .env=NULL, ...) { lifecycle::signal_superseded("1.0.0", "sample_n()", "slice_sample()") - message(data_frame_returned_message) + tidy_message(data_frame_returned_message) tbl |> as_tibble() |> @@ -425,7 +424,7 @@ sample_frac.SummarizedExperiment <- function(tbl, size=1, replace=FALSE, weight=NULL, .env=NULL, ...) { lifecycle::signal_superseded("1.0.0", "sample_frac()", "slice_sample()") - message(data_frame_returned_message) + tidy_message(data_frame_returned_message) tbl |> as_tibble() |> @@ -448,7 +447,7 @@ sample_frac.SummarizedExperiment <- function(tbl, size=1, replace=FALSE, #' @export count.SummarizedExperiment <- function(x, ..., wt=NULL, sort=FALSE, name=NULL, .drop=group_by_drop_default(x)) { - message(data_frame_returned_message) + tidy_message(data_frame_returned_message) # Deprecation of special column names .cols <- enquos(..., .ignore_empty="all") %>% @@ -528,14 +527,13 @@ pull.SummarizedExperiment <- function(.data, var=-1, name=NULL, ...) { # Warning if column names of assays do not overlap if (check_if_assays_are_NOT_consistently_ordered(.data)) { - warning( - "tidySummarizedExperiment says:", - " the assays in your SummarizedExperiment have column names, ", + tidy_warning(paste0( + "the assays in your SummarizedExperiment have column names, ", "but their order is not the same. Pulling assays can return ", - "data in a order you don't expect. To avoid unwanted behaviour", - " it is highly recommended to have assays with the same order", - " of colnames and rownames" - ) + "data in a order you don't expect. To avoid unwanted behaviour ", + "it is highly recommended to have assays with the same order ", + "of colnames and rownames." + )) # reorder assay colnames before printing # Rearrange if assays has colnames and rownames diff --git a/R/filter.R b/R/filter.R index 92beb20..92d353a 100644 --- a/R/filter.R +++ b/R/filter.R @@ -56,6 +56,7 @@ analyze_query_scope_filter <- function(se, ...) { #' # Learn more in ?dplyr_tidy_eval #' #' @importFrom purrr map +#' @importFrom tidyprint tidy_message #' @importFrom dplyr filter #' @references #' Hutchison, W.J., Keyes, T.J., The tidyomics Consortium. et al. The tidyomics ecosystem: enhancing omic data analyses. Nat Methods 21, 1166–1170 (2024). https://doi.org/10.1038/s41592-024-02299-2 @@ -90,10 +91,11 @@ filter.SummarizedExperiment <- function(.data, ..., .preserve=FALSE) { dplyr::filter(..., .preserve=.preserve) if (!is_rectangular(new_meta, .data)) { - message("tidySummarizedExperiment says:", - " The resulting data frame is not rectangular", - " (all genes for all samples), a tibble is returned", - " for independent data analysis.") + tidy_message(paste0( + "The resulting data frame is not rectangular ", + "(all genes for all samples), a tibble is returned ", + "for independent data analysis." + )) return(new_meta) } else { .data[ diff --git a/R/join.R b/R/join.R index 2e8d192..d218d45 100644 --- a/R/join.R +++ b/R/join.R @@ -73,14 +73,14 @@ join_efficient_for_SE <- function(x, y, by = NULL, copy = FALSE, force_tibble_route) { # If I have a big dataset - if (ncol(x) > 100) message("tidySummarizedExperiment says: if you are joining a dataframe both sample-wise and feature-wise, for efficiency (until further development), it is better to separate your joins and join datasets sample-wise OR feature-wise.") + if (ncol(x) > 100) tidyprint::tidy_message("If you are joining a dataframe both sample-wise and feature-wise, for efficiency (until further development), it is better to separate your joins and join datasets sample-wise OR feature-wise.", type = "warning") joined <- x %>% as_tibble(skip_GRanges = TRUE) %>% join_function(y, by = by, copy = copy, suffix = suffix, ...) out <- if (!is_not_duplicated(joined, x) || !is_rectangular(joined, x)) { - message(duplicated_cell_names) - message(data_frame_returned_message) + tidyprint::tidy_message(duplicated_cell_names, type = "warning") + tidyprint::tidy_message(data_frame_returned_message) joined } else { update_SE_from_tibble(joined, x) @@ -173,7 +173,7 @@ join_efficient_for_SE <- function(x, y, by = NULL, copy = FALSE, x } - else stop("tidySummarizedExperiment says: ERROR FOR DEVELOPERS: this option should not exist. In join utility.") + else tidy_stop("ERROR FOR DEVELOPERS: this option should not exist. In join utility.") } #' @name left_join @@ -190,6 +190,7 @@ join_efficient_for_SE <- function(x, y, by = NULL, copy = FALSE, #' slice(1)) #' #' @importFrom dplyr left_join +#' @importFrom tidyprint tidy_message #' @references #' Hutchison, W.J., Keyes, T.J., The tidyomics Consortium. et al. The tidyomics ecosystem: enhancing omic data analyses. Nat Methods 21, 1166–1170 (2024). https://doi.org/10.1038/s41592-024-02299-2 #' diff --git a/R/mutate.R b/R/mutate.R index 0ec6077..1b9e165 100644 --- a/R/mutate.R +++ b/R/mutate.R @@ -216,14 +216,13 @@ mutate_via_tibble <- function(.data, ...) { columns <- special_columns |> paste(collapse=", ") - stop( - "tidySummarizedExperiment says:", - " you are trying to rename a column that is view only", + tidy_stop(paste0( + "you are trying to rename a column that is view only ", columns, - "(it is not present in the colData).", - " If you want to mutate a view-only column,", - " make a copy and mutate that one." - ) + " (it is not present in the colData). ", + "If you want to mutate a view-only column, ", + "make a copy and mutate that one." + )) } # If Ranges column not in query perform fast as_tibble diff --git a/R/rename.R b/R/rename.R index 0a42569..29e1960 100644 --- a/R/rename.R +++ b/R/rename.R @@ -44,14 +44,13 @@ rename.SummarizedExperiment <- function(.data, ...) { if (any(old_names %in% special_columns)) { columns <- intersect(old_names, special_columns) |> paste(collapse=", ") - stop( - "tidySummarizedExperiment says:", - " you are trying to rename a column that is view only: ", + tidy_stop(paste0( + "you are trying to rename a column that is view only: ", columns, - " (it is not present in the colData or rowData).", - " If you want to mutate a view-only column,", - " make a copy and mutate that one." - ) + " (it is not present in the colData or rowData). ", + "If you want to mutate a view-only column, ", + "make a copy and mutate that one." + )) } # Dispatch to appropriate domain-specific function @@ -63,9 +62,10 @@ rename.SummarizedExperiment <- function(.data, ...) { return(modify_features(.data, "rename", ...)) } else { # No matching columns found - stop("tidySummarizedExperiment says:", - " the columns you are trying to rename (", + tidy_stop(paste0( + "the columns you are trying to rename (", paste(old_names, collapse=", "), - ") are not found in colData or rowData.") + ") are not found in colData or rowData." + )) } } \ No newline at end of file diff --git a/R/select.R b/R/select.R index e544ef9..93d8c23 100644 --- a/R/select.R +++ b/R/select.R @@ -62,6 +62,7 @@ analyze_query_scope_select <- function(se, ...) { #' #' @importFrom SummarizedExperiment colData #' @importFrom dplyr select +#' @importFrom tidyprint tidy_message #' @importFrom tidyselect all_of #' @importFrom tidyselect any_of #' @export @@ -82,14 +83,13 @@ select.SummarizedExperiment <- function(.data, ...) { # Warning if column names of assays do not overlap if (check_if_assays_are_NOT_consistently_ordered(.data)) { - warning( - "tidySummarizedExperiment says:", - " the assays in your SummarizedExperiment have column names,", - " but their order is not the same. Assays were internally", - " reordered to be consistent with each other.", - " To avoid unwanted behaviour it is highly reccomended", - " to have assays with the same order of colnames and rownames." - ) + tidy_warning(paste0( + "the assays in your SummarizedExperiment have column names, ", + "but their order is not the same. Assays were internally ", + "reordered to be consistent with each other. ", + "To avoid unwanted behaviour it is highly recommended ", + "to have assays with the same order of colnames and rownames." + )) # reorder assay colnames before printing # Rearrange if assays has colnames and rownames @@ -106,11 +106,10 @@ select.SummarizedExperiment <- function(.data, ...) { col_data_tibble <- colData(.data) |> as_tibble(rownames = s_(.data)$name) - message( - "tidySummarizedExperiment says:", - " Key columns are missing.", - " A data frame is returned for independent data analysis." - ) + tidy_message(paste0( + "Key columns are missing. ", + "A data frame is returned for independent data analysis." + )) return( col_data_tibble |> dplyr::select(tidyselect::eval_select(rlang::expr(c(...)), col_data_tibble)) |> @@ -121,9 +120,10 @@ select.SummarizedExperiment <- function(.data, ...) { row_data_tibble <- rowData(.data) |> as_tibble(rownames=f_(.data)$name) - message("tidySummarizedExperiment says:", - " Key columns are missing.", - " A data frame is returned for independent data analysis.") + tidy_message(paste0( + "Key columns are missing. ", + "A data frame is returned for independent data analysis." + )) return( row_data_tibble |> dplyr::select(tidyselect::eval_select(rlang::expr(c(...)), row_data_tibble)) |> @@ -184,15 +184,17 @@ select.SummarizedExperiment <- function(.data, ...) { # convert to tibble and delegate selection to dplyr if (!all(c(get_needed_columns(.data)) %in% scope_report$selected_columns)) { if (ncol(.data)>100) { - message("tidySummarizedExperiment says:", - " You are doing a complex selection both sample-wise", - " and feature-wise. In the latter case, for efficiency", - " (until further development), it is better to separate", - " your selects sample-wise OR feature-wise.") + tidy_message( + paste0( + "You are doing a complex selection both sample-wise ", + "and feature-wise. In the latter case, for efficiency ", + "(until further development), it is better to separate ", + "your selects sample-wise OR feature-wise." + ), + type = "warning" + ) } - message("tidySummarizedExperiment says:", - " Key columns are missing.", - " A data frame is returned for independent data analysis.") + tidy_message(data_frame_returned_message) .data |> as_tibble(skip_GRanges=TRUE) |> diff --git a/R/tidyr_methods.R b/R/tidyr_methods.R index d23b7d9..daeb588 100755 --- a/R/tidyr_methods.R +++ b/R/tidyr_methods.R @@ -81,10 +81,11 @@ unnest_summarized_experiment <- function(data, cols, ..., # If both nested by transcript and sample if (s_(se)$name %in% colnames(data) & f_(se)$name %in% colnames(data) ) { - stop("tidySummarizedExperiment says:", - " for the moment nesting both by sample- and feature-wise", - " information is not possible. Please ask this feature", - " to github/stemangiola/tidySummarizedExperiment") + tidy_stop(paste0( + "for the moment nesting both by sample- and feature-wise ", + "information is not possible. Please ask this feature ", + "to github/stemangiola/tidySummarizedExperiment") + ) } # If both nested not by transcript nor sample @@ -119,9 +120,7 @@ unnest_summarized_experiment <- function(data, cols, ..., # Drop if SE is null if (data |> filter(map_lgl(!!cols, is.null)) |> nrow() > 0) { - warning("tidySummarizedcExperiment says:", - " some SummarizedExperiment objects to", - " unnest were , and were elminated") + tidy_warning("some SummarizedExperiment objects to unnest were , and were eliminated") data <- data |> filter(!map_lgl(!!cols, is.null)) } @@ -173,12 +172,11 @@ unnest_summarized_experiment <- function(data, cols, ..., } # If neither there is something wrong else { - stop("tidySummarizedcExperiment says: not the sample names", - " nor the feature names overlap through your nesting.", - " The nesting (due to the underlying", - " SummarizedExperiment::cbind and", - " SummarizedExperiment::rbind requirements)", - " needs to be rectangular.)") + tidy_stop(paste0( + "not the sample names nor the feature names overlap through your nesting. ", + "The nesting (due to the underlying SummarizedExperiment::cbind and ", + "SummarizedExperiment::rbind requirements) needs to be rectangular." + )) } } @@ -236,7 +234,7 @@ nest.SummarizedExperiment <- function(.data, ..., .names_sep=NULL) { # we have to add them, otherwise the nesting and a nesting will get confused with # the link between Sample wise, columns, and Sample IDs if(rownames(.data) |> is.null() | colnames(.data) |> is.null() ) - warning("tidySummarizedExperiment says: the nesting and unnesting operations require row names and column names to avoid side-effects. Therefore, doors will be added as \"1\", \"2\", \"3\".") + tidy_warning("the nesting and unnesting operations require row names and column names to avoid side-effects. Therefore, doors will be added as \"1\", \"2\", \"3\".") if(rownames(.data) |> is.null() ) rownames(.data) = .data |> nrow() |> seq_len() |> as.character() if(colnames(.data) |> is.null() ) colnames(.data) = .data |> ncol() |> seq_len() |> as.character() @@ -270,11 +268,12 @@ nest.SummarizedExperiment <- function(.data, ..., .names_sep=NULL) { # Check that other column are there length(colnames(my_test_nest)) > 2 ) { - stop("tidySummarizedExperiment says:", - " You cannot have the columns feature among the nesting", - " mixed with other nesting for efficiency reasons.", - " Please consider to convert to_tibble() first.", - " We are working for optimising a generalised solution of nest().") + tidy_stop(paste0( + "You cannot have the columns feature among the nesting ", + "mixed with other nesting for efficiency reasons. ", + "Please consider to convert to_tibble() first. ", + "We are working for optimising a generalised solution of nest()." + )) } # If I nest only for .feature -> THIS WORKS ONLY WITH THE CHECK ABOVE @@ -391,14 +390,13 @@ extract.SummarizedExperiment <- function(data, col, if (tst) { columns <- special_columns |> paste(collapse=", ") - stop( - "tidySummarizedExperiment says:", - " you are trying to rename a column that is view only", + tidy_stop(paste0( + "you are trying to rename a column that is view only ", columns, - "(it is not present in the colData).", - " If you want to mutate a view-only column,", - " make a copy and mutate that one." - ) + " (it is not present in the colData). ", + "If you want to mutate a view-only column, ", + "make a copy and mutate that one." + )) } # Subset column annotation @@ -463,6 +461,7 @@ extract.SummarizedExperiment <- function(data, col, #' names_to="name", values_to="value") #' #' @importFrom tidyr pivot_longer +#' @importFrom tidyprint tidy_message #' @references #' Hutchison, W.J., Keyes, T.J., The tidyomics Consortium. et al. The tidyomics ecosystem: enhancing omic data analyses. Nat Methods 21, 1166–1170 (2024). https://doi.org/10.1038/s41592-024-02299-2 #' @@ -477,7 +476,7 @@ pivot_longer.SummarizedExperiment <- function(data, cols <- enquo(cols) - message(data_frame_returned_message) + tidy_message(data_frame_returned_message) # Deprecation of special column names if(is_sample_feature_deprecated_used( @@ -526,7 +525,7 @@ pivot_wider.SummarizedExperiment <- function(data, name <- enquo(names_from) value <- enquo(values_from) - message(data_frame_returned_message) + tidy_message(data_frame_returned_message) # Deprecation of special column names if (is_sample_feature_deprecated_used( @@ -598,14 +597,13 @@ unite.SummarizedExperiment <- function(data, col, ..., if (tst) { columns <- special_columns |> paste(collapse=", ") - stop( - "tidySummarizedExperiment says:", - " you are trying to rename a column that is view only", + tidy_stop(paste0( + "you are trying to rename a column that is view only ", columns, - "(it is not present in the colData).", - " If you want to mutate a view-only column,", - " make a copy and mutate that one." - ) + " (it is not present in the colData). ", + "If you want to mutate a view-only column, ", + "make a copy and mutate that one." + )) } columns_to_unite <- data[1,1] %>% select(...) %>% colnames() @@ -704,14 +702,13 @@ separate.SummarizedExperiment <- function(data, col, if (tst) { columns <- special_columns |> paste(collapse=", ") - stop( - "tidySummarizedExperiment says:", - " you are trying to rename a column that is view only", + tidy_stop(paste0( + "you are trying to rename a column that is view only ", columns, - "(it is not present in the colData).", - " If you want to mutate a view-only column,", - " make a copy and mutate that one." - ) + " (it is not present in the colData). ", + "If you want to mutate a view-only column, ", + "make a copy and mutate that one." + )) } diff --git a/R/utilities.R b/R/utilities.R index 62f497a..42c711a 100755 --- a/R/utilities.R +++ b/R/utilities.R @@ -67,7 +67,7 @@ as_matrix <- function(tbl, pull(class) %>% unique() %>% `%in%`(c("numeric", "integer")) %>% not() %>% any()) { - warning("tidybulk says: there are NON-numerical columns, the matrix will NOT be numerical") + tidy_warning("there are NON-numerical columns, the matrix will NOT be numerical") } out <- tbl %>% as.data.frame() if (!quo_is_null(rownames)) { @@ -193,14 +193,13 @@ get_abundance_sc_wide <- function(.data, transcripts = NULL, all = FALSE) { is.null(transcripts) && !all ) { - stop(" - Your object does not contain variable feature labels, - feature argument is empty and all arguments are set to FALSE. - Either: - 1. use detect_variable_features() to select variable feature - 2. pass an array of feature names - 3. set all=TRUE (this will output a very large object, does your computer have enough RAM?) - ") + tidy_stop(paste0( + "Your object does not contain variable feature labels, ", + "feature argument is empty and all arguments are set to FALSE. ", + "Either: 1. use detect_variable_features() to select variable feature, ", + "2. pass an array of feature names, ", + "3. set all=TRUE (this will output a very large object, does your computer have enough RAM?)" + )) } # Get variable features if existing @@ -221,7 +220,7 @@ get_abundance_sc_wide <- function(.data, transcripts = NULL, all = FALSE) { } else if (!is.null(transcripts)) { mat[transcripts, , drop = FALSE] } else { - stop("It is not convenient to extract all genes, you should have either variable features or feature list to extract") + tidy_stop("It is not convenient to extract all genes, you should have either variable features or feature list to extract") } mat %>% as.matrix() %>% @@ -263,14 +262,13 @@ get_abundance_sc_long <- function(.data, transcripts = NULL, all = FALSE, is.null(transcripts) && !all ) { - stop(" - Your object does not contain variable feature labels, - feature argument is empty and all arguments are set to FALSE. - Either: - 1. use detect_variable_features() to select variable feature - 2. pass an array of feature names - 3. set all=TRUE (this will output a very large object, does your computer have enough RAM?) - ") + tidy_stop(paste0( + "Your object does not contain variable feature labels, ", + "feature argument is empty and all arguments are set to FALSE. ", + "Either: 1. use detect_variable_features() to select variable feature, ", + "2. pass an array of feature names, ", + "3. set all=TRUE (this will output a very large object, does your computer have enough RAM?)" + )) } @@ -303,7 +301,7 @@ get_abundance_sc_long <- function(.data, transcripts = NULL, all = FALSE, } else if (all) { .x } else { - stop("It is not convenient to extract all genes, you should have either variable features or feature list to extract") + tidy_stop("It is not convenient to extract all genes, you should have either variable features or feature list to extract") } if (exclude_zeros) { .x_sub[.x_sub == 0] <- NA @@ -460,7 +458,7 @@ slice_optimised <- function(.data, ..., .by = NULL, .preserve = FALSE) { slice_args <- list(...) if (is_range_slice_ungrouped_detected(.data, slice_args, .by)) { # For range slices on ungrouped data, throw an error with a helpful message - stop("tidySummarizedExperiment says: slice using a range doesn't work on ungrouped data. Please use .by parameter or convert to tibble with as_tibble() before using slice with ranges.") + tidy_stop("slice using a range doesn't work on ungrouped data. Please use .by parameter or convert to tibble with as_tibble() before using slice with ranges.") } @@ -581,10 +579,10 @@ check_se_dimnames <- function(se) { ) if (any(cn)) { idx <- which(cn)[1] - warning( - "tidySummarizedExperiment says: the assays in your SummarizedExperiment have column names, but the SummarizedExperiment does not. Setting colnames(se) to column names of first assay with column names (assay ", - idx, ")." - ) + tidy_warning(paste0( + "the assays in your SummarizedExperiment have column names, but the SummarizedExperiment does not. ", + "Setting colnames(se) to column names of first assay with column names (assay ", idx, ")." + )) colnames(se) <- colnames(assays(se, withDimnames = FALSE)[[idx]]) } } @@ -596,22 +594,22 @@ check_se_dimnames <- function(se) { ) if (any(rn)) { idx <- which(rn)[1] - warning( - "tidySummarizedExperiment says: the assays in your SummarizedExperiment have row names, but the SummarizedExperiment does not. Setting rownames(se) to row names of first assay with row names (assay ", - idx, ")." - ) + tidy_warning(paste0( + "the assays in your SummarizedExperiment have row names, but the SummarizedExperiment does not. ", + "Setting rownames(se) to row names of first assay with row names (assay ", idx, ")." + )) rownames(se) <- rownames(assays(se, withDimnames = FALSE)[[idx]]) } } # Repair duplicated dimnames (common after base::cbind()/rbind()). if (!is.null(colnames(se)) && any(duplicated(colnames(se)))) { - warning("tidySummarizedExperiment says: some column names are duplicated; making them unique.") + tidy_warning("some column names are duplicated; making them unique.") unique_colnames <- make.unique(colnames(se), sep = "_") colnames(se) <- unique_colnames } if (!is.null(rownames(se)) && any(duplicated(rownames(se)))) { - warning("tidySummarizedExperiment says: some row names are duplicated; making them unique.") + tidy_warning("some row names are duplicated; making them unique.") unique_rownames <- make.unique(rownames(se), sep = "_") rownames(se) <- unique_rownames } @@ -619,14 +617,14 @@ check_se_dimnames <- function(se) { # Warn if column names of assays do not overlap, or if some assays have # column names and others don't if (check_if_assays_are_NOT_overlapped(se, dim = "cols")) { - warning( - "tidySummarizedExperiment says: at least one of the assays in your SummarizedExperiment have column names, but they don't completely overlap between assays. It is strongly recommended to make the assays consistent, to avoid erroneous matching of samples." + tidy_warning( + "at least one of the assays in your SummarizedExperiment have column names, but they don't completely overlap between assays. It is strongly recommended to make the assays consistent, to avoid erroneous matching of samples." ) } # Same for row names if (check_if_assays_are_NOT_overlapped(se, dim = "rows")) { - warning( - "tidySummarizedExperiment says: at least one of the assays in your SummarizedExperiment have row names, but they don't completely overlap between assays. It is strongly recommended to make the assays consistent, to avoid erroneous matching of features." + tidy_warning( + "at least one of the assays in your SummarizedExperiment have row names, but they don't completely overlap between assays. It is strongly recommended to make the assays consistent, to avoid erroneous matching of features." ) } @@ -636,16 +634,16 @@ check_se_dimnames <- function(se) { length(assays(se)) > 0 && !is.null(colnames(assays(se, withDimnames = FALSE)[[1]])) && !all(colnames(assays(se, withDimnames = FALSE)[[1]]) %in% colnames(se))) { - warning( - "tidySummarizedExperiment says: the assays in your SummarizedExperiment have column names, but they don't agree with the column names of the SummarizedExperiment object itself. It is strongly recommended to make the assays consistent, to avoid erroneous matching of samples." + tidy_warning( + "the assays in your SummarizedExperiment have column names, but they don't agree with the column names of the SummarizedExperiment object itself. It is strongly recommended to make the assays consistent, to avoid erroneous matching of samples." ) } if (!is.null(rownames(se)) && length(assays(se)) > 0 && !is.null(rownames(assays(se, withDimnames = FALSE)[[1]])) && !all(rownames(assays(se, withDimnames = FALSE)[[1]]) %in% rownames(se))) { - warning( - "tidySummarizedExperiment says: the assays in your SummarizedExperiment have row names, but they don't agree with the row names of the SummarizedExperiment object itself. It is strongly recommended to make the assays consistent, to avoid erroneous matching of features." + tidy_warning( + "the assays in your SummarizedExperiment have row names, but they don't agree with the row names of the SummarizedExperiment object itself. It is strongly recommended to make the assays consistent, to avoid erroneous matching of features." ) } @@ -1043,7 +1041,7 @@ is_sample_feature_deprecated_used <- function(.data, user_columns, use_old_speci old_standard_is_used <- old_standard_is_used_for_sample | old_standard_is_used_for_feature if (old_standard_is_used) { - warning("tidySummarizedExperiment says: from version 1.3.1, the special columns including sample/feature id (colnames(se), rownames(se)) has changed to \".sample\" and \".feature\". This dataset is returned with the old-style vocabulary (feature and sample), however we suggest to update your workflow to reflect the new vocabulary (.feature, .sample)") + tidy_warning("from version 1.3.1, the special columns including sample/feature id (colnames(se), rownames(se)) has changed to \".sample\" and \".feature\". This dataset is returned with the old-style vocabulary (feature and sample), however we suggest to update your workflow to reflect the new vocabulary (.feature, .sample)") use_old_special_names <- TRUE } @@ -1051,8 +1049,28 @@ is_sample_feature_deprecated_used <- function(.data, user_columns, use_old_speci use_old_special_names } -data_frame_returned_message <- "tidySummarizedExperiment says: A data frame is returned for independent data analysis." -duplicated_cell_names <- "tidySummarizedExperiment says: This operation lead to duplicated feature names. A data frame is returned for independent data analysis." +data_frame_returned_message <- "A data frame is returned for independent data analysis." +duplicated_cell_names <- "This operation lead to duplicated feature names. A data frame is returned for independent data analysis." + +#' Format message with package prefix (tidyprint-style) +#' @keywords internal +tidy_format_message <- function(message) { + calling_package <- utils::packageName(parent.frame(n = 2)) + prefix <- if (is.null(calling_package)) "Console" else calling_package + paste0(prefix, " says: ", message) +} + +#' Emit a warning with tidyprint-style package prefix +#' @keywords internal +tidy_warning <- function(message) { + warning(tidy_format_message(message), call. = FALSE) +} + +#' Emit an error with tidyprint-style package prefix +#' @keywords internal +tidy_stop <- function(message) { + stop(tidy_format_message(message), call. = FALSE) +} # Key column names #' @importFrom S4Vectors metadata @@ -1189,7 +1207,7 @@ s_ <- function(x) { split_SummarizedExperiment_by_feature_to_list <- function(.data) { if (nrow(.data) > 1000) - message("tidySummarizedExperiment says: grouping a SummarizedExperiment by feature takes 1 minute for ~ 10,000 features.") + tidyprint::tidy_message("Grouping a SummarizedExperiment by feature takes 1 minute for ~ 10,000 features.", type = "warning") map(1:nrow(.data), ~ .data[.x,]) } From ca22843c0c2514f054e79bbdf4f1ec73f06bae21 Mon Sep 17 00:00:00 2001 From: Stefano Mangiola Date: Thu, 12 Mar 2026 13:51:44 +1030 Subject: [PATCH 03/21] Add tidy print functionality for SummarizedExperiment This commit introduces three new functions: tidy_print_on, tidy_print_off, and tidy_print_enabled, which allow users to enable or disable tidy printing for SummarizedExperiment objects. The NAMESPACE and documentation have been updated accordingly. Additionally, the tidy_warning and tidy_stop functions have been modified to utilize tidyprint for consistent message formatting. --- NAMESPACE | 6 ++++++ R/tidy_print.R | 43 +++++++++++++++++++++++++++++++++++++++++++ R/utilities.R | 20 -------------------- R/zzz.R | 10 ++++------ man/tidy_print.Rd | 31 +++++++++++++++++++++++++++++++ 5 files changed, 84 insertions(+), 26 deletions(-) create mode 100644 R/tidy_print.R create mode 100644 man/tidy_print.Rd diff --git a/NAMESPACE b/NAMESPACE index 76bbe65..bc9256f 100755 --- a/NAMESPACE +++ b/NAMESPACE @@ -39,6 +39,9 @@ S3method(unnest,tidySummarizedExperiment_nested) export("%>%") export(subset_feature_data) export(subset_sample_data) +export(tidy_print_enabled) +export(tidy_print_off) +export(tidy_print_on) export(unnest_summarized_experiment) exportMethods(subset_feature_data) exportMethods(subset_sample_data) @@ -125,6 +128,9 @@ importFrom(tibble,enframe) importFrom(tibble,rowid_to_column) importFrom(tibble,tibble) importFrom(tidyprint,tidy_message) +importFrom(tidyprint,tidy_print_enabled) +importFrom(tidyprint,tidy_print_off) +importFrom(tidyprint,tidy_print_on) importFrom(tidyr,extract) importFrom(tidyr,gather) importFrom(tidyr,nest) diff --git a/R/tidy_print.R b/R/tidy_print.R new file mode 100644 index 0000000..4db84d6 --- /dev/null +++ b/R/tidy_print.R @@ -0,0 +1,43 @@ +#' Enable or disable tidy print for SummarizedExperiment +#' +#' Re-exports from \pkg{tidyprint} for convenience. When tidy print is enabled, +#' SummarizedExperiment objects display in a compact tibble-style format. +#' +#' @importFrom tidyprint tidy_print_on tidy_print_off tidy_print_enabled +#' +#' @param remember If \code{TRUE}, saves the setting to a cache file so it +#' persists across R sessions. If \code{FALSE} (default), the setting only +#' affects the current session. +#' +#' @return \code{tidy_print_on()} and \code{tidy_print_off()} return \code{TRUE} +#' or \code{FALSE} invisibly. \code{tidy_print_enabled()} returns a logical. +#' +#' @seealso \code{\link[tidyprint:tidy_print_toggle]{tidyprint::tidy_print_on}} +#' +#' @name tidy_print +#' @export +tidy_print_on <- tidyprint::tidy_print_on + +#' @rdname tidy_print +#' @export +tidy_print_off <- tidyprint::tidy_print_off + +#' @rdname tidy_print +#' @export +tidy_print_enabled <- tidyprint::tidy_print_enabled + +#' Emit a warning with tidyprint-style display +#' @keywords internal +#' @noRd +tidy_warning <- function(message) { + tidyprint::tidy_message(message, type = "warning") + warning(message, call. = FALSE) +} + +#' Emit an error with tidyprint-style display +#' @keywords internal +#' @noRd +tidy_stop <- function(message) { + tidyprint::tidy_message(message, type = "danger") + stop(message, call. = FALSE) +} \ No newline at end of file diff --git a/R/utilities.R b/R/utilities.R index 42c711a..6bc56d8 100755 --- a/R/utilities.R +++ b/R/utilities.R @@ -1052,26 +1052,6 @@ is_sample_feature_deprecated_used <- function(.data, user_columns, use_old_speci data_frame_returned_message <- "A data frame is returned for independent data analysis." duplicated_cell_names <- "This operation lead to duplicated feature names. A data frame is returned for independent data analysis." -#' Format message with package prefix (tidyprint-style) -#' @keywords internal -tidy_format_message <- function(message) { - calling_package <- utils::packageName(parent.frame(n = 2)) - prefix <- if (is.null(calling_package)) "Console" else calling_package - paste0(prefix, " says: ", message) -} - -#' Emit a warning with tidyprint-style package prefix -#' @keywords internal -tidy_warning <- function(message) { - warning(tidy_format_message(message), call. = FALSE) -} - -#' Emit an error with tidyprint-style package prefix -#' @keywords internal -tidy_stop <- function(message) { - stop(tidy_format_message(message), call. = FALSE) -} - # Key column names #' @importFrom S4Vectors metadata #' @importFrom S4Vectors metadata<- diff --git a/R/zzz.R b/R/zzz.R index 1d86e93..19c05b3 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -55,10 +55,8 @@ .onAttach <- function(libname, pkgname) { attached <- tidyverse_attach() - # Print loading message about printing - cli::cli_alert_info(paste0( - "tidySummarizedExperiment says: The tidy printing is now handled externally.\n", - "If you want to visualize the data in a tidy way, do `library(tidyprint)`.\n", - "See `https://github.com/tidyomics/tidyprint` for more information." - )) + tidyprint::tidy_message( + "By default SummarizedExperiment uses the standard display. For a tidy tibble-style display, run tidy_print_on(remember = TRUE).", + type = "info" + ) } diff --git a/man/tidy_print.Rd b/man/tidy_print.Rd new file mode 100644 index 0000000..50abafa --- /dev/null +++ b/man/tidy_print.Rd @@ -0,0 +1,31 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/tidy_print.R +\name{tidy_print} +\alias{tidy_print} +\alias{tidy_print_on} +\alias{tidy_print_off} +\alias{tidy_print_enabled} +\title{Enable or disable tidy print for SummarizedExperiment} +\usage{ +tidy_print_on(remember = FALSE) + +tidy_print_off(remember = FALSE) + +tidy_print_enabled() +} +\arguments{ +\item{remember}{If \code{TRUE}, saves the setting to a cache file so it +persists across R sessions. If \code{FALSE} (default), the setting only +affects the current session.} +} +\value{ +\code{tidy_print_on()} and \code{tidy_print_off()} return \code{TRUE} +or \code{FALSE} invisibly. \code{tidy_print_enabled()} returns a logical. +} +\description{ +Re-exports from \pkg{tidyprint} for convenience. When tidy print is enabled, +SummarizedExperiment objects display in a compact tibble-style format. +} +\seealso{ +\code{\link[tidyprint:tidy_print_toggle]{tidyprint::tidy_print_on}} +} From de3e4045ced7f0b3842e01450f1a0aba03071c29 Mon Sep 17 00:00:00 2001 From: Stefano Mangiola Date: Thu, 12 Mar 2026 14:27:19 +1030 Subject: [PATCH 04/21] Add tidy_print_off to vignette to prevent display issues with pasilla dataset --- vignettes/introduction.Rmd | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vignettes/introduction.Rmd b/vignettes/introduction.Rmd index 17e5337..e9cce2e 100755 --- a/vignettes/introduction.Rmd +++ b/vignettes/introduction.Rmd @@ -87,6 +87,11 @@ library(dplyr) library(tidySummarizedExperiment) ``` +```{r, echo=FALSE} +# Use standard print in vignette to avoid tidyprint display bug with pasilla (7 cols) +tidy_print_off() +``` + # Create `tidySummarizedExperiment`, the best of both worlds! From 7d0f133f64e7f06450c50551559ff7ba7b82de1e Mon Sep 17 00:00:00 2001 From: Stefano Mangiola Date: Fri, 13 Mar 2026 17:05:47 +1030 Subject: [PATCH 05/21] Enhance introduction vignette with tidyomics context and detailed tidy print options. Update GitHub installation link and add new references for the tidyomics ecosystem. --- vignettes/introduction.Rmd | 46 +++++++++++++++++++++++--- vignettes/tidySummarizedExperiment.bib | 12 +++++++ 2 files changed, 54 insertions(+), 4 deletions(-) diff --git a/vignettes/introduction.Rmd b/vignettes/introduction.Rmd index e9cce2e..f3661cd 100755 --- a/vignettes/introduction.Rmd +++ b/vignettes/introduction.Rmd @@ -43,7 +43,7 @@ knitr::opts_chunk$set(warning=FALSE, message=FALSE) # Introduction -tidySummarizedExperiment provides a bridge between Bioconductor [SummarizedExperiment](https://bioconductor.org/packages/release/bioc/html/SummarizedExperiment.html) [@morgan2020summarized] and the tidyverse [@wickham2019welcome]. It creates an invisible layer that enables viewing the +tidySummarizedExperiment provides a bridge between Bioconductor [SummarizedExperiment](https://bioconductor.org/packages/release/bioc/html/SummarizedExperiment.html) [@morgan2020summarized] and the tidyverse [@wickham2019welcome] as part of the tidyomics ecosystem [@hutchison2024tidyomics]. It creates an invisible layer that enables viewing the Bioconductor *SummarizedExperiment* object as a tidyverse tibble, and provides SummarizedExperiment-compatible *dplyr*, *tidyr*, *ggplot* and *plotly* functions. This allows users to get the best of both Bioconductor and tidyverse worlds. @@ -76,7 +76,7 @@ BiocManager::install("tidySummarizedExperiment") From Github (development) ```{r, eval=FALSE} -remotes::install_github("stemangiola/tidySummarizedExperiment") +remotes::install_github("tidyomics/tidySummarizedExperiment") ``` Load libraries used in the examples. @@ -88,12 +88,49 @@ library(tidySummarizedExperiment) ``` ```{r, echo=FALSE} -# Use standard print in vignette to avoid tidyprint display bug with pasilla (7 cols) +# Use standard print for initial examples tidy_print_off() ``` -# Create `tidySummarizedExperiment`, the best of both worlds! +# Opting In and Out of Tidy Print + +By default, the standard SummarizedExperiment print format is used. You can opt in to use the tidy tibble-style display, and opt out at any time. The setting can be configured for the current R session only, or saved to persist across sessions. + +**Opt In to Tidy Print** + +To enable the tidy print format, use `tidy_print_on()`. By default, this only affects the current R session: + +```{r, eval=FALSE} +# Enable tidy print for current session only +tidy_print_on() +pasilla_tidy # Will display with tidy tibble-style format +``` + +If you want the setting to persist across R sessions, use `remember = TRUE`: + +```{r, eval=FALSE} +# Enable tidy print and remember the setting +tidy_print_on(remember = TRUE) +``` + +**Opt Out of Tidy Print** + +To return to the standard SummarizedExperiment print format, use `tidy_print_off()`. By default, this only affects the current session: + +```{r, eval=FALSE} +# Disable tidy print for current session only +tidy_print_off() +``` + +To permanently disable tidy print and clear any saved preference: + +```{r, eval=FALSE} +tidy_print_off(remember = TRUE) +``` + + +# `tidySummarizedExperiment`, the best of two worlds! This is a SummarizedExperiment object but it is evaluated as a tibble. So it is fully compatible both with SummarizedExperiment and tidyverse APIs. @@ -104,6 +141,7 @@ pasilla_tidy <- tidySummarizedExperiment::pasilla **It looks like a tibble** ```{r} +tidy_print_on() pasilla_tidy ``` diff --git a/vignettes/tidySummarizedExperiment.bib b/vignettes/tidySummarizedExperiment.bib index 9398c69..3fdd2c0 100644 --- a/vignettes/tidySummarizedExperiment.bib +++ b/vignettes/tidySummarizedExperiment.bib @@ -14,3 +14,15 @@ @article{wickham2019welcome pages={1686}, year={2019} } + +@article{hutchison2024tidyomics, + title={The tidyomics ecosystem: enhancing omic data analyses}, + author={Hutchison, William J and Keyes, Timothy J and The tidyomics Consortium and others}, + journal={Nature Methods}, + volume={21}, + number={8}, + pages={1166--1170}, + year={2024}, + publisher={Nature Publishing Group}, + doi={10.1038/s41592-024-02299-2} +} From 0335cabae7f83a928b7d78177a229e5f1fb726a4 Mon Sep 17 00:00:00 2001 From: Stefano Mangiola Date: Tue, 17 Mar 2026 13:51:16 +1030 Subject: [PATCH 06/21] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- R/tidyr_methods.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/tidyr_methods.R b/R/tidyr_methods.R index daeb588..7071679 100755 --- a/R/tidyr_methods.R +++ b/R/tidyr_methods.R @@ -234,7 +234,7 @@ nest.SummarizedExperiment <- function(.data, ..., .names_sep=NULL) { # we have to add them, otherwise the nesting and a nesting will get confused with # the link between Sample wise, columns, and Sample IDs if(rownames(.data) |> is.null() | colnames(.data) |> is.null() ) - tidy_warning("the nesting and unnesting operations require row names and column names to avoid side-effects. Therefore, doors will be added as \"1\", \"2\", \"3\".") + tidy_warning("the nesting and unnesting operations require row names and column names to avoid side-effects. Therefore, default row and column names \"1\", \"2\", \"3\", ... will be added.") if(rownames(.data) |> is.null() ) rownames(.data) = .data |> nrow() |> seq_len() |> as.character() if(colnames(.data) |> is.null() ) colnames(.data) = .data |> ncol() |> seq_len() |> as.character() From f82f4bc7cc6824b3112d7167d5f9f99fe6c87596 Mon Sep 17 00:00:00 2001 From: Stefano Mangiola Date: Tue, 17 Mar 2026 13:51:25 +1030 Subject: [PATCH 07/21] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- R/tidyr_methods.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/tidyr_methods.R b/R/tidyr_methods.R index 7071679..af72006 100755 --- a/R/tidyr_methods.R +++ b/R/tidyr_methods.R @@ -84,7 +84,7 @@ unnest_summarized_experiment <- function(data, cols, ..., tidy_stop(paste0( "for the moment nesting both by sample- and feature-wise ", "information is not possible. Please ask this feature ", - "to github/stemangiola/tidySummarizedExperiment") + "to github/tidyomics/tidySummarizedExperiment") ) } From 4d71d40779796ceceffbaca036f9e3b7c71de129 Mon Sep 17 00:00:00 2001 From: Stefano Mangiola Date: Tue, 17 Mar 2026 13:51:59 +1030 Subject: [PATCH 08/21] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- R/utilities.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/utilities.R b/R/utilities.R index 6bc56d8..9e2ec99 100755 --- a/R/utilities.R +++ b/R/utilities.R @@ -1050,7 +1050,7 @@ is_sample_feature_deprecated_used <- function(.data, user_columns, use_old_speci } data_frame_returned_message <- "A data frame is returned for independent data analysis." -duplicated_cell_names <- "This operation lead to duplicated feature names. A data frame is returned for independent data analysis." +duplicated_cell_names <- "This operation led to duplicated feature names. A data frame is returned for independent data analysis." # Key column names #' @importFrom S4Vectors metadata From e05294334cbcb40e807753530ba4b091418478d8 Mon Sep 17 00:00:00 2001 From: Stefano Mangiola Date: Tue, 17 Mar 2026 13:52:51 +1030 Subject: [PATCH 09/21] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- DESCRIPTION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 4690144..8368542 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -21,8 +21,8 @@ Depends: SummarizedExperiment, ttservice (>= 0.5.0) Imports: - tidyprint, - dplyr, + tidyprint, + dplyr, tibble (>= 3.0.4), magrittr, tidyr, From 8449153261ff4d843fc6f5f9b807dfd74bbe2db8 Mon Sep 17 00:00:00 2001 From: A Wokaty Date: Tue, 28 Apr 2026 08:54:20 -0400 Subject: [PATCH 10/21] bump x.y.z version to even y prior to creation of RELEASE_3_23 branch --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 2728f4f..49c5169 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: tidySummarizedExperiment Title: Brings SummarizedExperiment to the Tidyverse -Version: 1.21.0 +Version: 1.22.0 Authors@R: c(person("Stefano", "Mangiola", email = "mangiolastefano@gmail.com", role = c("aut", "cre")) ) Author: Stefano Mangiola [aut, cre] From c35aee3b732ada0035392e24518225c4289a35a2 Mon Sep 17 00:00:00 2001 From: A Wokaty Date: Tue, 28 Apr 2026 08:54:20 -0400 Subject: [PATCH 11/21] bump x.y.z version to odd y following creation of RELEASE_3_23 branch --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 49c5169..e0c7f32 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: tidySummarizedExperiment Title: Brings SummarizedExperiment to the Tidyverse -Version: 1.22.0 +Version: 1.23.0 Authors@R: c(person("Stefano", "Mangiola", email = "mangiolastefano@gmail.com", role = c("aut", "cre")) ) Author: Stefano Mangiola [aut, cre] From 1f15a3abe12b03939cd32a6a82131195dabf96d5 Mon Sep 17 00:00:00 2001 From: Stefano Mangiola Date: Thu, 20 Aug 2026 11:37:20 +0930 Subject: [PATCH 12/21] update docs --- man/subset_feature_data-methods.Rd | 2 +- man/subset_sample_data-methods.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/man/subset_feature_data-methods.Rd b/man/subset_feature_data-methods.Rd index 3acd60b..ac1cbdb 100644 --- a/man/subset_feature_data-methods.Rd +++ b/man/subset_feature_data-methods.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/pivot.R +% Please edit documentation in R/subset_data.R \docType{methods} \name{subset_feature_data} \alias{subset_feature_data} diff --git a/man/subset_sample_data-methods.Rd b/man/subset_sample_data-methods.Rd index 6e31e72..4d7e47a 100644 --- a/man/subset_sample_data-methods.Rd +++ b/man/subset_sample_data-methods.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/pivot.R +% Please edit documentation in R/subset_data.R \docType{methods} \name{subset_sample_data} \alias{subset_sample_data} From de9e00cec08848ec70417d856189f7cc370062af Mon Sep 17 00:00:00 2001 From: Stefano Mangiola Date: Thu, 20 Aug 2026 11:39:50 +0930 Subject: [PATCH 13/21] version UP --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 0f88319..dd79d40 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: tidySummarizedExperiment Title: Brings SummarizedExperiment to the Tidyverse -Version: 1.23.0 +Version: 1.23.1 Authors@R: c(person("Stefano", "Mangiola", email = "mangiolastefano@gmail.com", role = c("aut", "cre")) ) Author: Stefano Mangiola [aut, cre] From 1cacb81d9d91f1c5ab58d4f48499b94d127882a8 Mon Sep 17 00:00:00 2001 From: Stefano Mangiola Date: Wed, 11 Mar 2026 17:54:31 +1030 Subject: [PATCH 14/21] Update version to 1.20.4, add tidyprint dependency, and replace messages with tidy_message for improved consistency in user feedback. Enhance error handling in various functions to provide clearer guidance on usage and potential issues. --- DESCRIPTION | 3 +- NAMESPACE | 1 + R/dplyr_methods.R | 36 ++++++++-------- R/filter.R | 10 +++-- R/join.R | 9 ++-- R/mutate.R | 13 +++--- R/rename.R | 20 ++++----- R/select.R | 50 ++++++++++++----------- R/tidyr_methods.R | 81 ++++++++++++++++++------------------ R/utilities.R | 102 +++++++++++++++++++++++++++------------------- 10 files changed, 172 insertions(+), 153 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index dd79d40..7476097 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: tidySummarizedExperiment Title: Brings SummarizedExperiment to the Tidyverse -Version: 1.23.1 +Version: 1.23.2 Authors@R: c(person("Stefano", "Mangiola", email = "mangiolastefano@gmail.com", role = c("aut", "cre")) ) Author: Stefano Mangiola [aut, cre] @@ -21,6 +21,7 @@ Depends: SummarizedExperiment, ttservice (>= 0.5.0) Imports: + tidyprint, dplyr, tibble (>= 3.0.4), magrittr, diff --git a/NAMESPACE b/NAMESPACE index 7d885c6..76bbe65 100755 --- a/NAMESPACE +++ b/NAMESPACE @@ -124,6 +124,7 @@ importFrom(tibble,as_tibble) importFrom(tibble,enframe) importFrom(tibble,rowid_to_column) importFrom(tibble,tibble) +importFrom(tidyprint,tidy_message) importFrom(tidyr,extract) importFrom(tidyr,gather) importFrom(tidyr,nest) diff --git a/R/dplyr_methods.R b/R/dplyr_methods.R index f72e4b7..e4c80b6 100755 --- a/R/dplyr_methods.R +++ b/R/dplyr_methods.R @@ -11,6 +11,7 @@ #' @importFrom SummarizedExperiment assays<- #' @importFrom S4Vectors SimpleList #' @importFrom ttservice bind_rows +#' @importFrom tidyprint tidy_message #' @importFrom lifecycle deprecate_warn #' @references #' Hutchison, W.J., Keyes, T.J., The tidyomics Consortium. et al. The tidyomics ecosystem: enhancing omic data analyses. Nat Methods 21, 1166–1170 (2024). https://doi.org/10.1038/s41592-024-02299-2 @@ -25,7 +26,7 @@ bind_rows.SummarizedExperiment <- function(..., .id=NULL, add.cell.ids=NULL) { tts <- flatten_if(dots_values(...), is_spliced) if (is_split_by_sample(tts) && is_split_by_transcript(tts)) { - stop("tidySummarizedExperiment says: bind_rows cannot be applied to splits both by sample- and feature-wise information") + tidy_stop("bind_rows cannot be applied to splits both by sample- and feature-wise information") } new_obj <- if (is_split_by_sample(tts)) { cbind(tts[[1]], tts[[2]]) @@ -38,8 +39,7 @@ bind_rows.SummarizedExperiment <- function(..., .id=NULL, add.cell.ids=NULL) { # If duplicated sample names if (new_obj |> colnames() |> duplicated() |> which() |> length() |> gt(0)) { - warning("tidySummarizedExperiment says:", - " you have duplicated sample names, they will be made unique.") + tidy_warning("you have duplicated sample names, they will be made unique.") } unique_colnames <- make.unique(colnames(new_obj), sep="_") @@ -91,8 +91,7 @@ append_samples.SummarizedExperiment <- function(x, ..., .id = NULL) { # If duplicated sample names if (any(duplicated(colnames(new_obj)))) { - warning("tidySummarizedExperiment says:", - " you have duplicated sample names, they will be made unique.") + tidy_warning("you have duplicated sample names, they will be made unique.") unique_colnames <- make.unique(colnames(new_obj), sep = "_") colnames(new_obj) <- unique_colnames @@ -176,7 +175,7 @@ bind_cols_internal <- function(..., .id=NULL, column_belonging=NULL) { ))) { update_SE_from_tibble(bound, tts[[1]], column_belonging = column_belonging) } else { - warning("tidySummarizedExperiment says: The new columns do not include pure sample-wise or feature-wise. A data frame is returned for independent data analysis.") + tidy_warning("The new columns do not include pure sample-wise or feature-wise. A data frame is returned for independent data analysis.") bound } } @@ -254,7 +253,7 @@ distinct.SummarizedExperiment <- function(.data, ..., .keep_all=FALSE) { #' @export group_by.SummarizedExperiment <- function(.data, ..., .add=FALSE, .drop=group_by_drop_default(.data)) { - message(data_frame_returned_message) + tidy_message(data_frame_returned_message) # Deprecation of special column names .cols <- enquos(..., .ignore_empty="all") %>% @@ -285,7 +284,7 @@ group_by.SummarizedExperiment <- function(.data, ..., #' Wickham, H., François, R., Henry, L., Müller, K., Vaughan, D. (2023). dplyr: A Grammar of Data Manipulation. R package version 2.1.4, https://CRAN.R-project.org/package=dplyr #' @export summarise.SummarizedExperiment <- function(.data, ...) { - message(data_frame_returned_message) + tidy_message(data_frame_returned_message) # Deprecation of special column names .cols <- enquos(..., .ignore_empty="all") %>% @@ -333,7 +332,7 @@ summarize.SummarizedExperiment <- summarise.SummarizedExperiment #' Wickham, H., François, R., Henry, L., Müller, K., Vaughan, D. (2023). dplyr: A Grammar of Data Manipulation. R package version 2.1.4, https://CRAN.R-project.org/package=dplyr #' @export rowwise.SummarizedExperiment <- function(data, ...) { - message(data_frame_returned_message) + tidy_message(data_frame_returned_message) data |> as_tibble() |> @@ -406,7 +405,7 @@ sample_n.SummarizedExperiment <- function(tbl, size, replace=FALSE, weight=NULL, .env=NULL, ...) { lifecycle::signal_superseded("1.0.0", "sample_n()", "slice_sample()") - message(data_frame_returned_message) + tidy_message(data_frame_returned_message) tbl |> as_tibble() |> @@ -425,7 +424,7 @@ sample_frac.SummarizedExperiment <- function(tbl, size=1, replace=FALSE, weight=NULL, .env=NULL, ...) { lifecycle::signal_superseded("1.0.0", "sample_frac()", "slice_sample()") - message(data_frame_returned_message) + tidy_message(data_frame_returned_message) tbl |> as_tibble() |> @@ -448,7 +447,7 @@ sample_frac.SummarizedExperiment <- function(tbl, size=1, replace=FALSE, #' @export count.SummarizedExperiment <- function(x, ..., wt=NULL, sort=FALSE, name=NULL, .drop=group_by_drop_default(x)) { - message(data_frame_returned_message) + tidy_message(data_frame_returned_message) # Deprecation of special column names .cols <- enquos(..., .ignore_empty="all") %>% @@ -528,14 +527,13 @@ pull.SummarizedExperiment <- function(.data, var=-1, name=NULL, ...) { # Warning if column names of assays do not overlap if (check_if_assays_are_NOT_consistently_ordered(.data)) { - warning( - "tidySummarizedExperiment says:", - " the assays in your SummarizedExperiment have column names, ", + tidy_warning(paste0( + "the assays in your SummarizedExperiment have column names, ", "but their order is not the same. Pulling assays can return ", - "data in a order you don't expect. To avoid unwanted behaviour", - " it is highly recommended to have assays with the same order", - " of colnames and rownames" - ) + "data in a order you don't expect. To avoid unwanted behaviour ", + "it is highly recommended to have assays with the same order ", + "of colnames and rownames." + )) # reorder assay colnames before printing # Rearrange if assays has colnames and rownames diff --git a/R/filter.R b/R/filter.R index 92beb20..92d353a 100644 --- a/R/filter.R +++ b/R/filter.R @@ -56,6 +56,7 @@ analyze_query_scope_filter <- function(se, ...) { #' # Learn more in ?dplyr_tidy_eval #' #' @importFrom purrr map +#' @importFrom tidyprint tidy_message #' @importFrom dplyr filter #' @references #' Hutchison, W.J., Keyes, T.J., The tidyomics Consortium. et al. The tidyomics ecosystem: enhancing omic data analyses. Nat Methods 21, 1166–1170 (2024). https://doi.org/10.1038/s41592-024-02299-2 @@ -90,10 +91,11 @@ filter.SummarizedExperiment <- function(.data, ..., .preserve=FALSE) { dplyr::filter(..., .preserve=.preserve) if (!is_rectangular(new_meta, .data)) { - message("tidySummarizedExperiment says:", - " The resulting data frame is not rectangular", - " (all genes for all samples), a tibble is returned", - " for independent data analysis.") + tidy_message(paste0( + "The resulting data frame is not rectangular ", + "(all genes for all samples), a tibble is returned ", + "for independent data analysis." + )) return(new_meta) } else { .data[ diff --git a/R/join.R b/R/join.R index 2e8d192..d218d45 100644 --- a/R/join.R +++ b/R/join.R @@ -73,14 +73,14 @@ join_efficient_for_SE <- function(x, y, by = NULL, copy = FALSE, force_tibble_route) { # If I have a big dataset - if (ncol(x) > 100) message("tidySummarizedExperiment says: if you are joining a dataframe both sample-wise and feature-wise, for efficiency (until further development), it is better to separate your joins and join datasets sample-wise OR feature-wise.") + if (ncol(x) > 100) tidyprint::tidy_message("If you are joining a dataframe both sample-wise and feature-wise, for efficiency (until further development), it is better to separate your joins and join datasets sample-wise OR feature-wise.", type = "warning") joined <- x %>% as_tibble(skip_GRanges = TRUE) %>% join_function(y, by = by, copy = copy, suffix = suffix, ...) out <- if (!is_not_duplicated(joined, x) || !is_rectangular(joined, x)) { - message(duplicated_cell_names) - message(data_frame_returned_message) + tidyprint::tidy_message(duplicated_cell_names, type = "warning") + tidyprint::tidy_message(data_frame_returned_message) joined } else { update_SE_from_tibble(joined, x) @@ -173,7 +173,7 @@ join_efficient_for_SE <- function(x, y, by = NULL, copy = FALSE, x } - else stop("tidySummarizedExperiment says: ERROR FOR DEVELOPERS: this option should not exist. In join utility.") + else tidy_stop("ERROR FOR DEVELOPERS: this option should not exist. In join utility.") } #' @name left_join @@ -190,6 +190,7 @@ join_efficient_for_SE <- function(x, y, by = NULL, copy = FALSE, #' slice(1)) #' #' @importFrom dplyr left_join +#' @importFrom tidyprint tidy_message #' @references #' Hutchison, W.J., Keyes, T.J., The tidyomics Consortium. et al. The tidyomics ecosystem: enhancing omic data analyses. Nat Methods 21, 1166–1170 (2024). https://doi.org/10.1038/s41592-024-02299-2 #' diff --git a/R/mutate.R b/R/mutate.R index 0ec6077..1b9e165 100644 --- a/R/mutate.R +++ b/R/mutate.R @@ -216,14 +216,13 @@ mutate_via_tibble <- function(.data, ...) { columns <- special_columns |> paste(collapse=", ") - stop( - "tidySummarizedExperiment says:", - " you are trying to rename a column that is view only", + tidy_stop(paste0( + "you are trying to rename a column that is view only ", columns, - "(it is not present in the colData).", - " If you want to mutate a view-only column,", - " make a copy and mutate that one." - ) + " (it is not present in the colData). ", + "If you want to mutate a view-only column, ", + "make a copy and mutate that one." + )) } # If Ranges column not in query perform fast as_tibble diff --git a/R/rename.R b/R/rename.R index 0a42569..29e1960 100644 --- a/R/rename.R +++ b/R/rename.R @@ -44,14 +44,13 @@ rename.SummarizedExperiment <- function(.data, ...) { if (any(old_names %in% special_columns)) { columns <- intersect(old_names, special_columns) |> paste(collapse=", ") - stop( - "tidySummarizedExperiment says:", - " you are trying to rename a column that is view only: ", + tidy_stop(paste0( + "you are trying to rename a column that is view only: ", columns, - " (it is not present in the colData or rowData).", - " If you want to mutate a view-only column,", - " make a copy and mutate that one." - ) + " (it is not present in the colData or rowData). ", + "If you want to mutate a view-only column, ", + "make a copy and mutate that one." + )) } # Dispatch to appropriate domain-specific function @@ -63,9 +62,10 @@ rename.SummarizedExperiment <- function(.data, ...) { return(modify_features(.data, "rename", ...)) } else { # No matching columns found - stop("tidySummarizedExperiment says:", - " the columns you are trying to rename (", + tidy_stop(paste0( + "the columns you are trying to rename (", paste(old_names, collapse=", "), - ") are not found in colData or rowData.") + ") are not found in colData or rowData." + )) } } \ No newline at end of file diff --git a/R/select.R b/R/select.R index e544ef9..93d8c23 100644 --- a/R/select.R +++ b/R/select.R @@ -62,6 +62,7 @@ analyze_query_scope_select <- function(se, ...) { #' #' @importFrom SummarizedExperiment colData #' @importFrom dplyr select +#' @importFrom tidyprint tidy_message #' @importFrom tidyselect all_of #' @importFrom tidyselect any_of #' @export @@ -82,14 +83,13 @@ select.SummarizedExperiment <- function(.data, ...) { # Warning if column names of assays do not overlap if (check_if_assays_are_NOT_consistently_ordered(.data)) { - warning( - "tidySummarizedExperiment says:", - " the assays in your SummarizedExperiment have column names,", - " but their order is not the same. Assays were internally", - " reordered to be consistent with each other.", - " To avoid unwanted behaviour it is highly reccomended", - " to have assays with the same order of colnames and rownames." - ) + tidy_warning(paste0( + "the assays in your SummarizedExperiment have column names, ", + "but their order is not the same. Assays were internally ", + "reordered to be consistent with each other. ", + "To avoid unwanted behaviour it is highly recommended ", + "to have assays with the same order of colnames and rownames." + )) # reorder assay colnames before printing # Rearrange if assays has colnames and rownames @@ -106,11 +106,10 @@ select.SummarizedExperiment <- function(.data, ...) { col_data_tibble <- colData(.data) |> as_tibble(rownames = s_(.data)$name) - message( - "tidySummarizedExperiment says:", - " Key columns are missing.", - " A data frame is returned for independent data analysis." - ) + tidy_message(paste0( + "Key columns are missing. ", + "A data frame is returned for independent data analysis." + )) return( col_data_tibble |> dplyr::select(tidyselect::eval_select(rlang::expr(c(...)), col_data_tibble)) |> @@ -121,9 +120,10 @@ select.SummarizedExperiment <- function(.data, ...) { row_data_tibble <- rowData(.data) |> as_tibble(rownames=f_(.data)$name) - message("tidySummarizedExperiment says:", - " Key columns are missing.", - " A data frame is returned for independent data analysis.") + tidy_message(paste0( + "Key columns are missing. ", + "A data frame is returned for independent data analysis." + )) return( row_data_tibble |> dplyr::select(tidyselect::eval_select(rlang::expr(c(...)), row_data_tibble)) |> @@ -184,15 +184,17 @@ select.SummarizedExperiment <- function(.data, ...) { # convert to tibble and delegate selection to dplyr if (!all(c(get_needed_columns(.data)) %in% scope_report$selected_columns)) { if (ncol(.data)>100) { - message("tidySummarizedExperiment says:", - " You are doing a complex selection both sample-wise", - " and feature-wise. In the latter case, for efficiency", - " (until further development), it is better to separate", - " your selects sample-wise OR feature-wise.") + tidy_message( + paste0( + "You are doing a complex selection both sample-wise ", + "and feature-wise. In the latter case, for efficiency ", + "(until further development), it is better to separate ", + "your selects sample-wise OR feature-wise." + ), + type = "warning" + ) } - message("tidySummarizedExperiment says:", - " Key columns are missing.", - " A data frame is returned for independent data analysis.") + tidy_message(data_frame_returned_message) .data |> as_tibble(skip_GRanges=TRUE) |> diff --git a/R/tidyr_methods.R b/R/tidyr_methods.R index d23b7d9..daeb588 100755 --- a/R/tidyr_methods.R +++ b/R/tidyr_methods.R @@ -81,10 +81,11 @@ unnest_summarized_experiment <- function(data, cols, ..., # If both nested by transcript and sample if (s_(se)$name %in% colnames(data) & f_(se)$name %in% colnames(data) ) { - stop("tidySummarizedExperiment says:", - " for the moment nesting both by sample- and feature-wise", - " information is not possible. Please ask this feature", - " to github/stemangiola/tidySummarizedExperiment") + tidy_stop(paste0( + "for the moment nesting both by sample- and feature-wise ", + "information is not possible. Please ask this feature ", + "to github/stemangiola/tidySummarizedExperiment") + ) } # If both nested not by transcript nor sample @@ -119,9 +120,7 @@ unnest_summarized_experiment <- function(data, cols, ..., # Drop if SE is null if (data |> filter(map_lgl(!!cols, is.null)) |> nrow() > 0) { - warning("tidySummarizedcExperiment says:", - " some SummarizedExperiment objects to", - " unnest were , and were elminated") + tidy_warning("some SummarizedExperiment objects to unnest were , and were eliminated") data <- data |> filter(!map_lgl(!!cols, is.null)) } @@ -173,12 +172,11 @@ unnest_summarized_experiment <- function(data, cols, ..., } # If neither there is something wrong else { - stop("tidySummarizedcExperiment says: not the sample names", - " nor the feature names overlap through your nesting.", - " The nesting (due to the underlying", - " SummarizedExperiment::cbind and", - " SummarizedExperiment::rbind requirements)", - " needs to be rectangular.)") + tidy_stop(paste0( + "not the sample names nor the feature names overlap through your nesting. ", + "The nesting (due to the underlying SummarizedExperiment::cbind and ", + "SummarizedExperiment::rbind requirements) needs to be rectangular." + )) } } @@ -236,7 +234,7 @@ nest.SummarizedExperiment <- function(.data, ..., .names_sep=NULL) { # we have to add them, otherwise the nesting and a nesting will get confused with # the link between Sample wise, columns, and Sample IDs if(rownames(.data) |> is.null() | colnames(.data) |> is.null() ) - warning("tidySummarizedExperiment says: the nesting and unnesting operations require row names and column names to avoid side-effects. Therefore, doors will be added as \"1\", \"2\", \"3\".") + tidy_warning("the nesting and unnesting operations require row names and column names to avoid side-effects. Therefore, doors will be added as \"1\", \"2\", \"3\".") if(rownames(.data) |> is.null() ) rownames(.data) = .data |> nrow() |> seq_len() |> as.character() if(colnames(.data) |> is.null() ) colnames(.data) = .data |> ncol() |> seq_len() |> as.character() @@ -270,11 +268,12 @@ nest.SummarizedExperiment <- function(.data, ..., .names_sep=NULL) { # Check that other column are there length(colnames(my_test_nest)) > 2 ) { - stop("tidySummarizedExperiment says:", - " You cannot have the columns feature among the nesting", - " mixed with other nesting for efficiency reasons.", - " Please consider to convert to_tibble() first.", - " We are working for optimising a generalised solution of nest().") + tidy_stop(paste0( + "You cannot have the columns feature among the nesting ", + "mixed with other nesting for efficiency reasons. ", + "Please consider to convert to_tibble() first. ", + "We are working for optimising a generalised solution of nest()." + )) } # If I nest only for .feature -> THIS WORKS ONLY WITH THE CHECK ABOVE @@ -391,14 +390,13 @@ extract.SummarizedExperiment <- function(data, col, if (tst) { columns <- special_columns |> paste(collapse=", ") - stop( - "tidySummarizedExperiment says:", - " you are trying to rename a column that is view only", + tidy_stop(paste0( + "you are trying to rename a column that is view only ", columns, - "(it is not present in the colData).", - " If you want to mutate a view-only column,", - " make a copy and mutate that one." - ) + " (it is not present in the colData). ", + "If you want to mutate a view-only column, ", + "make a copy and mutate that one." + )) } # Subset column annotation @@ -463,6 +461,7 @@ extract.SummarizedExperiment <- function(data, col, #' names_to="name", values_to="value") #' #' @importFrom tidyr pivot_longer +#' @importFrom tidyprint tidy_message #' @references #' Hutchison, W.J., Keyes, T.J., The tidyomics Consortium. et al. The tidyomics ecosystem: enhancing omic data analyses. Nat Methods 21, 1166–1170 (2024). https://doi.org/10.1038/s41592-024-02299-2 #' @@ -477,7 +476,7 @@ pivot_longer.SummarizedExperiment <- function(data, cols <- enquo(cols) - message(data_frame_returned_message) + tidy_message(data_frame_returned_message) # Deprecation of special column names if(is_sample_feature_deprecated_used( @@ -526,7 +525,7 @@ pivot_wider.SummarizedExperiment <- function(data, name <- enquo(names_from) value <- enquo(values_from) - message(data_frame_returned_message) + tidy_message(data_frame_returned_message) # Deprecation of special column names if (is_sample_feature_deprecated_used( @@ -598,14 +597,13 @@ unite.SummarizedExperiment <- function(data, col, ..., if (tst) { columns <- special_columns |> paste(collapse=", ") - stop( - "tidySummarizedExperiment says:", - " you are trying to rename a column that is view only", + tidy_stop(paste0( + "you are trying to rename a column that is view only ", columns, - "(it is not present in the colData).", - " If you want to mutate a view-only column,", - " make a copy and mutate that one." - ) + " (it is not present in the colData). ", + "If you want to mutate a view-only column, ", + "make a copy and mutate that one." + )) } columns_to_unite <- data[1,1] %>% select(...) %>% colnames() @@ -704,14 +702,13 @@ separate.SummarizedExperiment <- function(data, col, if (tst) { columns <- special_columns |> paste(collapse=", ") - stop( - "tidySummarizedExperiment says:", - " you are trying to rename a column that is view only", + tidy_stop(paste0( + "you are trying to rename a column that is view only ", columns, - "(it is not present in the colData).", - " If you want to mutate a view-only column,", - " make a copy and mutate that one." - ) + " (it is not present in the colData). ", + "If you want to mutate a view-only column, ", + "make a copy and mutate that one." + )) } diff --git a/R/utilities.R b/R/utilities.R index 62f497a..42c711a 100755 --- a/R/utilities.R +++ b/R/utilities.R @@ -67,7 +67,7 @@ as_matrix <- function(tbl, pull(class) %>% unique() %>% `%in%`(c("numeric", "integer")) %>% not() %>% any()) { - warning("tidybulk says: there are NON-numerical columns, the matrix will NOT be numerical") + tidy_warning("there are NON-numerical columns, the matrix will NOT be numerical") } out <- tbl %>% as.data.frame() if (!quo_is_null(rownames)) { @@ -193,14 +193,13 @@ get_abundance_sc_wide <- function(.data, transcripts = NULL, all = FALSE) { is.null(transcripts) && !all ) { - stop(" - Your object does not contain variable feature labels, - feature argument is empty and all arguments are set to FALSE. - Either: - 1. use detect_variable_features() to select variable feature - 2. pass an array of feature names - 3. set all=TRUE (this will output a very large object, does your computer have enough RAM?) - ") + tidy_stop(paste0( + "Your object does not contain variable feature labels, ", + "feature argument is empty and all arguments are set to FALSE. ", + "Either: 1. use detect_variable_features() to select variable feature, ", + "2. pass an array of feature names, ", + "3. set all=TRUE (this will output a very large object, does your computer have enough RAM?)" + )) } # Get variable features if existing @@ -221,7 +220,7 @@ get_abundance_sc_wide <- function(.data, transcripts = NULL, all = FALSE) { } else if (!is.null(transcripts)) { mat[transcripts, , drop = FALSE] } else { - stop("It is not convenient to extract all genes, you should have either variable features or feature list to extract") + tidy_stop("It is not convenient to extract all genes, you should have either variable features or feature list to extract") } mat %>% as.matrix() %>% @@ -263,14 +262,13 @@ get_abundance_sc_long <- function(.data, transcripts = NULL, all = FALSE, is.null(transcripts) && !all ) { - stop(" - Your object does not contain variable feature labels, - feature argument is empty and all arguments are set to FALSE. - Either: - 1. use detect_variable_features() to select variable feature - 2. pass an array of feature names - 3. set all=TRUE (this will output a very large object, does your computer have enough RAM?) - ") + tidy_stop(paste0( + "Your object does not contain variable feature labels, ", + "feature argument is empty and all arguments are set to FALSE. ", + "Either: 1. use detect_variable_features() to select variable feature, ", + "2. pass an array of feature names, ", + "3. set all=TRUE (this will output a very large object, does your computer have enough RAM?)" + )) } @@ -303,7 +301,7 @@ get_abundance_sc_long <- function(.data, transcripts = NULL, all = FALSE, } else if (all) { .x } else { - stop("It is not convenient to extract all genes, you should have either variable features or feature list to extract") + tidy_stop("It is not convenient to extract all genes, you should have either variable features or feature list to extract") } if (exclude_zeros) { .x_sub[.x_sub == 0] <- NA @@ -460,7 +458,7 @@ slice_optimised <- function(.data, ..., .by = NULL, .preserve = FALSE) { slice_args <- list(...) if (is_range_slice_ungrouped_detected(.data, slice_args, .by)) { # For range slices on ungrouped data, throw an error with a helpful message - stop("tidySummarizedExperiment says: slice using a range doesn't work on ungrouped data. Please use .by parameter or convert to tibble with as_tibble() before using slice with ranges.") + tidy_stop("slice using a range doesn't work on ungrouped data. Please use .by parameter or convert to tibble with as_tibble() before using slice with ranges.") } @@ -581,10 +579,10 @@ check_se_dimnames <- function(se) { ) if (any(cn)) { idx <- which(cn)[1] - warning( - "tidySummarizedExperiment says: the assays in your SummarizedExperiment have column names, but the SummarizedExperiment does not. Setting colnames(se) to column names of first assay with column names (assay ", - idx, ")." - ) + tidy_warning(paste0( + "the assays in your SummarizedExperiment have column names, but the SummarizedExperiment does not. ", + "Setting colnames(se) to column names of first assay with column names (assay ", idx, ")." + )) colnames(se) <- colnames(assays(se, withDimnames = FALSE)[[idx]]) } } @@ -596,22 +594,22 @@ check_se_dimnames <- function(se) { ) if (any(rn)) { idx <- which(rn)[1] - warning( - "tidySummarizedExperiment says: the assays in your SummarizedExperiment have row names, but the SummarizedExperiment does not. Setting rownames(se) to row names of first assay with row names (assay ", - idx, ")." - ) + tidy_warning(paste0( + "the assays in your SummarizedExperiment have row names, but the SummarizedExperiment does not. ", + "Setting rownames(se) to row names of first assay with row names (assay ", idx, ")." + )) rownames(se) <- rownames(assays(se, withDimnames = FALSE)[[idx]]) } } # Repair duplicated dimnames (common after base::cbind()/rbind()). if (!is.null(colnames(se)) && any(duplicated(colnames(se)))) { - warning("tidySummarizedExperiment says: some column names are duplicated; making them unique.") + tidy_warning("some column names are duplicated; making them unique.") unique_colnames <- make.unique(colnames(se), sep = "_") colnames(se) <- unique_colnames } if (!is.null(rownames(se)) && any(duplicated(rownames(se)))) { - warning("tidySummarizedExperiment says: some row names are duplicated; making them unique.") + tidy_warning("some row names are duplicated; making them unique.") unique_rownames <- make.unique(rownames(se), sep = "_") rownames(se) <- unique_rownames } @@ -619,14 +617,14 @@ check_se_dimnames <- function(se) { # Warn if column names of assays do not overlap, or if some assays have # column names and others don't if (check_if_assays_are_NOT_overlapped(se, dim = "cols")) { - warning( - "tidySummarizedExperiment says: at least one of the assays in your SummarizedExperiment have column names, but they don't completely overlap between assays. It is strongly recommended to make the assays consistent, to avoid erroneous matching of samples." + tidy_warning( + "at least one of the assays in your SummarizedExperiment have column names, but they don't completely overlap between assays. It is strongly recommended to make the assays consistent, to avoid erroneous matching of samples." ) } # Same for row names if (check_if_assays_are_NOT_overlapped(se, dim = "rows")) { - warning( - "tidySummarizedExperiment says: at least one of the assays in your SummarizedExperiment have row names, but they don't completely overlap between assays. It is strongly recommended to make the assays consistent, to avoid erroneous matching of features." + tidy_warning( + "at least one of the assays in your SummarizedExperiment have row names, but they don't completely overlap between assays. It is strongly recommended to make the assays consistent, to avoid erroneous matching of features." ) } @@ -636,16 +634,16 @@ check_se_dimnames <- function(se) { length(assays(se)) > 0 && !is.null(colnames(assays(se, withDimnames = FALSE)[[1]])) && !all(colnames(assays(se, withDimnames = FALSE)[[1]]) %in% colnames(se))) { - warning( - "tidySummarizedExperiment says: the assays in your SummarizedExperiment have column names, but they don't agree with the column names of the SummarizedExperiment object itself. It is strongly recommended to make the assays consistent, to avoid erroneous matching of samples." + tidy_warning( + "the assays in your SummarizedExperiment have column names, but they don't agree with the column names of the SummarizedExperiment object itself. It is strongly recommended to make the assays consistent, to avoid erroneous matching of samples." ) } if (!is.null(rownames(se)) && length(assays(se)) > 0 && !is.null(rownames(assays(se, withDimnames = FALSE)[[1]])) && !all(rownames(assays(se, withDimnames = FALSE)[[1]]) %in% rownames(se))) { - warning( - "tidySummarizedExperiment says: the assays in your SummarizedExperiment have row names, but they don't agree with the row names of the SummarizedExperiment object itself. It is strongly recommended to make the assays consistent, to avoid erroneous matching of features." + tidy_warning( + "the assays in your SummarizedExperiment have row names, but they don't agree with the row names of the SummarizedExperiment object itself. It is strongly recommended to make the assays consistent, to avoid erroneous matching of features." ) } @@ -1043,7 +1041,7 @@ is_sample_feature_deprecated_used <- function(.data, user_columns, use_old_speci old_standard_is_used <- old_standard_is_used_for_sample | old_standard_is_used_for_feature if (old_standard_is_used) { - warning("tidySummarizedExperiment says: from version 1.3.1, the special columns including sample/feature id (colnames(se), rownames(se)) has changed to \".sample\" and \".feature\". This dataset is returned with the old-style vocabulary (feature and sample), however we suggest to update your workflow to reflect the new vocabulary (.feature, .sample)") + tidy_warning("from version 1.3.1, the special columns including sample/feature id (colnames(se), rownames(se)) has changed to \".sample\" and \".feature\". This dataset is returned with the old-style vocabulary (feature and sample), however we suggest to update your workflow to reflect the new vocabulary (.feature, .sample)") use_old_special_names <- TRUE } @@ -1051,8 +1049,28 @@ is_sample_feature_deprecated_used <- function(.data, user_columns, use_old_speci use_old_special_names } -data_frame_returned_message <- "tidySummarizedExperiment says: A data frame is returned for independent data analysis." -duplicated_cell_names <- "tidySummarizedExperiment says: This operation lead to duplicated feature names. A data frame is returned for independent data analysis." +data_frame_returned_message <- "A data frame is returned for independent data analysis." +duplicated_cell_names <- "This operation lead to duplicated feature names. A data frame is returned for independent data analysis." + +#' Format message with package prefix (tidyprint-style) +#' @keywords internal +tidy_format_message <- function(message) { + calling_package <- utils::packageName(parent.frame(n = 2)) + prefix <- if (is.null(calling_package)) "Console" else calling_package + paste0(prefix, " says: ", message) +} + +#' Emit a warning with tidyprint-style package prefix +#' @keywords internal +tidy_warning <- function(message) { + warning(tidy_format_message(message), call. = FALSE) +} + +#' Emit an error with tidyprint-style package prefix +#' @keywords internal +tidy_stop <- function(message) { + stop(tidy_format_message(message), call. = FALSE) +} # Key column names #' @importFrom S4Vectors metadata @@ -1189,7 +1207,7 @@ s_ <- function(x) { split_SummarizedExperiment_by_feature_to_list <- function(.data) { if (nrow(.data) > 1000) - message("tidySummarizedExperiment says: grouping a SummarizedExperiment by feature takes 1 minute for ~ 10,000 features.") + tidyprint::tidy_message("Grouping a SummarizedExperiment by feature takes 1 minute for ~ 10,000 features.", type = "warning") map(1:nrow(.data), ~ .data[.x,]) } From d41f3cc56c91cd8a763e2151770d75576580029d Mon Sep 17 00:00:00 2001 From: Stefano Mangiola Date: Thu, 12 Mar 2026 13:51:44 +1030 Subject: [PATCH 15/21] Add tidy print functionality for SummarizedExperiment This commit introduces three new functions: tidy_print_on, tidy_print_off, and tidy_print_enabled, which allow users to enable or disable tidy printing for SummarizedExperiment objects. The NAMESPACE and documentation have been updated accordingly. Additionally, the tidy_warning and tidy_stop functions have been modified to utilize tidyprint for consistent message formatting. --- NAMESPACE | 6 ++++++ R/tidy_print.R | 43 +++++++++++++++++++++++++++++++++++++++++++ R/utilities.R | 20 -------------------- R/zzz.R | 10 ++++------ man/tidy_print.Rd | 31 +++++++++++++++++++++++++++++++ 5 files changed, 84 insertions(+), 26 deletions(-) create mode 100644 R/tidy_print.R create mode 100644 man/tidy_print.Rd diff --git a/NAMESPACE b/NAMESPACE index 76bbe65..bc9256f 100755 --- a/NAMESPACE +++ b/NAMESPACE @@ -39,6 +39,9 @@ S3method(unnest,tidySummarizedExperiment_nested) export("%>%") export(subset_feature_data) export(subset_sample_data) +export(tidy_print_enabled) +export(tidy_print_off) +export(tidy_print_on) export(unnest_summarized_experiment) exportMethods(subset_feature_data) exportMethods(subset_sample_data) @@ -125,6 +128,9 @@ importFrom(tibble,enframe) importFrom(tibble,rowid_to_column) importFrom(tibble,tibble) importFrom(tidyprint,tidy_message) +importFrom(tidyprint,tidy_print_enabled) +importFrom(tidyprint,tidy_print_off) +importFrom(tidyprint,tidy_print_on) importFrom(tidyr,extract) importFrom(tidyr,gather) importFrom(tidyr,nest) diff --git a/R/tidy_print.R b/R/tidy_print.R new file mode 100644 index 0000000..4db84d6 --- /dev/null +++ b/R/tidy_print.R @@ -0,0 +1,43 @@ +#' Enable or disable tidy print for SummarizedExperiment +#' +#' Re-exports from \pkg{tidyprint} for convenience. When tidy print is enabled, +#' SummarizedExperiment objects display in a compact tibble-style format. +#' +#' @importFrom tidyprint tidy_print_on tidy_print_off tidy_print_enabled +#' +#' @param remember If \code{TRUE}, saves the setting to a cache file so it +#' persists across R sessions. If \code{FALSE} (default), the setting only +#' affects the current session. +#' +#' @return \code{tidy_print_on()} and \code{tidy_print_off()} return \code{TRUE} +#' or \code{FALSE} invisibly. \code{tidy_print_enabled()} returns a logical. +#' +#' @seealso \code{\link[tidyprint:tidy_print_toggle]{tidyprint::tidy_print_on}} +#' +#' @name tidy_print +#' @export +tidy_print_on <- tidyprint::tidy_print_on + +#' @rdname tidy_print +#' @export +tidy_print_off <- tidyprint::tidy_print_off + +#' @rdname tidy_print +#' @export +tidy_print_enabled <- tidyprint::tidy_print_enabled + +#' Emit a warning with tidyprint-style display +#' @keywords internal +#' @noRd +tidy_warning <- function(message) { + tidyprint::tidy_message(message, type = "warning") + warning(message, call. = FALSE) +} + +#' Emit an error with tidyprint-style display +#' @keywords internal +#' @noRd +tidy_stop <- function(message) { + tidyprint::tidy_message(message, type = "danger") + stop(message, call. = FALSE) +} \ No newline at end of file diff --git a/R/utilities.R b/R/utilities.R index 42c711a..6bc56d8 100755 --- a/R/utilities.R +++ b/R/utilities.R @@ -1052,26 +1052,6 @@ is_sample_feature_deprecated_used <- function(.data, user_columns, use_old_speci data_frame_returned_message <- "A data frame is returned for independent data analysis." duplicated_cell_names <- "This operation lead to duplicated feature names. A data frame is returned for independent data analysis." -#' Format message with package prefix (tidyprint-style) -#' @keywords internal -tidy_format_message <- function(message) { - calling_package <- utils::packageName(parent.frame(n = 2)) - prefix <- if (is.null(calling_package)) "Console" else calling_package - paste0(prefix, " says: ", message) -} - -#' Emit a warning with tidyprint-style package prefix -#' @keywords internal -tidy_warning <- function(message) { - warning(tidy_format_message(message), call. = FALSE) -} - -#' Emit an error with tidyprint-style package prefix -#' @keywords internal -tidy_stop <- function(message) { - stop(tidy_format_message(message), call. = FALSE) -} - # Key column names #' @importFrom S4Vectors metadata #' @importFrom S4Vectors metadata<- diff --git a/R/zzz.R b/R/zzz.R index 1d86e93..19c05b3 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -55,10 +55,8 @@ .onAttach <- function(libname, pkgname) { attached <- tidyverse_attach() - # Print loading message about printing - cli::cli_alert_info(paste0( - "tidySummarizedExperiment says: The tidy printing is now handled externally.\n", - "If you want to visualize the data in a tidy way, do `library(tidyprint)`.\n", - "See `https://github.com/tidyomics/tidyprint` for more information." - )) + tidyprint::tidy_message( + "By default SummarizedExperiment uses the standard display. For a tidy tibble-style display, run tidy_print_on(remember = TRUE).", + type = "info" + ) } diff --git a/man/tidy_print.Rd b/man/tidy_print.Rd new file mode 100644 index 0000000..50abafa --- /dev/null +++ b/man/tidy_print.Rd @@ -0,0 +1,31 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/tidy_print.R +\name{tidy_print} +\alias{tidy_print} +\alias{tidy_print_on} +\alias{tidy_print_off} +\alias{tidy_print_enabled} +\title{Enable or disable tidy print for SummarizedExperiment} +\usage{ +tidy_print_on(remember = FALSE) + +tidy_print_off(remember = FALSE) + +tidy_print_enabled() +} +\arguments{ +\item{remember}{If \code{TRUE}, saves the setting to a cache file so it +persists across R sessions. If \code{FALSE} (default), the setting only +affects the current session.} +} +\value{ +\code{tidy_print_on()} and \code{tidy_print_off()} return \code{TRUE} +or \code{FALSE} invisibly. \code{tidy_print_enabled()} returns a logical. +} +\description{ +Re-exports from \pkg{tidyprint} for convenience. When tidy print is enabled, +SummarizedExperiment objects display in a compact tibble-style format. +} +\seealso{ +\code{\link[tidyprint:tidy_print_toggle]{tidyprint::tidy_print_on}} +} From 5dacc2a6ed7e6aea7eaf97aac149c10eae248eaf Mon Sep 17 00:00:00 2001 From: Stefano Mangiola Date: Thu, 12 Mar 2026 14:27:19 +1030 Subject: [PATCH 16/21] Add tidy_print_off to vignette to prevent display issues with pasilla dataset --- vignettes/introduction.Rmd | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vignettes/introduction.Rmd b/vignettes/introduction.Rmd index 17e5337..e9cce2e 100755 --- a/vignettes/introduction.Rmd +++ b/vignettes/introduction.Rmd @@ -87,6 +87,11 @@ library(dplyr) library(tidySummarizedExperiment) ``` +```{r, echo=FALSE} +# Use standard print in vignette to avoid tidyprint display bug with pasilla (7 cols) +tidy_print_off() +``` + # Create `tidySummarizedExperiment`, the best of both worlds! From 7956bd5558854a55acf31a45da55a10f1d8c42f9 Mon Sep 17 00:00:00 2001 From: Stefano Mangiola Date: Fri, 13 Mar 2026 17:05:47 +1030 Subject: [PATCH 17/21] Enhance introduction vignette with tidyomics context and detailed tidy print options. Update GitHub installation link and add new references for the tidyomics ecosystem. --- vignettes/introduction.Rmd | 46 +++++++++++++++++++++++--- vignettes/tidySummarizedExperiment.bib | 12 +++++++ 2 files changed, 54 insertions(+), 4 deletions(-) diff --git a/vignettes/introduction.Rmd b/vignettes/introduction.Rmd index e9cce2e..f3661cd 100755 --- a/vignettes/introduction.Rmd +++ b/vignettes/introduction.Rmd @@ -43,7 +43,7 @@ knitr::opts_chunk$set(warning=FALSE, message=FALSE) # Introduction -tidySummarizedExperiment provides a bridge between Bioconductor [SummarizedExperiment](https://bioconductor.org/packages/release/bioc/html/SummarizedExperiment.html) [@morgan2020summarized] and the tidyverse [@wickham2019welcome]. It creates an invisible layer that enables viewing the +tidySummarizedExperiment provides a bridge between Bioconductor [SummarizedExperiment](https://bioconductor.org/packages/release/bioc/html/SummarizedExperiment.html) [@morgan2020summarized] and the tidyverse [@wickham2019welcome] as part of the tidyomics ecosystem [@hutchison2024tidyomics]. It creates an invisible layer that enables viewing the Bioconductor *SummarizedExperiment* object as a tidyverse tibble, and provides SummarizedExperiment-compatible *dplyr*, *tidyr*, *ggplot* and *plotly* functions. This allows users to get the best of both Bioconductor and tidyverse worlds. @@ -76,7 +76,7 @@ BiocManager::install("tidySummarizedExperiment") From Github (development) ```{r, eval=FALSE} -remotes::install_github("stemangiola/tidySummarizedExperiment") +remotes::install_github("tidyomics/tidySummarizedExperiment") ``` Load libraries used in the examples. @@ -88,12 +88,49 @@ library(tidySummarizedExperiment) ``` ```{r, echo=FALSE} -# Use standard print in vignette to avoid tidyprint display bug with pasilla (7 cols) +# Use standard print for initial examples tidy_print_off() ``` -# Create `tidySummarizedExperiment`, the best of both worlds! +# Opting In and Out of Tidy Print + +By default, the standard SummarizedExperiment print format is used. You can opt in to use the tidy tibble-style display, and opt out at any time. The setting can be configured for the current R session only, or saved to persist across sessions. + +**Opt In to Tidy Print** + +To enable the tidy print format, use `tidy_print_on()`. By default, this only affects the current R session: + +```{r, eval=FALSE} +# Enable tidy print for current session only +tidy_print_on() +pasilla_tidy # Will display with tidy tibble-style format +``` + +If you want the setting to persist across R sessions, use `remember = TRUE`: + +```{r, eval=FALSE} +# Enable tidy print and remember the setting +tidy_print_on(remember = TRUE) +``` + +**Opt Out of Tidy Print** + +To return to the standard SummarizedExperiment print format, use `tidy_print_off()`. By default, this only affects the current session: + +```{r, eval=FALSE} +# Disable tidy print for current session only +tidy_print_off() +``` + +To permanently disable tidy print and clear any saved preference: + +```{r, eval=FALSE} +tidy_print_off(remember = TRUE) +``` + + +# `tidySummarizedExperiment`, the best of two worlds! This is a SummarizedExperiment object but it is evaluated as a tibble. So it is fully compatible both with SummarizedExperiment and tidyverse APIs. @@ -104,6 +141,7 @@ pasilla_tidy <- tidySummarizedExperiment::pasilla **It looks like a tibble** ```{r} +tidy_print_on() pasilla_tidy ``` diff --git a/vignettes/tidySummarizedExperiment.bib b/vignettes/tidySummarizedExperiment.bib index 9398c69..3fdd2c0 100644 --- a/vignettes/tidySummarizedExperiment.bib +++ b/vignettes/tidySummarizedExperiment.bib @@ -14,3 +14,15 @@ @article{wickham2019welcome pages={1686}, year={2019} } + +@article{hutchison2024tidyomics, + title={The tidyomics ecosystem: enhancing omic data analyses}, + author={Hutchison, William J and Keyes, Timothy J and The tidyomics Consortium and others}, + journal={Nature Methods}, + volume={21}, + number={8}, + pages={1166--1170}, + year={2024}, + publisher={Nature Publishing Group}, + doi={10.1038/s41592-024-02299-2} +} From 7b1f1e9a96f38641ff0c798a502982c16e86c546 Mon Sep 17 00:00:00 2001 From: Stefano Mangiola Date: Tue, 17 Mar 2026 13:51:16 +1030 Subject: [PATCH 18/21] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- R/tidyr_methods.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/tidyr_methods.R b/R/tidyr_methods.R index daeb588..7071679 100755 --- a/R/tidyr_methods.R +++ b/R/tidyr_methods.R @@ -234,7 +234,7 @@ nest.SummarizedExperiment <- function(.data, ..., .names_sep=NULL) { # we have to add them, otherwise the nesting and a nesting will get confused with # the link between Sample wise, columns, and Sample IDs if(rownames(.data) |> is.null() | colnames(.data) |> is.null() ) - tidy_warning("the nesting and unnesting operations require row names and column names to avoid side-effects. Therefore, doors will be added as \"1\", \"2\", \"3\".") + tidy_warning("the nesting and unnesting operations require row names and column names to avoid side-effects. Therefore, default row and column names \"1\", \"2\", \"3\", ... will be added.") if(rownames(.data) |> is.null() ) rownames(.data) = .data |> nrow() |> seq_len() |> as.character() if(colnames(.data) |> is.null() ) colnames(.data) = .data |> ncol() |> seq_len() |> as.character() From 06561fd11b53590d7c75cf92555bb3d447c4cd2e Mon Sep 17 00:00:00 2001 From: Stefano Mangiola Date: Tue, 17 Mar 2026 13:51:25 +1030 Subject: [PATCH 19/21] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- R/tidyr_methods.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/tidyr_methods.R b/R/tidyr_methods.R index 7071679..af72006 100755 --- a/R/tidyr_methods.R +++ b/R/tidyr_methods.R @@ -84,7 +84,7 @@ unnest_summarized_experiment <- function(data, cols, ..., tidy_stop(paste0( "for the moment nesting both by sample- and feature-wise ", "information is not possible. Please ask this feature ", - "to github/stemangiola/tidySummarizedExperiment") + "to github/tidyomics/tidySummarizedExperiment") ) } From c751d78232cf1c0b8cfdc36e72243572277e5025 Mon Sep 17 00:00:00 2001 From: Stefano Mangiola Date: Tue, 17 Mar 2026 13:51:59 +1030 Subject: [PATCH 20/21] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- R/utilities.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/utilities.R b/R/utilities.R index 6bc56d8..9e2ec99 100755 --- a/R/utilities.R +++ b/R/utilities.R @@ -1050,7 +1050,7 @@ is_sample_feature_deprecated_used <- function(.data, user_columns, use_old_speci } data_frame_returned_message <- "A data frame is returned for independent data analysis." -duplicated_cell_names <- "This operation lead to duplicated feature names. A data frame is returned for independent data analysis." +duplicated_cell_names <- "This operation led to duplicated feature names. A data frame is returned for independent data analysis." # Key column names #' @importFrom S4Vectors metadata From 4108149f95e2820075fb1eab89b7edbb6bbbd48c Mon Sep 17 00:00:00 2001 From: Stefano Mangiola Date: Tue, 17 Mar 2026 13:52:51 +1030 Subject: [PATCH 21/21] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- DESCRIPTION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 7476097..96fd8c6 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -21,8 +21,8 @@ Depends: SummarizedExperiment, ttservice (>= 0.5.0) Imports: - tidyprint, - dplyr, + tidyprint, + dplyr, tibble (>= 3.0.4), magrittr, tidyr,