diff --git a/R/print_method.R b/R/print_method.R index a345881..2c56469 100755 --- a/R/print_method.R +++ b/R/print_method.R @@ -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 @@ -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)) } @@ -58,6 +63,7 @@ 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 |> @@ -65,6 +71,7 @@ print.SingleCellExperiment <- function(x, ..., n=NULL, width=NULL) { 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)