Skip to content

Commit f168ab6

Browse files
committed
update doc
1 parent 252b743 commit f168ab6

File tree

1 file changed

+56
-6
lines changed

1 file changed

+56
-6
lines changed

R/print_methods.R

Lines changed: 56 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,50 @@
1+
#' Print method for SummarizedExperiment with tidyprint styles
2+
#'
3+
#' Provides alternative console displays for a \link[SummarizedExperiment]{SummarizedExperiment}
4+
#' object. The default shows the standard Bioconductor summary. The
5+
#' `"tidyprint_1"` design prints a compact tibble-like abstraction that
6+
#' preserves assay values and key covariates with a separator band when
7+
#' the table is truncated.
8+
#'
9+
#' @param x A \code{SummarizedExperiment} object to print.
10+
#' @param design Either a character string or integer selecting the print style.
11+
#' Character choices are:
12+
#' \itemize{
13+
#' \item \code{"SummarizedExperiment"} — standard Bioconductor summary.
14+
#' \item \code{"tidyprint_1"} — tidyprint tibble abstraction (top/bottom slices,
15+
#' assays | colData | rowData blocks, with an adaptive separator row).
16+
#' }
17+
#' Numeric shortcuts are mapped as:
18+
#' \itemize{
19+
#' \item \code{1} \eqn{\to} \code{"SummarizedExperiment"}
20+
#' \item \code{2} \eqn{\to} \code{"tidyprint_1"}
21+
#' }
22+
#' @param n_print Integer (default \code{10}). Approximate number of rows to show
23+
#' in the \code{"tidyprint_1"} display. When the total cells shown are fewer
24+
#' than \code{n_print}, the full table is printed and the separator row is
25+
#' suppressed.
26+
#' @param ... Additional arguments passed to internal printers (currently unused).
27+
#'
28+
#' @details
29+
#' The \code{"tidyprint_1"} design constructs a tibble abstraction for SummarizedExperiment
30+
#' data with columns:
31+
#' \code{.feature}, \code{.sample}, assay columns, a vertical separator \code{"|"},
32+
#' followed by selected \code{colData} and \code{rowData} fields. When the output
33+
#' is truncated, an adaptive dash-only separator row is inserted after the first
34+
#' half block of rows. Additional indication of \code{colData} is provided as well.
35+
#'
36+
#' @return \code{x} is returned \emph{invisibly} after printing.
37+
#'
38+
#' @seealso \link[SummarizedExperiment]{SummarizedExperiment}, \link[tibble]{as_tibble}
39+
#'
40+
#' @examples
41+
#' \dontrun{
42+
#' library(tidyprint)
43+
#' print(se_airway) # default
44+
#' print(se_airway, design = "tidyprint_1") # tidyprint abstraction
45+
#' print(se_airway, design = 2) # numeric alias for "tidyprint_1"
46+
#' }
47+
#'
148
#' @importClassesFrom SummarizedExperiment SummarizedExperiment
249
#' @importFrom methods setMethod
350

@@ -11,21 +58,24 @@
1158
#' @importFrom magrittr `%>%`
1259
#' @importFrom dplyr if_else mutate across
1360
#' @export
14-
print.SummarizedExperiment <- function(x, design = 4, n_print = 10, ...) {
61+
print.SummarizedExperiment <- function(x, design = 2, n_print = 10, ...) {
1562

1663
# Match the user-supplied design argument to one of the valid choices:
1764
if (is.numeric(design)) {
1865
# Allowed numeric -> corresponding design
19-
design_map <- c("SummarizedExperiment", "tidySummarizedExperiment", "plyxp", "tidyprint_1")
20-
66+
# design_map <- c("SummarizedExperiment", "tidySummarizedExperiment", "plyxp", "tidyprint_1")
67+
design_map <- c("SummarizedExperiment", "tidyprint_1")
68+
2169
# Validate numeric input
22-
if (!design %in% 1:4) {
23-
stop("Invalid numeric design argument. Choose 1, 2, 3, or 4.")
70+
if (!design %in% 1:2) {
71+
stop("Invalid numeric design argument. Choose 1 or 2.")
2472
}
2573
design <- design_map[design]
2674
}
2775

28-
design <- match.arg(design, c("SummarizedExperiment", "tidyprint_1", "tidySummarizedExperiment", "plyxp"))
76+
# design <- match.arg(design, c("SummarizedExperiment", "tidyprint_1", "tidySummarizedExperiment", "plyxp"))
77+
design <- match.arg(design, c("SummarizedExperiment", "tidyprint_1"))
78+
2979

3080
if (!inherits(x, "SummarizedExperiment")) {
3181
stop("The object provided is not a SummarizedExperiment.")

0 commit comments

Comments
 (0)