diff --git a/R/print_method.R b/R/print_method.R index bdef4ae..cea49e6 100755 --- a/R/print_method.R +++ b/R/print_method.R @@ -18,6 +18,7 @@ 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 @@ -30,11 +31,12 @@ 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)) } @@ -52,6 +54,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 |> @@ -59,7 +62,9 @@ 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) -} +} \ No newline at end of file