Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions R/print_method.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ tbl_format_header.tidySingleCellExperiment <- function(x, setup, ...) {

number_of_features <- x |> attr("number_of_features")
assay_names <- x |> attr("assay_names")
altExpNames <- x |> attr("altExpNames")


# Change name
named_header <- setup$tbl_sum
Expand All @@ -33,11 +35,14 @@ tbl_format_header.tidySingleCellExperiment <- function(x, setup, ...) {
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),
paste(assay_names, collapse=", ")
), after=1)

append(sprintf(
"\033[90m Features=%s | Cells=%s | Assays=%s | altExpNames=%s\033[39m",
number_of_features, nrow(x),
paste(assay_names, collapse=", "),
if(length(nchar(altExpNames)) > 0) paste(altExpNames, collapse=", ") else {"NULL"}
), after=1)

}
style_subtle(pillar___format_comment(header, width=setup$width))
}
Expand All @@ -58,13 +63,15 @@ tbl_format_header.tidySingleCellExperiment <- function(x, setup, ...) {
#'
#' @importFrom vctrs new_data_frame
#' @importFrom SummarizedExperiment assayNames
#' @importFrom SingleCellExperiment altExpNames
#' @export
print.SingleCellExperiment <- function(x, ..., n=NULL, width=NULL) {
x |>
as_tibble(n_dimensions_to_return=5) |>
new_data_frame(class=c("tidySingleCellExperiment", "tbl")) %>%
add_attr(nrow(x), "number_of_features") %>%
add_attr(assayNames(x), "assay_names") %>%
add_attr(altExpNames(x), "altExpNames") %>%
print()

invisible(x)
Expand Down
Loading