From 10d84c2007bf507b8911e3309f1b53c5aa4c8701 Mon Sep 17 00:00:00 2001 From: stemangiola Date: Fri, 20 May 2022 18:16:51 +1000 Subject: [PATCH 01/34] use new pillar methods --- NAMESPACE | 8 +- R/pillar_utilities.R | 26 ++++ R/print_method.R | 338 +++++++---------------------------------- R/utilities.R | 16 ++ man/extract-methods.Rd | 2 +- man/unite-methods.Rd | 4 +- man/unnest-methods.Rd | 2 - 7 files changed, 107 insertions(+), 289 deletions(-) create mode 100644 R/pillar_utilities.R diff --git a/NAMESPACE b/NAMESPACE index a334cf0..f18e25d 100755 --- a/NAMESPACE +++ b/NAMESPACE @@ -37,6 +37,7 @@ S3method(select,SingleCellExperiment) S3method(separate,SingleCellExperiment) S3method(slice,SingleCellExperiment) S3method(summarise,SingleCellExperiment) +S3method(tbl_format_header,tidySingleCellExperiment) S3method(tidy,SingleCellExperiment) S3method(unite,SingleCellExperiment) S3method(unnest,tidySingleCellExperiment_nested) @@ -72,6 +73,7 @@ export(select) export(separate) export(slice) export(summarise) +export(tbl_format_header) export(tidy) export(unite) export(unnest) @@ -114,9 +116,10 @@ importFrom(lifecycle,deprecate_warn) importFrom(magrittr,"%$%") importFrom(magrittr,"%>%") importFrom(methods,as) -importFrom(pillar,extra_cols) -importFrom(pillar,squeeze) +importFrom(pillar,align) +importFrom(pillar,get_extent) importFrom(pillar,style_subtle) +importFrom(pillar,tbl_format_header) importFrom(plotly,plot_ly) importFrom(purrr,imap) importFrom(purrr,map) @@ -141,7 +144,6 @@ importFrom(stringr,str_replace) importFrom(tibble,as_tibble) importFrom(tibble,enframe) importFrom(tibble,glimpse) -importFrom(tibble,trunc_mat) importFrom(tidyr,extract) importFrom(tidyr,nest) importFrom(tidyr,pivot_longer) diff --git a/R/pillar_utilities.R b/R/pillar_utilities.R new file mode 100644 index 0000000..b84d179 --- /dev/null +++ b/R/pillar_utilities.R @@ -0,0 +1,26 @@ +NBSP <- "\U00A0" + +pillar___format_comment = function (x, width) +{ + if (length(x) == 0L) { + return(character()) + } + map_chr(x, pillar___wrap, prefix = "# ", width = min(width, cli::console_width())) +} + +#' @importFrom fansi strwrap_ctl +pillar___strwrap2 = function (x, width, indent) +{ + fansi::strwrap_ctl(x, width = max(width, 0), indent = indent, + exdent = indent + 2) +} + + +pillar___wrap = function (..., indent = 0, prefix = "", width) +{ + x <- paste0(..., collapse = "") + wrapped <- pillar___strwrap2(x, width - get_extent(prefix), indent) + wrapped <- paste0(prefix, wrapped) + wrapped <- gsub(NBSP, " ", wrapped) + paste0(wrapped, collapse = "\n") +} diff --git a/R/print_method.R b/R/print_method.R index 4241726..2c4805c 100755 --- a/R/print_method.R +++ b/R/print_method.R @@ -1,5 +1,56 @@ # This file is a replacement of the unexported functions in the tibble package, in order to specify "tibble abstraction in the header" +#' tbl_format_header +#' +#' @rdname tbl_format_header-methods +#' @name tbl_format_header +#' @importFrom pillar tbl_format_header +#' +#' @noRd +#' +#' @export +NULL + +#' @importFrom rlang names2 +#' @importFrom pillar align +#' @importFrom pillar get_extent +#' @importFrom pillar style_subtle +#' @export +#' @inheritParams tbl_format_header +tbl_format_header.tidySingleCellExperiment <- function(x, setup, ...){ + + number_of_features = x |> attr("number_of_features") + assay_names = x |> attr("assay_names") + + named_header <- setup$tbl_sum + + # Change name + names(named_header) = "A SingleCellExperiment-tibble abstraction" + + if (all(names2(named_header) == "")) { + header <- named_header + } + else { + header <- + paste0( + align(paste0(names2(named_header), ":"), space = NBSP), + " ", + named_header + ) %>% + + # Add further info single-cell + append(sprintf( + "\033[90m Features=%s | cells=%s | Assays=%s\033[39m", + number_of_features, + nrow(x), + assay_names %>% paste(collapse=", ") + ), after = 1) + } + style_subtle(pillar___format_comment(header, width = setup$width)) + +} + + #' Printing tibbles #' #' @description @@ -65,295 +116,20 @@ NULL #' @export print.SingleCellExperiment <- function(x, ..., n = NULL, width = NULL, n_extra = NULL) { - x %>% - as_tibble(n_dimensions_to_return = 5) %>% - - # Get formatting - tidySingleCellExperiment_format_tbl(..., n = n, width = width, n_extra = n_extra) %>% - - # Hijack the tibble header - map_chr(~ .x %>% str_replace("A tibble:", "A SingleCellExperiment-tibble abstraction:")) %>% - - # Insert more info - append(sprintf( - "\033[90m# Features=%s | Assays=%s\033[39m", - nrow(x), - assays(x) %>% names %>% paste(collapse=", ") - ), after = 1) %>% - - # Output - cat_line() + x |> + as_tibble(n_dimensions_to_return = 5) |> + vctrs::new_data_frame(class = c("tidySingleCellExperiment", "tbl")) %>% + tidybulk:::add_attr( nrow(x), "number_of_features") %>% + tidybulk:::add_attr( assays(x) %>% names , "assay_names") %>% + print() invisible(x) } -#' @importFrom tibble trunc_mat -tidySingleCellExperiment_format_tbl <- function(x, ..., n = NULL, width = NULL, n_extra = NULL) { - mat <- trunc_mat(x, n = n, width = width, n_extra = n_extra) - tidySingleCellExperiment_format_truncated_mat(mat) -} - -tidySingleCellExperiment_pluralise_n <- function(message, n) { - stopifnot(n >= 0) - - - # Don't strip parens if they have a space in between - # (but not if the space comes before the closing paren) - - if (n == 1) { - # strip [ - message <- gsub("\\[([^\\] ]* *)\\]", "\\1", message, perl = TRUE) - # remove ( and its content - message <- gsub("\\([^\\) ]* *\\)", "", message, perl = TRUE) - } else { - # strip ( - message <- gsub("\\(([^\\) ]* *)\\)", "\\1", message, perl = TRUE) - # remove [ and its content - message <- gsub("\\[[^\\] ]* *\\]", "", message, perl = TRUE) - } - - message -} - -tidySingleCellExperiment_nchar_width <- function(x) { - nchar(x, type = "width") -} - -#' @importFrom pillar style_subtle -#' @importFrom rlang names2 -#' @importFrom pillar squeeze -tidySingleCellExperiment_format_truncated_mat <- function(x, width = NULL, ...) { - if (is.null(width)) { - width <- x$width - } - - width <- tidySingleCellExperiment_tibble_width(width) - - named_header <- tidySingleCellExperiment_format_header(x) - if (all(names2(named_header) == "")) { - header <- named_header - } else { - header <- paste0( - tidySingleCellExperiment_justify( - paste0(names2(named_header), ":"), - right = FALSE, space = NBSP - ), - # We add a space after the NBSP inserted by tidySingleCellExperiment_justify() - # so that wrapping occurs at the right location for very narrow outputs - " ", - named_header - ) - } - - comment <- tidySingleCellExperiment_format_comment(header, width = width) - squeezed <- squeeze(x$mcf, width = width) - mcf <- tidySingleCellExperiment_format_body(squeezed) - - # Splitting lines is important, otherwise subtle style may be lost - # if column names contain spaces. - footer <- tidySingleCellExperiment_pre_dots(tidySingleCellExperiment_format_footer(x, squeezed)) - footer_comment <- tidySingleCellExperiment_split_lines(tidySingleCellExperiment_format_comment(footer, width = width)) - - c(style_subtle(comment), mcf, style_subtle(footer_comment)) -} - -tidySingleCellExperiment_format_header <- function(x) { - x$summary -} - -tidySingleCellExperiment_format_body <- function(x) { - format(x) -} - -#' @importFrom pillar extra_cols -tidySingleCellExperiment_format_footer <- function(x, squeezed_colonnade) { - extra_rows <- tidySingleCellExperiment_format_footer_rows(x) - extra_cols <- tidySingleCellExperiment_format_footer_cols(x, extra_cols(squeezed_colonnade, n = x$n_extra)) - - extra <- c(extra_rows, extra_cols) - if (length(extra) >= 1) { - extra[[1]] <- paste0("with ", extra[[1]]) - extra[-1] <- map_chr(extra[-1], function(ex) paste0("and ", ex)) - collapse(extra) - } else { - character() - } -} - -tidySingleCellExperiment_format_footer_rows <- function(x) { - if (length(x$mcf) != 0) { - if (is.na(x$rows_missing)) { - "more rows" - } else if (x$rows_missing > 0) { - paste0(tidySingleCellExperiment_big_mark(x$rows_missing), tidySingleCellExperiment_pluralise_n(" more row(s)", x$rows_missing)) - } - } else if (is.na(x$rows_total) && x$rows_min > 0) { - paste0("at least ", tidySingleCellExperiment_big_mark(x$rows_min), tidySingleCellExperiment_pluralise_n(" row(s) total", x$rows_min)) - } -} - -tidySingleCellExperiment_format_footer_cols <- function(x, extra_cols) { - if (length(extra_cols) == 0) return(NULL) - - vars <- tidySingleCellExperiment_format_extra_vars(extra_cols) - paste0( - tidySingleCellExperiment_big_mark(length(extra_cols)), " ", - if (!identical(x$rows_total, 0L) && x$rows_min > 0) "more ", - pluralise("variable(s)", extra_cols), vars - ) -} - -tidySingleCellExperiment_format_extra_vars <- function(extra_cols) { - # Also covers empty extra_cols vector! - if (is.na(extra_cols[1])) return("") - - if (anyNA(extra_cols)) { - extra_cols <- c(extra_cols[!is.na(extra_cols)], cli::symbol$ellipsis) - } - - paste0(": ", collapse(extra_cols)) -} - -tidySingleCellExperiment_format_comment <- function(x, width) { - if (length(x) == 0L) return(character()) - map_chr(x, tidySingleCellExperiment_wrap, prefix = "# ", width = min(width, getOption("width"))) -} - -tidySingleCellExperiment_pre_dots <- function(x) { - if (length(x) > 0) { - paste0(cli::symbol$ellipsis, " ", x) - } else { - character() - } -} - -tidySingleCellExperiment_justify <- function(x, right = TRUE, space = " ") { - if (length(x) == 0L) return(character()) - width <- tidySingleCellExperiment_nchar_width(x) - max_width <- max(width) - spaces_template <- paste(rep(space, max_width), collapse = "") - spaces <- map_chr(max_width - width, substr, x = spaces_template, start = 1L) - if (right) { - paste0(spaces, x) - } else { - paste0(x, spaces) - } -} - -tidySingleCellExperiment_split_lines <- function(x) { - # Avoid .ptype argument to vec_c() - if (is_empty(x)) return(character()) - - unlist(strsplit(x, "\n", fixed = TRUE)) -} - -tidySingleCellExperiment_big_mark <- function(x, ...) { - # The thousand separator, - # "," unless it's used for the decimal point, in which case "." - mark <- if (identical(getOption("OutDec"), ",")) "." else "," - ret <- formatC(x, big.mark = mark, format = "d", ...) - ret[is.na(x)] <- "??" - ret -} - -collapse <- function(x) paste(x, collapse = ", ") - -# tidySingleCellExperiment_wrap -------------------------------------------------------------------- - -NBSP <- "\U00A0" - -tidySingleCellExperiment_wrap <- function(..., indent = 0, prefix = "", width) { - x <- paste0(..., collapse = "") - wrapped <- tidySingleCellExperiment_strwrap2(x, width - tidySingleCellExperiment_nchar_width(prefix), indent) - wrapped <- paste0(prefix, wrapped) - wrapped <- gsub(NBSP, " ", wrapped) - - paste0(wrapped, collapse = "\n") -} - -#' @importFrom fansi strwrap_ctl -tidySingleCellExperiment_strwrap2 <- function(x, width, indent) { - strwrap_ctl(x, width = max(width, 0), indent = indent, exdent = indent + 2) -} - - -op.tibble <- list( - tibble.print_max = 20L, - tibble.print_min = 10L, - tibble.width = NULL, - tibble.max_extra_cols = 100L, - tibble.view_max = 1000L -) - -tidySingleCellExperiment_tibble_opt <- function(x, dplyr = TRUE) { - x_tibble <- paste0("tibble.", x) - res <- getOption(x_tibble) - if (!is.null(res)) { - return(res) - } - - if (dplyr) { - x_dplyr <- paste0("dplyr.", x) - res <- getOption(x_dplyr) - if (!is.null(res)) { - return(res) - } - } - - op.tibble[[x_tibble]] -} - -tidySingleCellExperiment_tibble_width <- function(width) { - if (!is.null(width)) { - return(width) - } - - width <- tidySingleCellExperiment_tibble_opt("width") - if (!is.null(width)) { - return(width) - } - - getOption("width") -} - -tidySingleCellExperiment_tibble_glimpse_width <- function(width) { - if (!is.null(width)) { - return(width) - } - - width <- tidySingleCellExperiment_tibble_opt("width") - if (!is.null(width) && is.finite(width)) { - return(width) - } - - getOption("width") -} - -# Pluralise if there are many columns -pluralise <- function(message, objects) { - pluralise_n(message, length(objects)) -} -pluralise_n <- function(message, n) { - stopifnot(n >= 0) - # Don't strip parens if they have a space in between - # (but not if the space comes before the closing paren) - if (n == 1) { - # strip [ - message <- gsub("\\[([^\\] ]* *)\\]", "\\1", message, perl = TRUE) - # remove ( and its content - message <- gsub("\\([^\\) ]* *\\)", "", message, perl = TRUE) - } else { - # strip ( - message <- gsub("\\(([^\\) ]* *)\\)", "\\1", message, perl = TRUE) - # remove [ and its content - message <- gsub("\\[[^\\] ]* *\\]", "", message, perl = TRUE) - } - message -} diff --git a/R/utilities.R b/R/utilities.R index 64e717a..3745997 100755 --- a/R/utilities.R +++ b/R/utilities.R @@ -383,3 +383,19 @@ c_ = function(x){ if("cell__" %in% names(metadata(x))) cell__ = metadata(x)$cell__ return(cell__) } + +#' Add attribute to abject +#' +#' @keywords internal +#' @noRd +#' +#' +#' @param var A tibble +#' @param attribute An object +#' @param name A character name of the attribute +#' +#' @return A tibble with an additional attribute +add_attr = function(var, attribute, name) { + attr(var, name) <- attribute + var +} diff --git a/man/extract-methods.Rd b/man/extract-methods.Rd index e496a0a..834f879 100644 --- a/man/extract-methods.Rd +++ b/man/extract-methods.Rd @@ -23,7 +23,7 @@ expression groups} \code{\link[tidyselect:vars_pull]{tidyselect::vars_pull()}}. This argument is passed by expression and supports -\link[rlang:nse-force]{quasiquotation} (you can unquote column +\link[rlang:topic-inject]{quasiquotation} (you can unquote column names or column positions).} \item{into}{Names of new variables to create as character vector. diff --git a/man/unite-methods.Rd b/man/unite-methods.Rd index fb19305..0309420 100644 --- a/man/unite-methods.Rd +++ b/man/unite-methods.Rd @@ -9,9 +9,9 @@ \item{col}{The name of the new column, as a string or symbol. This argument is passed by expression and supports -\link[rlang:nse-force]{quasiquotation} (you can unquote strings +\link[rlang:topic-inject]{quasiquotation} (you can unquote strings and symbols). The name is captured from the expression with -\code{\link[rlang:nse-defuse]{rlang::ensym()}} (note that this kind of interface where +\code{\link[rlang:defusing-advanced]{rlang::ensym()}} (note that this kind of interface where symbols do not represent actual objects is now discouraged in the tidyverse; we support it here for backward compatibility).} diff --git a/man/unnest-methods.Rd b/man/unnest-methods.Rd index abd7ddb..7787fa8 100644 --- a/man/unnest-methods.Rd +++ b/man/unnest-methods.Rd @@ -20,7 +20,6 @@ .preserve ) - unnest_single_cell_experiment( data, cols, @@ -77,7 +76,6 @@ stripped. This makes \code{names_sep} roughly symmetric between nesting and unne \item{.sep}{tidyr::unnest} - \item{.preserve}{See tidyr::unnest} \item{sep}{tidyr::unnest} From 8e7a0c49ef13f7b63e17ddcc870452e016fcfc35 Mon Sep 17 00:00:00 2001 From: stemangiola Date: Fri, 20 May 2022 18:19:59 +1000 Subject: [PATCH 02/34] version UP --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 8cac75d..e1ee1ee 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: tidySingleCellExperiment Title: Brings SingleCellExperiment to the Tidyverse -Version: 1.7.0 +Version: 1.7.1 Authors@R: c(person("Stefano", "Mangiola", email = "mangiolastefano@gmail.com", role = c("aut", "cre")) ) Description: tidySingleCellExperiment is an adapter that abstracts the 'SingleCellExperiment' container From 30e2316e16ec724cc2e0765d10bdae1e88dbeee0 Mon Sep 17 00:00:00 2001 From: stemangiola Date: Fri, 20 May 2022 18:31:25 +1000 Subject: [PATCH 03/34] fix bug tidybulk reference --- DESCRIPTION | 2 +- R/print_method.R | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index e1ee1ee..14f4203 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: tidySingleCellExperiment Title: Brings SingleCellExperiment to the Tidyverse -Version: 1.7.1 +Version: 1.7.2 Authors@R: c(person("Stefano", "Mangiola", email = "mangiolastefano@gmail.com", role = c("aut", "cre")) ) Description: tidySingleCellExperiment is an adapter that abstracts the 'SingleCellExperiment' container diff --git a/R/print_method.R b/R/print_method.R index 2c4805c..b9caead 100755 --- a/R/print_method.R +++ b/R/print_method.R @@ -119,8 +119,8 @@ print.SingleCellExperiment <- function(x, ..., n = NULL, width = NULL, n_extra = x |> as_tibble(n_dimensions_to_return = 5) |> vctrs::new_data_frame(class = c("tidySingleCellExperiment", "tbl")) %>% - tidybulk:::add_attr( nrow(x), "number_of_features") %>% - tidybulk:::add_attr( assays(x) %>% names , "assay_names") %>% + add_attr( nrow(x), "number_of_features") %>% + add_attr( assays(x) %>% names , "assay_names") %>% print() invisible(x) From e58f39619c6c31877019d1b0ce7defa0087a49e0 Mon Sep 17 00:00:00 2001 From: stemangiola Date: Fri, 20 May 2022 18:57:03 +1000 Subject: [PATCH 04/34] typo --- R/print_method.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/print_method.R b/R/print_method.R index b9caead..5217396 100755 --- a/R/print_method.R +++ b/R/print_method.R @@ -40,7 +40,7 @@ tbl_format_header.tidySingleCellExperiment <- function(x, setup, ...){ # Add further info single-cell append(sprintf( - "\033[90m Features=%s | cells=%s | Assays=%s\033[39m", + "\033[90m Features=%s | Cells=%s | Assays=%s\033[39m", number_of_features, nrow(x), assay_names %>% paste(collapse=", ") From aab95cb3ec4a4c137415aba520e745432612514c Mon Sep 17 00:00:00 2001 From: stemangiola Date: Fri, 20 May 2022 19:35:22 +1000 Subject: [PATCH 05/34] fix CHECK --- DESCRIPTION | 3 ++- NAMESPACE | 1 + R/print_method.R | 28 +++++++++++++++++++++++----- man/tbl_format_header-methods.Rd | 19 +++++++++++++++++++ 4 files changed, 45 insertions(+), 6 deletions(-) create mode 100644 man/tbl_format_header-methods.Rd diff --git a/DESCRIPTION b/DESCRIPTION index 14f4203..57b580b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -5,7 +5,7 @@ Version: 1.7.2 Authors@R: c(person("Stefano", "Mangiola", email = "mangiolastefano@gmail.com", role = c("aut", "cre")) ) Description: tidySingleCellExperiment is an adapter that abstracts the 'SingleCellExperiment' container - in the form of tibble and allows the data manipulation, plotting and nesting using 'tidyverse' + in the form of tibble and allows the data manipulation, plotting and nesting using 'tidyverse'. License: GPL-3 Depends: R (>= 4.0.0), @@ -27,6 +27,7 @@ Imports: S4Vectors, tidyselect, ellipsis, + vctrs, pillar, stringr, cli, diff --git a/NAMESPACE b/NAMESPACE index f18e25d..992c1af 100755 --- a/NAMESPACE +++ b/NAMESPACE @@ -154,3 +154,4 @@ importFrom(tidyr,unnest) importFrom(tidyselect,eval_select) importFrom(ttservice,join_features) importFrom(utils,tail) +importFrom(vctrs,new_data_frame) diff --git a/R/print_method.R b/R/print_method.R index 5217396..25f2969 100755 --- a/R/print_method.R +++ b/R/print_method.R @@ -1,14 +1,31 @@ # This file is a replacement of the unexported functions in the tibble package, in order to specify "tibble abstraction in the header" -#' tbl_format_header +#' Format the header of a tibble +#' +#' @description +#' `r lifecycle::badge("experimental")` +#' +#' For easier customization, the formatting of a tibble is split +#' into three components: header, body, and footer. +#' The `tbl_format_header()` method is responsible for formatting the header +#' of a tibble. +#' +#' Override this method if you need to change the appearance +#' of the entire header. +#' If you only need to change or extend the components shown in the header, +#' override or extend [tbl_sum()] for your class which is called by the +#' default method. #' -#' @rdname tbl_format_header-methods -#' @name tbl_format_header #' @importFrom pillar tbl_format_header +#' @inheritParams tbl_format_body +#' @inherit tbl_format_body return #' -#' @noRd +#' @rdname tbl_format_header-methods +#' @name tbl_format_header #' #' @export +#' +NULL NULL #' @importFrom rlang names2 @@ -113,12 +130,13 @@ NULL #' @rdname print #' @importFrom cli cat_line #' @importFrom SingleCellExperiment counts +#' @importFrom vctrs new_data_frame #' @export print.SingleCellExperiment <- function(x, ..., n = NULL, width = NULL, n_extra = NULL) { x |> as_tibble(n_dimensions_to_return = 5) |> - vctrs::new_data_frame(class = c("tidySingleCellExperiment", "tbl")) %>% + new_data_frame(class = c("tidySingleCellExperiment", "tbl")) %>% add_attr( nrow(x), "number_of_features") %>% add_attr( assays(x) %>% names , "assay_names") %>% print() diff --git a/man/tbl_format_header-methods.Rd b/man/tbl_format_header-methods.Rd new file mode 100644 index 0000000..a1f630c --- /dev/null +++ b/man/tbl_format_header-methods.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/print_method.R +\name{tbl_format_header} +\alias{tbl_format_header} +\title{Format the header of a tibble} +\description{ +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} + +For easier customization, the formatting of a tibble is split +into three components: header, body, and footer. +The \code{tbl_format_header()} method is responsible for formatting the header +of a tibble. + +Override this method if you need to change the appearance +of the entire header. +If you only need to change or extend the components shown in the header, +override or extend \code{\link[=tbl_sum]{tbl_sum()}} for your class which is called by the +default method. +} From 3e372b733ef36517aac0fc22fc3deb0075d507b4 Mon Sep 17 00:00:00 2001 From: stemangiola Date: Tue, 26 Jul 2022 09:03:02 +1000 Subject: [PATCH 06/34] dummy change --- R/print_method.R | 1 - 1 file changed, 1 deletion(-) diff --git a/R/print_method.R b/R/print_method.R index 25f2969..a8303b8 100755 --- a/R/print_method.R +++ b/R/print_method.R @@ -26,7 +26,6 @@ #' @export #' NULL -NULL #' @importFrom rlang names2 #' @importFrom pillar align From 179891a1e18cf2f8be58cd20a68ade04a4d9881c Mon Sep 17 00:00:00 2001 From: stemangiola Date: Tue, 26 Jul 2022 10:28:24 +1000 Subject: [PATCH 07/34] print restore show --- DESCRIPTION | 2 +- R/methods.R | 89 ++++++++++++++++++++++++++-------------------------- man/print.Rd | 2 +- 3 files changed, 47 insertions(+), 46 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 57b580b..d72619d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -57,7 +57,7 @@ Biarch: true biocViews: AssayDomain, Infrastructure, RNASeq, DifferentialExpression, GeneExpression, Normalization, Clustering, QualityControl, Sequencing Encoding: UTF-8 LazyData: true -RoxygenNote: 7.1.2 +RoxygenNote: 7.2.0 Roxygen: list(markdown = TRUE) URL: https://github.com/stemangiola/tidySingleCellExperiment BugReports: https://github.com/stemangiola/tidySingleCellExperiment/issues diff --git a/R/methods.R b/R/methods.R index 15d4977..b8f30de 100755 --- a/R/methods.R +++ b/R/methods.R @@ -1,57 +1,24 @@ -setClass("tidySingleCellExperiment", contains = "SingleCellExperiment") - -#' tidy for SingleCellExperiment -#' -#' @param object A SingleCellExperiment object -#' -#' @return A tidySingleCellExperiment object -#' -#' @name tidy -#' -#' @examples -#' -#' tidySingleCellExperiment::pbmc_small -#' @export -tidy <- function(object) { - UseMethod("tidy", object) -} - -#' @importFrom methods as -#' @importFrom lifecycle deprecate_warn -#' -#' @param object A SingleCellExperiment object -#' -#' @export -tidy.SingleCellExperiment <- function(object) { - - # DEPRECATE - deprecate_warn( - when = "1.1.1", - what = "tidy()", - details = "tidySingleCellExperiment says: tidy() is not needed anymore." - ) - - object -} setMethod( f = "show", signature = "SingleCellExperiment", definition = function(object) { - if (isTRUE(x = getOption(x = "restore_SingleCellExperiment_show", default = FALSE))) { - f <- getMethod( - f = "show", - signature = "SingleCellExperiment", - where = asNamespace(ns = "SingleCellExperiment") + if ( + isTRUE(x = getOption(x = "restore_SingleCellExperiment_show", default = FALSE)) + ) { + f <-getMethod( + f = "show", + signature = "SummarizedExperiment", + where = asNamespace(ns = "SummarizedExperiment") ) f(object = object) - } else { - object %>% - print() - } + + } else { print(object) } } ) +setClass("tidySingleCellExperiment", contains = "SingleCellExperiment") + #' Extract and join information for features. #' #' @@ -130,5 +97,39 @@ setMethod("join_features", "SingleCellExperiment", function(.data, }) +#' tidy for SingleCellExperiment +#' +#' @param object A SingleCellExperiment object +#' +#' @return A tidySingleCellExperiment object +#' +#' @name tidy +#' +#' @examples +#' +#' tidySingleCellExperiment::pbmc_small +#' @export +tidy <- function(object) { + UseMethod("tidy", object) +} + +#' @importFrom methods as +#' @importFrom lifecycle deprecate_warn +#' +#' @param object A SingleCellExperiment object +#' +#' @export +tidy.SingleCellExperiment <- function(object) { + + # DEPRECATE + deprecate_warn( + when = "1.1.1", + what = "tidy()", + details = "tidySingleCellExperiment says: tidy() is not needed anymore." + ) + + object +} + diff --git a/man/print.Rd b/man/print.Rd index 53d4817..bad962f 100644 --- a/man/print.Rd +++ b/man/print.Rd @@ -51,7 +51,7 @@ Only the first 5 reduced dimensions are displayed, while all of them are queriab The following options are used by the tibble and pillar packages to format and print \code{tbl_df} objects. -Used by the formatting workhorse \code{trunc_mat()} and, therefore, +Used by the formatting workhorse \code{trunc_mat()} and therefore, indirectly, by \code{print.tbl()}. \itemize{ \item \code{tibble.print_max}: Row number threshold: Maximum number of rows printed. From ced353122bfac63ec18cb236375c616dcc82d5a9 Mon Sep 17 00:00:00 2001 From: stemangiola Date: Fri, 20 May 2022 18:16:51 +1000 Subject: [PATCH 08/34] use new pillar methods --- NAMESPACE | 8 +- R/pillar_utilities.R | 26 ++++ R/print_method.R | 338 +++++++---------------------------------- R/utilities.R | 16 ++ man/extract-methods.Rd | 2 +- man/unite-methods.Rd | 4 +- man/unnest-methods.Rd | 2 - 7 files changed, 107 insertions(+), 289 deletions(-) create mode 100644 R/pillar_utilities.R diff --git a/NAMESPACE b/NAMESPACE index a334cf0..f18e25d 100755 --- a/NAMESPACE +++ b/NAMESPACE @@ -37,6 +37,7 @@ S3method(select,SingleCellExperiment) S3method(separate,SingleCellExperiment) S3method(slice,SingleCellExperiment) S3method(summarise,SingleCellExperiment) +S3method(tbl_format_header,tidySingleCellExperiment) S3method(tidy,SingleCellExperiment) S3method(unite,SingleCellExperiment) S3method(unnest,tidySingleCellExperiment_nested) @@ -72,6 +73,7 @@ export(select) export(separate) export(slice) export(summarise) +export(tbl_format_header) export(tidy) export(unite) export(unnest) @@ -114,9 +116,10 @@ importFrom(lifecycle,deprecate_warn) importFrom(magrittr,"%$%") importFrom(magrittr,"%>%") importFrom(methods,as) -importFrom(pillar,extra_cols) -importFrom(pillar,squeeze) +importFrom(pillar,align) +importFrom(pillar,get_extent) importFrom(pillar,style_subtle) +importFrom(pillar,tbl_format_header) importFrom(plotly,plot_ly) importFrom(purrr,imap) importFrom(purrr,map) @@ -141,7 +144,6 @@ importFrom(stringr,str_replace) importFrom(tibble,as_tibble) importFrom(tibble,enframe) importFrom(tibble,glimpse) -importFrom(tibble,trunc_mat) importFrom(tidyr,extract) importFrom(tidyr,nest) importFrom(tidyr,pivot_longer) diff --git a/R/pillar_utilities.R b/R/pillar_utilities.R new file mode 100644 index 0000000..b84d179 --- /dev/null +++ b/R/pillar_utilities.R @@ -0,0 +1,26 @@ +NBSP <- "\U00A0" + +pillar___format_comment = function (x, width) +{ + if (length(x) == 0L) { + return(character()) + } + map_chr(x, pillar___wrap, prefix = "# ", width = min(width, cli::console_width())) +} + +#' @importFrom fansi strwrap_ctl +pillar___strwrap2 = function (x, width, indent) +{ + fansi::strwrap_ctl(x, width = max(width, 0), indent = indent, + exdent = indent + 2) +} + + +pillar___wrap = function (..., indent = 0, prefix = "", width) +{ + x <- paste0(..., collapse = "") + wrapped <- pillar___strwrap2(x, width - get_extent(prefix), indent) + wrapped <- paste0(prefix, wrapped) + wrapped <- gsub(NBSP, " ", wrapped) + paste0(wrapped, collapse = "\n") +} diff --git a/R/print_method.R b/R/print_method.R index 4241726..2c4805c 100755 --- a/R/print_method.R +++ b/R/print_method.R @@ -1,5 +1,56 @@ # This file is a replacement of the unexported functions in the tibble package, in order to specify "tibble abstraction in the header" +#' tbl_format_header +#' +#' @rdname tbl_format_header-methods +#' @name tbl_format_header +#' @importFrom pillar tbl_format_header +#' +#' @noRd +#' +#' @export +NULL + +#' @importFrom rlang names2 +#' @importFrom pillar align +#' @importFrom pillar get_extent +#' @importFrom pillar style_subtle +#' @export +#' @inheritParams tbl_format_header +tbl_format_header.tidySingleCellExperiment <- function(x, setup, ...){ + + number_of_features = x |> attr("number_of_features") + assay_names = x |> attr("assay_names") + + named_header <- setup$tbl_sum + + # Change name + names(named_header) = "A SingleCellExperiment-tibble abstraction" + + if (all(names2(named_header) == "")) { + header <- named_header + } + else { + header <- + paste0( + align(paste0(names2(named_header), ":"), space = NBSP), + " ", + named_header + ) %>% + + # Add further info single-cell + append(sprintf( + "\033[90m Features=%s | cells=%s | Assays=%s\033[39m", + number_of_features, + nrow(x), + assay_names %>% paste(collapse=", ") + ), after = 1) + } + style_subtle(pillar___format_comment(header, width = setup$width)) + +} + + #' Printing tibbles #' #' @description @@ -65,295 +116,20 @@ NULL #' @export print.SingleCellExperiment <- function(x, ..., n = NULL, width = NULL, n_extra = NULL) { - x %>% - as_tibble(n_dimensions_to_return = 5) %>% - - # Get formatting - tidySingleCellExperiment_format_tbl(..., n = n, width = width, n_extra = n_extra) %>% - - # Hijack the tibble header - map_chr(~ .x %>% str_replace("A tibble:", "A SingleCellExperiment-tibble abstraction:")) %>% - - # Insert more info - append(sprintf( - "\033[90m# Features=%s | Assays=%s\033[39m", - nrow(x), - assays(x) %>% names %>% paste(collapse=", ") - ), after = 1) %>% - - # Output - cat_line() + x |> + as_tibble(n_dimensions_to_return = 5) |> + vctrs::new_data_frame(class = c("tidySingleCellExperiment", "tbl")) %>% + tidybulk:::add_attr( nrow(x), "number_of_features") %>% + tidybulk:::add_attr( assays(x) %>% names , "assay_names") %>% + print() invisible(x) } -#' @importFrom tibble trunc_mat -tidySingleCellExperiment_format_tbl <- function(x, ..., n = NULL, width = NULL, n_extra = NULL) { - mat <- trunc_mat(x, n = n, width = width, n_extra = n_extra) - tidySingleCellExperiment_format_truncated_mat(mat) -} - -tidySingleCellExperiment_pluralise_n <- function(message, n) { - stopifnot(n >= 0) - - - # Don't strip parens if they have a space in between - # (but not if the space comes before the closing paren) - - if (n == 1) { - # strip [ - message <- gsub("\\[([^\\] ]* *)\\]", "\\1", message, perl = TRUE) - # remove ( and its content - message <- gsub("\\([^\\) ]* *\\)", "", message, perl = TRUE) - } else { - # strip ( - message <- gsub("\\(([^\\) ]* *)\\)", "\\1", message, perl = TRUE) - # remove [ and its content - message <- gsub("\\[[^\\] ]* *\\]", "", message, perl = TRUE) - } - - message -} - -tidySingleCellExperiment_nchar_width <- function(x) { - nchar(x, type = "width") -} - -#' @importFrom pillar style_subtle -#' @importFrom rlang names2 -#' @importFrom pillar squeeze -tidySingleCellExperiment_format_truncated_mat <- function(x, width = NULL, ...) { - if (is.null(width)) { - width <- x$width - } - - width <- tidySingleCellExperiment_tibble_width(width) - - named_header <- tidySingleCellExperiment_format_header(x) - if (all(names2(named_header) == "")) { - header <- named_header - } else { - header <- paste0( - tidySingleCellExperiment_justify( - paste0(names2(named_header), ":"), - right = FALSE, space = NBSP - ), - # We add a space after the NBSP inserted by tidySingleCellExperiment_justify() - # so that wrapping occurs at the right location for very narrow outputs - " ", - named_header - ) - } - - comment <- tidySingleCellExperiment_format_comment(header, width = width) - squeezed <- squeeze(x$mcf, width = width) - mcf <- tidySingleCellExperiment_format_body(squeezed) - - # Splitting lines is important, otherwise subtle style may be lost - # if column names contain spaces. - footer <- tidySingleCellExperiment_pre_dots(tidySingleCellExperiment_format_footer(x, squeezed)) - footer_comment <- tidySingleCellExperiment_split_lines(tidySingleCellExperiment_format_comment(footer, width = width)) - - c(style_subtle(comment), mcf, style_subtle(footer_comment)) -} - -tidySingleCellExperiment_format_header <- function(x) { - x$summary -} - -tidySingleCellExperiment_format_body <- function(x) { - format(x) -} - -#' @importFrom pillar extra_cols -tidySingleCellExperiment_format_footer <- function(x, squeezed_colonnade) { - extra_rows <- tidySingleCellExperiment_format_footer_rows(x) - extra_cols <- tidySingleCellExperiment_format_footer_cols(x, extra_cols(squeezed_colonnade, n = x$n_extra)) - - extra <- c(extra_rows, extra_cols) - if (length(extra) >= 1) { - extra[[1]] <- paste0("with ", extra[[1]]) - extra[-1] <- map_chr(extra[-1], function(ex) paste0("and ", ex)) - collapse(extra) - } else { - character() - } -} - -tidySingleCellExperiment_format_footer_rows <- function(x) { - if (length(x$mcf) != 0) { - if (is.na(x$rows_missing)) { - "more rows" - } else if (x$rows_missing > 0) { - paste0(tidySingleCellExperiment_big_mark(x$rows_missing), tidySingleCellExperiment_pluralise_n(" more row(s)", x$rows_missing)) - } - } else if (is.na(x$rows_total) && x$rows_min > 0) { - paste0("at least ", tidySingleCellExperiment_big_mark(x$rows_min), tidySingleCellExperiment_pluralise_n(" row(s) total", x$rows_min)) - } -} - -tidySingleCellExperiment_format_footer_cols <- function(x, extra_cols) { - if (length(extra_cols) == 0) return(NULL) - - vars <- tidySingleCellExperiment_format_extra_vars(extra_cols) - paste0( - tidySingleCellExperiment_big_mark(length(extra_cols)), " ", - if (!identical(x$rows_total, 0L) && x$rows_min > 0) "more ", - pluralise("variable(s)", extra_cols), vars - ) -} - -tidySingleCellExperiment_format_extra_vars <- function(extra_cols) { - # Also covers empty extra_cols vector! - if (is.na(extra_cols[1])) return("") - - if (anyNA(extra_cols)) { - extra_cols <- c(extra_cols[!is.na(extra_cols)], cli::symbol$ellipsis) - } - - paste0(": ", collapse(extra_cols)) -} - -tidySingleCellExperiment_format_comment <- function(x, width) { - if (length(x) == 0L) return(character()) - map_chr(x, tidySingleCellExperiment_wrap, prefix = "# ", width = min(width, getOption("width"))) -} - -tidySingleCellExperiment_pre_dots <- function(x) { - if (length(x) > 0) { - paste0(cli::symbol$ellipsis, " ", x) - } else { - character() - } -} - -tidySingleCellExperiment_justify <- function(x, right = TRUE, space = " ") { - if (length(x) == 0L) return(character()) - width <- tidySingleCellExperiment_nchar_width(x) - max_width <- max(width) - spaces_template <- paste(rep(space, max_width), collapse = "") - spaces <- map_chr(max_width - width, substr, x = spaces_template, start = 1L) - if (right) { - paste0(spaces, x) - } else { - paste0(x, spaces) - } -} - -tidySingleCellExperiment_split_lines <- function(x) { - # Avoid .ptype argument to vec_c() - if (is_empty(x)) return(character()) - - unlist(strsplit(x, "\n", fixed = TRUE)) -} - -tidySingleCellExperiment_big_mark <- function(x, ...) { - # The thousand separator, - # "," unless it's used for the decimal point, in which case "." - mark <- if (identical(getOption("OutDec"), ",")) "." else "," - ret <- formatC(x, big.mark = mark, format = "d", ...) - ret[is.na(x)] <- "??" - ret -} - -collapse <- function(x) paste(x, collapse = ", ") - -# tidySingleCellExperiment_wrap -------------------------------------------------------------------- - -NBSP <- "\U00A0" - -tidySingleCellExperiment_wrap <- function(..., indent = 0, prefix = "", width) { - x <- paste0(..., collapse = "") - wrapped <- tidySingleCellExperiment_strwrap2(x, width - tidySingleCellExperiment_nchar_width(prefix), indent) - wrapped <- paste0(prefix, wrapped) - wrapped <- gsub(NBSP, " ", wrapped) - - paste0(wrapped, collapse = "\n") -} - -#' @importFrom fansi strwrap_ctl -tidySingleCellExperiment_strwrap2 <- function(x, width, indent) { - strwrap_ctl(x, width = max(width, 0), indent = indent, exdent = indent + 2) -} - - -op.tibble <- list( - tibble.print_max = 20L, - tibble.print_min = 10L, - tibble.width = NULL, - tibble.max_extra_cols = 100L, - tibble.view_max = 1000L -) - -tidySingleCellExperiment_tibble_opt <- function(x, dplyr = TRUE) { - x_tibble <- paste0("tibble.", x) - res <- getOption(x_tibble) - if (!is.null(res)) { - return(res) - } - - if (dplyr) { - x_dplyr <- paste0("dplyr.", x) - res <- getOption(x_dplyr) - if (!is.null(res)) { - return(res) - } - } - - op.tibble[[x_tibble]] -} - -tidySingleCellExperiment_tibble_width <- function(width) { - if (!is.null(width)) { - return(width) - } - - width <- tidySingleCellExperiment_tibble_opt("width") - if (!is.null(width)) { - return(width) - } - - getOption("width") -} - -tidySingleCellExperiment_tibble_glimpse_width <- function(width) { - if (!is.null(width)) { - return(width) - } - - width <- tidySingleCellExperiment_tibble_opt("width") - if (!is.null(width) && is.finite(width)) { - return(width) - } - - getOption("width") -} - -# Pluralise if there are many columns -pluralise <- function(message, objects) { - pluralise_n(message, length(objects)) -} -pluralise_n <- function(message, n) { - stopifnot(n >= 0) - # Don't strip parens if they have a space in between - # (but not if the space comes before the closing paren) - if (n == 1) { - # strip [ - message <- gsub("\\[([^\\] ]* *)\\]", "\\1", message, perl = TRUE) - # remove ( and its content - message <- gsub("\\([^\\) ]* *\\)", "", message, perl = TRUE) - } else { - # strip ( - message <- gsub("\\(([^\\) ]* *)\\)", "\\1", message, perl = TRUE) - # remove [ and its content - message <- gsub("\\[[^\\] ]* *\\]", "", message, perl = TRUE) - } - message -} diff --git a/R/utilities.R b/R/utilities.R index 64e717a..3745997 100755 --- a/R/utilities.R +++ b/R/utilities.R @@ -383,3 +383,19 @@ c_ = function(x){ if("cell__" %in% names(metadata(x))) cell__ = metadata(x)$cell__ return(cell__) } + +#' Add attribute to abject +#' +#' @keywords internal +#' @noRd +#' +#' +#' @param var A tibble +#' @param attribute An object +#' @param name A character name of the attribute +#' +#' @return A tibble with an additional attribute +add_attr = function(var, attribute, name) { + attr(var, name) <- attribute + var +} diff --git a/man/extract-methods.Rd b/man/extract-methods.Rd index e496a0a..834f879 100644 --- a/man/extract-methods.Rd +++ b/man/extract-methods.Rd @@ -23,7 +23,7 @@ expression groups} \code{\link[tidyselect:vars_pull]{tidyselect::vars_pull()}}. This argument is passed by expression and supports -\link[rlang:nse-force]{quasiquotation} (you can unquote column +\link[rlang:topic-inject]{quasiquotation} (you can unquote column names or column positions).} \item{into}{Names of new variables to create as character vector. diff --git a/man/unite-methods.Rd b/man/unite-methods.Rd index fb19305..0309420 100644 --- a/man/unite-methods.Rd +++ b/man/unite-methods.Rd @@ -9,9 +9,9 @@ \item{col}{The name of the new column, as a string or symbol. This argument is passed by expression and supports -\link[rlang:nse-force]{quasiquotation} (you can unquote strings +\link[rlang:topic-inject]{quasiquotation} (you can unquote strings and symbols). The name is captured from the expression with -\code{\link[rlang:nse-defuse]{rlang::ensym()}} (note that this kind of interface where +\code{\link[rlang:defusing-advanced]{rlang::ensym()}} (note that this kind of interface where symbols do not represent actual objects is now discouraged in the tidyverse; we support it here for backward compatibility).} diff --git a/man/unnest-methods.Rd b/man/unnest-methods.Rd index abd7ddb..7787fa8 100644 --- a/man/unnest-methods.Rd +++ b/man/unnest-methods.Rd @@ -20,7 +20,6 @@ .preserve ) - unnest_single_cell_experiment( data, cols, @@ -77,7 +76,6 @@ stripped. This makes \code{names_sep} roughly symmetric between nesting and unne \item{.sep}{tidyr::unnest} - \item{.preserve}{See tidyr::unnest} \item{sep}{tidyr::unnest} From cb058a3db191953ac128afda520d556d943f629f Mon Sep 17 00:00:00 2001 From: stemangiola Date: Fri, 20 May 2022 18:19:59 +1000 Subject: [PATCH 09/34] version UP --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 8cac75d..e1ee1ee 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: tidySingleCellExperiment Title: Brings SingleCellExperiment to the Tidyverse -Version: 1.7.0 +Version: 1.7.1 Authors@R: c(person("Stefano", "Mangiola", email = "mangiolastefano@gmail.com", role = c("aut", "cre")) ) Description: tidySingleCellExperiment is an adapter that abstracts the 'SingleCellExperiment' container From 875ede19f01ab29fac18e7c0b10fe7f5b7b29bac Mon Sep 17 00:00:00 2001 From: stemangiola Date: Fri, 20 May 2022 18:31:25 +1000 Subject: [PATCH 10/34] fix bug tidybulk reference --- DESCRIPTION | 2 +- R/print_method.R | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index e1ee1ee..14f4203 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: tidySingleCellExperiment Title: Brings SingleCellExperiment to the Tidyverse -Version: 1.7.1 +Version: 1.7.2 Authors@R: c(person("Stefano", "Mangiola", email = "mangiolastefano@gmail.com", role = c("aut", "cre")) ) Description: tidySingleCellExperiment is an adapter that abstracts the 'SingleCellExperiment' container diff --git a/R/print_method.R b/R/print_method.R index 2c4805c..b9caead 100755 --- a/R/print_method.R +++ b/R/print_method.R @@ -119,8 +119,8 @@ print.SingleCellExperiment <- function(x, ..., n = NULL, width = NULL, n_extra = x |> as_tibble(n_dimensions_to_return = 5) |> vctrs::new_data_frame(class = c("tidySingleCellExperiment", "tbl")) %>% - tidybulk:::add_attr( nrow(x), "number_of_features") %>% - tidybulk:::add_attr( assays(x) %>% names , "assay_names") %>% + add_attr( nrow(x), "number_of_features") %>% + add_attr( assays(x) %>% names , "assay_names") %>% print() invisible(x) From 19ff7eff8a61619ddb131d750032cd710aa0943e Mon Sep 17 00:00:00 2001 From: stemangiola Date: Fri, 20 May 2022 18:57:03 +1000 Subject: [PATCH 11/34] typo --- R/print_method.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/print_method.R b/R/print_method.R index b9caead..5217396 100755 --- a/R/print_method.R +++ b/R/print_method.R @@ -40,7 +40,7 @@ tbl_format_header.tidySingleCellExperiment <- function(x, setup, ...){ # Add further info single-cell append(sprintf( - "\033[90m Features=%s | cells=%s | Assays=%s\033[39m", + "\033[90m Features=%s | Cells=%s | Assays=%s\033[39m", number_of_features, nrow(x), assay_names %>% paste(collapse=", ") From 665217e2c202a711b3deddc4b0d0d34e8ecd0c82 Mon Sep 17 00:00:00 2001 From: stemangiola Date: Fri, 20 May 2022 19:35:22 +1000 Subject: [PATCH 12/34] fix CHECK --- DESCRIPTION | 3 ++- NAMESPACE | 1 + R/print_method.R | 28 +++++++++++++++++++++++----- man/tbl_format_header-methods.Rd | 19 +++++++++++++++++++ 4 files changed, 45 insertions(+), 6 deletions(-) create mode 100644 man/tbl_format_header-methods.Rd diff --git a/DESCRIPTION b/DESCRIPTION index 14f4203..57b580b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -5,7 +5,7 @@ Version: 1.7.2 Authors@R: c(person("Stefano", "Mangiola", email = "mangiolastefano@gmail.com", role = c("aut", "cre")) ) Description: tidySingleCellExperiment is an adapter that abstracts the 'SingleCellExperiment' container - in the form of tibble and allows the data manipulation, plotting and nesting using 'tidyverse' + in the form of tibble and allows the data manipulation, plotting and nesting using 'tidyverse'. License: GPL-3 Depends: R (>= 4.0.0), @@ -27,6 +27,7 @@ Imports: S4Vectors, tidyselect, ellipsis, + vctrs, pillar, stringr, cli, diff --git a/NAMESPACE b/NAMESPACE index f18e25d..992c1af 100755 --- a/NAMESPACE +++ b/NAMESPACE @@ -154,3 +154,4 @@ importFrom(tidyr,unnest) importFrom(tidyselect,eval_select) importFrom(ttservice,join_features) importFrom(utils,tail) +importFrom(vctrs,new_data_frame) diff --git a/R/print_method.R b/R/print_method.R index 5217396..25f2969 100755 --- a/R/print_method.R +++ b/R/print_method.R @@ -1,14 +1,31 @@ # This file is a replacement of the unexported functions in the tibble package, in order to specify "tibble abstraction in the header" -#' tbl_format_header +#' Format the header of a tibble +#' +#' @description +#' `r lifecycle::badge("experimental")` +#' +#' For easier customization, the formatting of a tibble is split +#' into three components: header, body, and footer. +#' The `tbl_format_header()` method is responsible for formatting the header +#' of a tibble. +#' +#' Override this method if you need to change the appearance +#' of the entire header. +#' If you only need to change or extend the components shown in the header, +#' override or extend [tbl_sum()] for your class which is called by the +#' default method. #' -#' @rdname tbl_format_header-methods -#' @name tbl_format_header #' @importFrom pillar tbl_format_header +#' @inheritParams tbl_format_body +#' @inherit tbl_format_body return #' -#' @noRd +#' @rdname tbl_format_header-methods +#' @name tbl_format_header #' #' @export +#' +NULL NULL #' @importFrom rlang names2 @@ -113,12 +130,13 @@ NULL #' @rdname print #' @importFrom cli cat_line #' @importFrom SingleCellExperiment counts +#' @importFrom vctrs new_data_frame #' @export print.SingleCellExperiment <- function(x, ..., n = NULL, width = NULL, n_extra = NULL) { x |> as_tibble(n_dimensions_to_return = 5) |> - vctrs::new_data_frame(class = c("tidySingleCellExperiment", "tbl")) %>% + new_data_frame(class = c("tidySingleCellExperiment", "tbl")) %>% add_attr( nrow(x), "number_of_features") %>% add_attr( assays(x) %>% names , "assay_names") %>% print() diff --git a/man/tbl_format_header-methods.Rd b/man/tbl_format_header-methods.Rd new file mode 100644 index 0000000..a1f630c --- /dev/null +++ b/man/tbl_format_header-methods.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/print_method.R +\name{tbl_format_header} +\alias{tbl_format_header} +\title{Format the header of a tibble} +\description{ +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} + +For easier customization, the formatting of a tibble is split +into three components: header, body, and footer. +The \code{tbl_format_header()} method is responsible for formatting the header +of a tibble. + +Override this method if you need to change the appearance +of the entire header. +If you only need to change or extend the components shown in the header, +override or extend \code{\link[=tbl_sum]{tbl_sum()}} for your class which is called by the +default method. +} From dbfd4eb40173201fc102fdf224a607072b412c58 Mon Sep 17 00:00:00 2001 From: stemangiola Date: Fri, 20 May 2022 18:16:51 +1000 Subject: [PATCH 13/34] use new pillar methods --- R/print_method.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/print_method.R b/R/print_method.R index 25f2969..7404c0f 100755 --- a/R/print_method.R +++ b/R/print_method.R @@ -26,7 +26,6 @@ #' @export #' NULL -NULL #' @importFrom rlang names2 #' @importFrom pillar align @@ -136,9 +135,11 @@ print.SingleCellExperiment <- function(x, ..., n = NULL, width = NULL, n_extra = x |> as_tibble(n_dimensions_to_return = 5) |> + new_data_frame(class = c("tidySingleCellExperiment", "tbl")) %>% add_attr( nrow(x), "number_of_features") %>% add_attr( assays(x) %>% names , "assay_names") %>% + print() invisible(x) From 4edb3e7a580834ff54d1043e290de13476497552 Mon Sep 17 00:00:00 2001 From: stemangiola Date: Fri, 20 May 2022 18:19:59 +1000 Subject: [PATCH 14/34] version UP --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 57b580b..050c389 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -5,7 +5,7 @@ Version: 1.7.2 Authors@R: c(person("Stefano", "Mangiola", email = "mangiolastefano@gmail.com", role = c("aut", "cre")) ) Description: tidySingleCellExperiment is an adapter that abstracts the 'SingleCellExperiment' container - in the form of tibble and allows the data manipulation, plotting and nesting using 'tidyverse'. + in the form of a tibble and allows the data manipulation, plotting and nesting using 'tidyverse'. License: GPL-3 Depends: R (>= 4.0.0), From 2bde91babe3b58abf2dcd8d71d2a6392d8dc0b9d Mon Sep 17 00:00:00 2001 From: stemangiola Date: Fri, 20 May 2022 18:31:25 +1000 Subject: [PATCH 15/34] fix bug tidybulk reference --- R/print_method.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/print_method.R b/R/print_method.R index 7404c0f..4d8022a 100755 --- a/R/print_method.R +++ b/R/print_method.R @@ -134,7 +134,7 @@ NULL print.SingleCellExperiment <- function(x, ..., n = NULL, width = NULL, n_extra = NULL) { x |> - as_tibble(n_dimensions_to_return = 5) |> + as_tibble(n_dimensions_to_return = 5 ) |> new_data_frame(class = c("tidySingleCellExperiment", "tbl")) %>% add_attr( nrow(x), "number_of_features") %>% From 8b2e38d4f57e2b693efd43b01792a72b3fcb5bf9 Mon Sep 17 00:00:00 2001 From: stemangiola Date: Fri, 20 May 2022 19:35:22 +1000 Subject: [PATCH 16/34] fix CHECK --- R/print_method.R | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/R/print_method.R b/R/print_method.R index 4d8022a..3e2c586 100755 --- a/R/print_method.R +++ b/R/print_method.R @@ -25,6 +25,10 @@ #' #' @export #' +<<<<<<< HEAD +======= +NULL +>>>>>>> fix CHECK NULL #' @importFrom rlang names2 From 4936f898f93b568e60ba4a824ec754e25b21e765 Mon Sep 17 00:00:00 2001 From: stemangiola Date: Tue, 26 Jul 2022 09:03:02 +1000 Subject: [PATCH 17/34] dummy change --- R/print_method.R | 4 ---- 1 file changed, 4 deletions(-) diff --git a/R/print_method.R b/R/print_method.R index 3e2c586..4d8022a 100755 --- a/R/print_method.R +++ b/R/print_method.R @@ -25,10 +25,6 @@ #' #' @export #' -<<<<<<< HEAD -======= -NULL ->>>>>>> fix CHECK NULL #' @importFrom rlang names2 From b4862418310db31bea9eb406cdc820acb030f663 Mon Sep 17 00:00:00 2001 From: stemangiola Date: Tue, 26 Jul 2022 10:28:24 +1000 Subject: [PATCH 18/34] print restore show --- DESCRIPTION | 2 +- R/methods.R | 89 ++++++++++++++++++++++++++-------------------------- man/print.Rd | 2 +- 3 files changed, 47 insertions(+), 46 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 050c389..99fd472 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -57,7 +57,7 @@ Biarch: true biocViews: AssayDomain, Infrastructure, RNASeq, DifferentialExpression, GeneExpression, Normalization, Clustering, QualityControl, Sequencing Encoding: UTF-8 LazyData: true -RoxygenNote: 7.1.2 +RoxygenNote: 7.2.0 Roxygen: list(markdown = TRUE) URL: https://github.com/stemangiola/tidySingleCellExperiment BugReports: https://github.com/stemangiola/tidySingleCellExperiment/issues diff --git a/R/methods.R b/R/methods.R index 15d4977..b8f30de 100755 --- a/R/methods.R +++ b/R/methods.R @@ -1,57 +1,24 @@ -setClass("tidySingleCellExperiment", contains = "SingleCellExperiment") - -#' tidy for SingleCellExperiment -#' -#' @param object A SingleCellExperiment object -#' -#' @return A tidySingleCellExperiment object -#' -#' @name tidy -#' -#' @examples -#' -#' tidySingleCellExperiment::pbmc_small -#' @export -tidy <- function(object) { - UseMethod("tidy", object) -} - -#' @importFrom methods as -#' @importFrom lifecycle deprecate_warn -#' -#' @param object A SingleCellExperiment object -#' -#' @export -tidy.SingleCellExperiment <- function(object) { - - # DEPRECATE - deprecate_warn( - when = "1.1.1", - what = "tidy()", - details = "tidySingleCellExperiment says: tidy() is not needed anymore." - ) - - object -} setMethod( f = "show", signature = "SingleCellExperiment", definition = function(object) { - if (isTRUE(x = getOption(x = "restore_SingleCellExperiment_show", default = FALSE))) { - f <- getMethod( - f = "show", - signature = "SingleCellExperiment", - where = asNamespace(ns = "SingleCellExperiment") + if ( + isTRUE(x = getOption(x = "restore_SingleCellExperiment_show", default = FALSE)) + ) { + f <-getMethod( + f = "show", + signature = "SummarizedExperiment", + where = asNamespace(ns = "SummarizedExperiment") ) f(object = object) - } else { - object %>% - print() - } + + } else { print(object) } } ) +setClass("tidySingleCellExperiment", contains = "SingleCellExperiment") + #' Extract and join information for features. #' #' @@ -130,5 +97,39 @@ setMethod("join_features", "SingleCellExperiment", function(.data, }) +#' tidy for SingleCellExperiment +#' +#' @param object A SingleCellExperiment object +#' +#' @return A tidySingleCellExperiment object +#' +#' @name tidy +#' +#' @examples +#' +#' tidySingleCellExperiment::pbmc_small +#' @export +tidy <- function(object) { + UseMethod("tidy", object) +} + +#' @importFrom methods as +#' @importFrom lifecycle deprecate_warn +#' +#' @param object A SingleCellExperiment object +#' +#' @export +tidy.SingleCellExperiment <- function(object) { + + # DEPRECATE + deprecate_warn( + when = "1.1.1", + what = "tidy()", + details = "tidySingleCellExperiment says: tidy() is not needed anymore." + ) + + object +} + diff --git a/man/print.Rd b/man/print.Rd index 53d4817..bad962f 100644 --- a/man/print.Rd +++ b/man/print.Rd @@ -51,7 +51,7 @@ Only the first 5 reduced dimensions are displayed, while all of them are queriab The following options are used by the tibble and pillar packages to format and print \code{tbl_df} objects. -Used by the formatting workhorse \code{trunc_mat()} and, therefore, +Used by the formatting workhorse \code{trunc_mat()} and therefore, indirectly, by \code{print.tbl()}. \itemize{ \item \code{tibble.print_max}: Row number threshold: Maximum number of rows printed. From ebc07b8524f53526354d4693fe51c621faa55217 Mon Sep 17 00:00:00 2001 From: stemangiola Date: Fri, 20 May 2022 18:16:51 +1000 Subject: [PATCH 19/34] use new pillar methods --- R/print_method.R | 2 ++ 1 file changed, 2 insertions(+) diff --git a/R/print_method.R b/R/print_method.R index 25f2969..e6527f6 100755 --- a/R/print_method.R +++ b/R/print_method.R @@ -136,9 +136,11 @@ print.SingleCellExperiment <- function(x, ..., n = NULL, width = NULL, n_extra = x |> as_tibble(n_dimensions_to_return = 5) |> + new_data_frame(class = c("tidySingleCellExperiment", "tbl")) %>% add_attr( nrow(x), "number_of_features") %>% add_attr( assays(x) %>% names , "assay_names") %>% + print() invisible(x) From 7c84cc2deddb96ab9219d0e97528a491c35618bc Mon Sep 17 00:00:00 2001 From: stemangiola Date: Fri, 20 May 2022 18:19:59 +1000 Subject: [PATCH 20/34] version UP --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 6e34c07..d68f383 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -5,7 +5,7 @@ Version: 1.7.3 Authors@R: c(person("Stefano", "Mangiola", email = "mangiolastefano@gmail.com", role = c("aut", "cre")) ) Description: tidySingleCellExperiment is an adapter that abstracts the 'SingleCellExperiment' container - in the form of tibble and allows the data manipulation, plotting and nesting using 'tidyverse'. + in the form of a tibble and allows the data manipulation, plotting and nesting using 'tidyverse'. License: GPL-3 Depends: R (>= 4.1.0), From feb66b137a1f44ec29423ff7d2523ab8c9ce2d56 Mon Sep 17 00:00:00 2001 From: stemangiola Date: Fri, 20 May 2022 18:31:25 +1000 Subject: [PATCH 21/34] fix bug tidybulk reference --- R/print_method.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/print_method.R b/R/print_method.R index e6527f6..1214e05 100755 --- a/R/print_method.R +++ b/R/print_method.R @@ -137,6 +137,7 @@ print.SingleCellExperiment <- function(x, ..., n = NULL, width = NULL, n_extra = x |> as_tibble(n_dimensions_to_return = 5) |> + new_data_frame(class = c("tidySingleCellExperiment", "tbl")) %>% add_attr( nrow(x), "number_of_features") %>% add_attr( assays(x) %>% names , "assay_names") %>% From 4dd7cba1daf1536753cb699bc0d5ed4d2df0d22c Mon Sep 17 00:00:00 2001 From: stemangiola Date: Fri, 20 May 2022 19:35:22 +1000 Subject: [PATCH 22/34] fix CHECK --- R/print_method.R | 1 - 1 file changed, 1 deletion(-) diff --git a/R/print_method.R b/R/print_method.R index 1214e05..e6527f6 100755 --- a/R/print_method.R +++ b/R/print_method.R @@ -137,7 +137,6 @@ print.SingleCellExperiment <- function(x, ..., n = NULL, width = NULL, n_extra = x |> as_tibble(n_dimensions_to_return = 5) |> - new_data_frame(class = c("tidySingleCellExperiment", "tbl")) %>% add_attr( nrow(x), "number_of_features") %>% add_attr( assays(x) %>% names , "assay_names") %>% From 7c1dc6e4192021cacf4045d20a4a5ffa8e63f271 Mon Sep 17 00:00:00 2001 From: stemangiola Date: Tue, 26 Jul 2022 09:03:02 +1000 Subject: [PATCH 23/34] dummy change --- R/print_method.R | 1 - 1 file changed, 1 deletion(-) diff --git a/R/print_method.R b/R/print_method.R index e6527f6..7404c0f 100755 --- a/R/print_method.R +++ b/R/print_method.R @@ -26,7 +26,6 @@ #' @export #' NULL -NULL #' @importFrom rlang names2 #' @importFrom pillar align From 481aebee90f8d2365c18a3b7560914b358109500 Mon Sep 17 00:00:00 2001 From: stemangiola Date: Tue, 26 Jul 2022 10:28:24 +1000 Subject: [PATCH 24/34] print restore show --- DESCRIPTION | 2 +- R/methods.R | 89 ++++++++++++++++++++++++++-------------------------- man/print.Rd | 2 +- 3 files changed, 47 insertions(+), 46 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index d68f383..be8f047 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -57,7 +57,7 @@ Biarch: true biocViews: AssayDomain, Infrastructure, RNASeq, DifferentialExpression, GeneExpression, Normalization, Clustering, QualityControl, Sequencing Encoding: UTF-8 LazyData: true -RoxygenNote: 7.1.2 +RoxygenNote: 7.2.0 Roxygen: list(markdown = TRUE) URL: https://github.com/stemangiola/tidySingleCellExperiment BugReports: https://github.com/stemangiola/tidySingleCellExperiment/issues diff --git a/R/methods.R b/R/methods.R index 15d4977..b8f30de 100755 --- a/R/methods.R +++ b/R/methods.R @@ -1,57 +1,24 @@ -setClass("tidySingleCellExperiment", contains = "SingleCellExperiment") - -#' tidy for SingleCellExperiment -#' -#' @param object A SingleCellExperiment object -#' -#' @return A tidySingleCellExperiment object -#' -#' @name tidy -#' -#' @examples -#' -#' tidySingleCellExperiment::pbmc_small -#' @export -tidy <- function(object) { - UseMethod("tidy", object) -} - -#' @importFrom methods as -#' @importFrom lifecycle deprecate_warn -#' -#' @param object A SingleCellExperiment object -#' -#' @export -tidy.SingleCellExperiment <- function(object) { - - # DEPRECATE - deprecate_warn( - when = "1.1.1", - what = "tidy()", - details = "tidySingleCellExperiment says: tidy() is not needed anymore." - ) - - object -} setMethod( f = "show", signature = "SingleCellExperiment", definition = function(object) { - if (isTRUE(x = getOption(x = "restore_SingleCellExperiment_show", default = FALSE))) { - f <- getMethod( - f = "show", - signature = "SingleCellExperiment", - where = asNamespace(ns = "SingleCellExperiment") + if ( + isTRUE(x = getOption(x = "restore_SingleCellExperiment_show", default = FALSE)) + ) { + f <-getMethod( + f = "show", + signature = "SummarizedExperiment", + where = asNamespace(ns = "SummarizedExperiment") ) f(object = object) - } else { - object %>% - print() - } + + } else { print(object) } } ) +setClass("tidySingleCellExperiment", contains = "SingleCellExperiment") + #' Extract and join information for features. #' #' @@ -130,5 +97,39 @@ setMethod("join_features", "SingleCellExperiment", function(.data, }) +#' tidy for SingleCellExperiment +#' +#' @param object A SingleCellExperiment object +#' +#' @return A tidySingleCellExperiment object +#' +#' @name tidy +#' +#' @examples +#' +#' tidySingleCellExperiment::pbmc_small +#' @export +tidy <- function(object) { + UseMethod("tidy", object) +} + +#' @importFrom methods as +#' @importFrom lifecycle deprecate_warn +#' +#' @param object A SingleCellExperiment object +#' +#' @export +tidy.SingleCellExperiment <- function(object) { + + # DEPRECATE + deprecate_warn( + when = "1.1.1", + what = "tidy()", + details = "tidySingleCellExperiment says: tidy() is not needed anymore." + ) + + object +} + diff --git a/man/print.Rd b/man/print.Rd index 53d4817..bad962f 100644 --- a/man/print.Rd +++ b/man/print.Rd @@ -51,7 +51,7 @@ Only the first 5 reduced dimensions are displayed, while all of them are queriab The following options are used by the tibble and pillar packages to format and print \code{tbl_df} objects. -Used by the formatting workhorse \code{trunc_mat()} and, therefore, +Used by the formatting workhorse \code{trunc_mat()} and therefore, indirectly, by \code{print.tbl()}. \itemize{ \item \code{tibble.print_max}: Row number threshold: Maximum number of rows printed. From de2c7537aa9d5ec2b09c15efd11f05c615b2461a Mon Sep 17 00:00:00 2001 From: stemangiola Date: Fri, 20 May 2022 18:16:51 +1000 Subject: [PATCH 25/34] use new pillar methods --- R/print_method.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/print_method.R b/R/print_method.R index 7404c0f..f10e087 100755 --- a/R/print_method.R +++ b/R/print_method.R @@ -62,6 +62,7 @@ tbl_format_header.tidySingleCellExperiment <- function(x, setup, ...){ assay_names %>% paste(collapse=", ") ), after = 1) } + style_subtle(pillar___format_comment(header, width = setup$width)) } From 9e5e47c6be2a3cd0da37821eb82b72b337d00fb0 Mon Sep 17 00:00:00 2001 From: stemangiola Date: Fri, 20 May 2022 18:19:59 +1000 Subject: [PATCH 26/34] version UP --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index be8f047..d6b80d6 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -5,7 +5,7 @@ Version: 1.7.3 Authors@R: c(person("Stefano", "Mangiola", email = "mangiolastefano@gmail.com", role = c("aut", "cre")) ) Description: tidySingleCellExperiment is an adapter that abstracts the 'SingleCellExperiment' container - in the form of a tibble and allows the data manipulation, plotting and nesting using 'tidyverse'. + in the form of tibble and allows the data manipulation, plotting and nesting using 'tidyverse'. License: GPL-3 Depends: R (>= 4.1.0), From d79710d91c9676e45a5ad413350e477a4036dee0 Mon Sep 17 00:00:00 2001 From: stemangiola Date: Fri, 20 May 2022 18:31:25 +1000 Subject: [PATCH 27/34] fix bug tidybulk reference --- R/print_method.R | 1 - 1 file changed, 1 deletion(-) diff --git a/R/print_method.R b/R/print_method.R index f10e087..8606c6b 100755 --- a/R/print_method.R +++ b/R/print_method.R @@ -136,7 +136,6 @@ print.SingleCellExperiment <- function(x, ..., n = NULL, width = NULL, n_extra = x |> as_tibble(n_dimensions_to_return = 5) |> - new_data_frame(class = c("tidySingleCellExperiment", "tbl")) %>% add_attr( nrow(x), "number_of_features") %>% add_attr( assays(x) %>% names , "assay_names") %>% From 72599e1b06dc6c4a9a1fb524c4d5b22baee63627 Mon Sep 17 00:00:00 2001 From: stemangiola Date: Fri, 20 May 2022 19:35:22 +1000 Subject: [PATCH 28/34] fix CHECK --- R/print_method.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/print_method.R b/R/print_method.R index 8606c6b..3492e93 100755 --- a/R/print_method.R +++ b/R/print_method.R @@ -27,6 +27,7 @@ #' NULL + #' @importFrom rlang names2 #' @importFrom pillar align #' @importFrom pillar get_extent From b02d844d85706a49f0dbe442a4739aaf689f0dc5 Mon Sep 17 00:00:00 2001 From: stemangiola Date: Fri, 20 May 2022 18:16:51 +1000 Subject: [PATCH 29/34] use new pillar methods --- R/print_method.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/print_method.R b/R/print_method.R index 3492e93..847aa85 100755 --- a/R/print_method.R +++ b/R/print_method.R @@ -137,6 +137,7 @@ print.SingleCellExperiment <- function(x, ..., n = NULL, width = NULL, n_extra = x |> as_tibble(n_dimensions_to_return = 5) |> + new_data_frame(class = c("tidySingleCellExperiment", "tbl")) %>% add_attr( nrow(x), "number_of_features") %>% add_attr( assays(x) %>% names , "assay_names") %>% From 3c85828f5b5c4da89762b0dac9421e37771b7f76 Mon Sep 17 00:00:00 2001 From: stemangiola Date: Fri, 20 May 2022 18:19:59 +1000 Subject: [PATCH 30/34] version UP --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index d6b80d6..be8f047 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -5,7 +5,7 @@ Version: 1.7.3 Authors@R: c(person("Stefano", "Mangiola", email = "mangiolastefano@gmail.com", role = c("aut", "cre")) ) Description: tidySingleCellExperiment is an adapter that abstracts the 'SingleCellExperiment' container - in the form of tibble and allows the data manipulation, plotting and nesting using 'tidyverse'. + in the form of a tibble and allows the data manipulation, plotting and nesting using 'tidyverse'. License: GPL-3 Depends: R (>= 4.1.0), From f6eefa7baadd00688fa54770bb76b2f253b93884 Mon Sep 17 00:00:00 2001 From: stemangiola Date: Fri, 20 May 2022 18:31:25 +1000 Subject: [PATCH 31/34] fix bug tidybulk reference --- R/print_method.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/print_method.R b/R/print_method.R index 847aa85..176b5cf 100755 --- a/R/print_method.R +++ b/R/print_method.R @@ -136,7 +136,7 @@ NULL print.SingleCellExperiment <- function(x, ..., n = NULL, width = NULL, n_extra = NULL) { x |> - as_tibble(n_dimensions_to_return = 5) |> + as_tibble(n_dimensions_to_return = 5 ) |> new_data_frame(class = c("tidySingleCellExperiment", "tbl")) %>% add_attr( nrow(x), "number_of_features") %>% From 209b6d49e5b223dc3ce26b918a5fac1c174a0154 Mon Sep 17 00:00:00 2001 From: stemangiola Date: Fri, 20 May 2022 19:35:22 +1000 Subject: [PATCH 32/34] fix CHECK --- R/print_method.R | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/R/print_method.R b/R/print_method.R index 176b5cf..099d5c0 100755 --- a/R/print_method.R +++ b/R/print_method.R @@ -25,6 +25,10 @@ #' #' @export #' +<<<<<<< HEAD +======= +NULL +>>>>>>> fix CHECK NULL From 683d4480dd1d050ea9084d59d0ed70c010d1291f Mon Sep 17 00:00:00 2001 From: stemangiola Date: Tue, 26 Jul 2022 09:03:02 +1000 Subject: [PATCH 33/34] dummy change --- R/print_method.R | 4 ---- 1 file changed, 4 deletions(-) diff --git a/R/print_method.R b/R/print_method.R index 099d5c0..176b5cf 100755 --- a/R/print_method.R +++ b/R/print_method.R @@ -25,10 +25,6 @@ #' #' @export #' -<<<<<<< HEAD -======= -NULL ->>>>>>> fix CHECK NULL From c5991fe8c7110320b6d11c8bfbf20bf5e5210ce4 Mon Sep 17 00:00:00 2001 From: stemangiola Date: Tue, 26 Jul 2022 10:45:14 +1000 Subject: [PATCH 34/34] version UP --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index be8f047..0a72513 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: tidySingleCellExperiment Title: Brings SingleCellExperiment to the Tidyverse -Version: 1.7.3 +Version: 1.7.4 Authors@R: c(person("Stefano", "Mangiola", email = "mangiolastefano@gmail.com", role = c("aut", "cre")) ) Description: tidySingleCellExperiment is an adapter that abstracts the 'SingleCellExperiment' container