diff --git a/DESCRIPTION b/DESCRIPTION index 6e34c07..0a72513 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,11 +1,11 @@ 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 - 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), @@ -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/R/print_method.R b/R/print_method.R index 25f2969..f7fdc94 100755 --- a/R/print_method.R +++ b/R/print_method.R @@ -26,7 +26,6 @@ #' @export #' NULL -NULL #' @importFrom rlang names2 #' @importFrom pillar align @@ -63,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)) } @@ -91,7 +91,7 @@ tbl_format_header.tidySingleCellExperiment <- function(x, setup, ...){ #' #' The following options are used by the tibble and pillar packages #' to format and print `tbl_df` objects. -#' Used by the formatting workhorse `trunc_mat()` and, therefore, +#' Used by the formatting workhorse `trunc_mat()` and therefore, #' indirectly, by `print.tbl()`. #' #' * `tibble.print_max`: Row number threshold: Maximum number of rows printed. @@ -135,19 +135,15 @@ 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") %>% add_attr( assays(x) %>% names , "assay_names") %>% + print() invisible(x) } - - - - - - 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.