Skip to content

Commit

Permalink
Merge pull request #47 from stemangiola/print_hotifx
Browse files Browse the repository at this point in the history
Print hotifx
  • Loading branch information
stemangiola authored Jul 26, 2022
2 parents 6e29a0d + c5991fe commit 0197567
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 57 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]",
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),
Expand Down Expand Up @@ -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
89 changes: 45 additions & 44 deletions R/methods.R
Original file line number Diff line number Diff line change
@@ -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.
#'
#'
Expand Down Expand Up @@ -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
}



14 changes: 5 additions & 9 deletions R/print_method.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#' @export
#'
NULL
NULL

#' @importFrom rlang names2
#' @importFrom pillar align
Expand Down Expand Up @@ -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))

}
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)
}








2 changes: 1 addition & 1 deletion man/print.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0197567

Please sign in to comment.