Package 'tidyprint'

Title: Custom Print Methods for SummarizedExperiment
Description: Provides customized print methods for 'SummarizedExperiment' objects to enhance readability and usability within a tidy workflow. It offers consistent, tidyverse-aligned console displays, including alternative tibble abstractions for large genomic data to improve discoverability and interpretation. The package also includes unified, contextual messaging utilities intended for the 'tidyomics' ecosystem.
Authors: Chen Zhan [aut, cre] (ORCID: <https://orcid.org/0000-0002-4794-8339>)
Maintainer: Chen Zhan <[email protected]>
License: GPL-3
Version: 1.1.0
Built: 2026-05-30 09:45:14 UTC
Source: https://github.com/bioc/tidyprint

Help Index


tidyprint: Custom Print Methods for SummarizedExperiment

Description

Provides customized print methods for SummarizedExperiment objects to enhance readability and usability within a tidy workflow. It offers consistent, tidyverse-aligned console displays, including alternative tibble abstractions for large genomic data to improve discoverability and interpretation. The package also includes unified, contextual messaging utilities intended for the 'tidyomics' ecosystem.

Value

This package provides S3 methods and functions that enhance the display and manipulation of SummarizedExperiment objects. The main functions return:

  • print.SummarizedExperiment: Returns the input object invisibly

  • as_tibble.SummarizedExperiment: Returns a tibble with combined assay and metadata

  • tidy_message: Returns NULL invisibly (prints styled messages)

Key Features

  • Custom Print Methods: Alternative display formats for SummarizedExperiment objects

  • Tidyverse Integration: Seamless integration with tidyverse workflows

  • Scalable Visualization: Adaptive displays for large genomic datasets

  • Standardized Messaging: Consistent messaging utilities for the tidyomics ecosystem

Print Designs

The package provides multiple print designs for SummarizedExperiment objects:

  • "SummarizedExperiment": Standard Bioconductor summary display

  • "tidyprint_1": Compact tibble abstraction with adaptive separator rows

  • "tidySummarizedExperiment": Legacy tidySummarizedExperiment style

  • "plyxp": Compact top/bottom row display

Messaging System

The tidy_message function provides standardized, visually appealing messages for packages within the tidyomics ecosystem. It automatically detects the calling package to provide contextualized messaging.

Data Conversion

The as_tibble method converts SummarizedExperiment objects to tibble format, combining assay data with sample and feature metadata in a long format suitable for tidyverse workflows.

Author(s)

Chen Zhan [email protected]

References

tidyprint: Custom Print Methods for SummarizedExperiment https://github.com/tidyomics/tidyprint

See Also


Convert SummarizedExperiment to tibble

Description

Converts a SummarizedExperiment object to a tibble format, combining assay data with sample and feature metadata in a long format suitable for tidyverse workflows.

Usage

## S3 method for class 'SummarizedExperiment'
as_tibble(
  x,
  ...,
  .name_repair = c("check_unique", "unique", "universal", "minimal"),
  rownames = pkgconfig::get_config("tibble::rownames", NULL)
)

Arguments

x

A SummarizedExperiment object to convert.

...

Additional arguments passed to internal conversion functions.

.name_repair

Treatment of problematic column names. See as_tibble for details.

rownames

Either NULL or a string giving the name of a column to use as rownames. See as_tibble for details.

Details

This method provides a bridge between Bioconductor's SummarizedExperiment objects and tidyverse data manipulation workflows. The conversion creates a long-format tibble where each row represents a feature-sample combination, making it suitable for filtering, grouping, and other tidyverse operations.

Value

A tibble containing the assay data combined with sample and feature metadata. The structure includes:

  • Feature identifiers (from rownames or rowData)

  • Sample identifiers (from colnames or colData)

  • Assay values (one column per assay)

  • Sample metadata (from colData)

  • Feature metadata (from rowData)

See Also

SummarizedExperiment, as_tibble

Examples

## Not run: 
  library(tidyprint)
  data(se_airway)
  as_tibble(se_airway)

## End(Not run)

Demonstrate tidy_message usage

Description

Runs through examples of the tidy_message() function for all supported message types ("info", "success", "warning", "danger"). Intended for demonstration and testing only.

Usage

demo_tidy_message()

Value

Invisibly returns NULL. Called for side effects (messages printed to the console).

Examples

demo_tidy_message()

Format covariate header by distributing label across covariate columns

Description

Format covariate header by distributing label across covariate columns

Usage

format_covariate_header(
  separator_row,
  printed_colnames,
  covariate_names,
  number_of_total_rows,
  label = "COVARIATES"
)

Arguments

separator_row

The separator row with column widths

printed_colnames

The printed column names

covariate_names

The names of covariate columns

number_of_total_rows

The total number of rows for spacing

label

The label to distribute (default: "COVARIATES")

Value

Formatted header string


Print method for SummarizedExperiment with tidyprint styles

Description

Provides a compact tibble-like display for a SummarizedExperiment object that preserves assay values and key covariates with a separator band when the table is truncated.

Usage

## S3 method for class 'SummarizedExperiment'
print(x, n = 10, ...)

Arguments

x

A SummarizedExperiment object to print.

n

Integer (default 10). Approximate number of rows to show in the display. When the total cells shown are fewer than n, the full table is printed and the separator row is suppressed.

...

Additional arguments passed to internal printers (currently unused).

Details

This method constructs a tibble abstraction for SummarizedExperiment data with columns: .feature, .sample, assay columns, a vertical separator "|", followed by selected colData and rowData fields. When the output is truncated, an adaptive dash-only separator row is inserted after the first half block of rows. Additional indication of colData is provided as well.

By default, this method uses the standard SummarizedExperiment print format. To enable the tidy print format, use tidy_print_on. To check the current status, use tidy_print_enabled.

Value

x is returned invisibly after printing.

See Also

SummarizedExperiment, as_tibble

Examples

## Not run: 
  library(tidyprint)
  print(se_airway)                         # compact tibble display
  print(se_airway, n = 20)                # with custom row count

## End(Not run)

Example SummarizedExperiment dataset

Description

Scaled RNA-seq counts for airway samples packaged as a SummarizedExperiment.

Usage

data(se_airway)

Format

A SummarizedExperiment object with:

assays

A matrix of scaled counts

colData

Sample metadata (cell type, treatment, etc.)

Source

airway package


Custom header for SE_print_abstraction

Description

Formats the header using pillar’s formatting context so it aligns with the tibble body and adds a centered COVARIATES banner.

Usage

## S3 method for class 'SE_print_abstraction'
tbl_format_header(x, setup, ...)

Arguments

x

An object of class SE_print_abstraction.

setup

A pillar formatting setup (list) passed by pillar; contains things like the rendering width and the pre-rendered first body line (setup$body).

...

Unused; present for S3 method consistency.

Value

A character vector of header lines to be displayed above the table. (pillar prints the returned character; this function has no side effects beyond returning those lines.)


Print a styled tidyprint message

Description

Prints a message to the console with a consistent tidyomics style. A package-specific prefix is automatically added based on the calling package name, followed by the message text. Different message types are displayed using appropriate styles from the cli package.

Usage

tidy_message(message, type = c("info", "success", "warning", "danger"))

Arguments

message

A character string containing the message to display.

type

The type of message to display. One of "info", "success", "warning", or "danger". Defaults to "info".

Value

Invisibly returns NULL. Called for side effects (printing a styled message to the console).

Examples

tidy_message("Loading data...", type = "info")
tidy_message("Data loaded successfully!", type = "success")

Enable or disable tidy print for SummarizedExperiment objects

Description

These functions control whether SummarizedExperiment objects use the custom tidy print format or the standard Bioconductor print format. By default, standard print is used.

Usage

tidy_print_on(remember = FALSE)

tidy_print_off(remember = FALSE)

tidy_print_enabled()

Arguments

remember

Logical (default FALSE). If TRUE, saves the setting to a local cache file so it persists across R sessions. If FALSE, the setting only affects the current R session.

Details

The tidy print format provides a compact tibble-like display that combines assay data with sample and feature metadata. The standard print format is the default Bioconductor display.

When tidy print is enabled, SummarizedExperiment objects will display using the custom tibble abstraction format. When disabled (default), they will use the standard SummarizedExperiment print method from the Bioconductor package.

The setting is stored in the global R options as tidyprint.use_tidy_print. When remember = TRUE, the setting is also saved to a cache file in the user's R configuration directory, which takes precedence over the option. The cache file location is determined by tools::R_user_dir("tidyprint", "config").

Value

  • tidy_print_on(): Returns TRUE invisibly after enabling tidy print

  • tidy_print_off(): Returns FALSE invisibly after disabling tidy print

  • tidy_print_enabled(): Returns a logical indicating whether tidy print is currently enabled

See Also

print.SummarizedExperiment

Examples

# Check current status
  tidy_print_enabled()

  # Enable tidy print (session only)
  tidy_print_on()

  # Enable tidy print and remember the setting (saved to cache)
  tidy_print_on(remember = TRUE)

  # Disable tidy print (use standard print)
  tidy_print_off()

  # Disable tidy print and remember the setting
  tidy_print_off(remember = TRUE)