plyxp
uses pillar for its printing.
If you want to change how your S4 object is printed within
plyxp
's print method, consider writing a method for
this function.
To print S4 objects in a tibble, plyxp
hacks a custom
integer vector built from vctrs
where
the S4 object lives in an attribute named "phantomData".
You can create your own S4 phantom vector with vec_phantom()
.
This function is not used outside of printing for plyxp
The default method for formatting a vec_phantom()
is to call
showAsCell()
.
Usage
vec_phantom(x)
plyxp_pillar_format(x, ...)
show_tidy(x, ...)
use_show_tidy()
use_show_default()
Arguments
- x
The S4 object
- ...
other arguments passed from
pillar_shaft
Value
plyxp_pillar_format
-> formatted version of your S4 vector
vec_phantom
-> integer vector with arbitrary object in phatomData
attribute.
tidy printing
By default, plyxp
will not affect the show method for
SummarizedExperiment
objects. In order to use a tibble abstraction, use
use_show_tidy()
to enable or use_show_default()
to disable this feature.
These functions are called for their side effects, modifying the global
option "show_SummarizedExperiment_as_tibble_abstraction".
To show an object as the tibble abstraction regardless of the set option,
use the S3 generic show_tidy(...)
.
Examples
if(require("IRanges")) {
ilist <- IRanges::IntegerList(list(c(1L,2L,3L),c(5L,6L)))
phantom <- vec_phantom(ilist)
pillar::pillar_shaft(phantom)
plyxp_pillar_format.CompressedIntegerList <- function(x) {
sprintf("Int: [%i]", lengths(x))
}
pillar::pillar_shaft(phantom)
rm(plyxp_pillar_format.CompressedIntegerList)
}
#> Loading required package: IRanges
#> Loading required package: BiocGenerics
#>
#> Attaching package: ‘BiocGenerics’
#> The following objects are masked from ‘package:stats’:
#>
#> IQR, mad, sd, var, xtabs
#> The following objects are masked from ‘package:base’:
#>
#> Filter, Find, Map, Position, Reduce, anyDuplicated, aperm, append,
#> as.data.frame, basename, cbind, colnames, dirname, do.call,
#> duplicated, eval, evalq, get, grep, grepl, intersect, is.unsorted,
#> lapply, mapply, match, mget, order, paste, pmax, pmax.int, pmin,
#> pmin.int, rank, rbind, rownames, sapply, setdiff, table, tapply,
#> union, unique, unsplit, which.max, which.min
#> Loading required package: S4Vectors
#> Loading required package: stats4
#>
#> Attaching package: ‘S4Vectors’
#> The following object is masked from ‘package:utils’:
#>
#> findMatches
#> The following objects are masked from ‘package:base’:
#>
#> I, expand.grid, unname
# default printing
se_simple
#> # A SummarizedExperiment-tibble Abstraction: 5 × 4
#> .features .samples | counts logcounts | gene length direction | sample
#> <chr> <chr> | <int> <dbl> | <chr> <int> <chr> | <chr>
#> 1 row_1 col_1 | 14 2.64 | g1 1 - | s1
#> 2 row_2 col_1 | 19 2.94 | g2 24 + | s1
#> 3 row_3 col_1 | 16 2.77 | g3 60 + | s1
#> 4 row_4 col_1 | 11 2.40 | g4 39 - | s1
#> 5 row_5 col_1 | 18 2.89 | g5 37 + | s1
#> … … … … … … … … …
#> n-4 row_1 col_4 | 9 2.20 | g1 1 - | s4
#> n-3 row_2 col_4 | 4 1.39 | g2 24 + | s4
#> n-2 row_3 col_4 | 20 3.00 | g3 60 + | s4
#> n-1 row_4 col_4 | 3 1.10 | g4 39 - | s4
#> n row_5 col_4 | 5 1.61 | g5 37 + | s4
#> # ℹ n = 20
#> # ℹ 1 more variable: condition <chr>
# use `plyxp` tibble abstraction
use_show_tidy()
se_simple
#> # A SummarizedExperiment-tibble Abstraction: 5 × 4
#> .features .samples | counts logcounts | gene length direction | sample
#> <chr> <chr> | <int> <dbl> | <chr> <int> <chr> | <chr>
#> 1 row_1 col_1 | 14 2.64 | g1 1 - | s1
#> 2 row_2 col_1 | 19 2.94 | g2 24 + | s1
#> 3 row_3 col_1 | 16 2.77 | g3 60 + | s1
#> 4 row_4 col_1 | 11 2.40 | g4 39 - | s1
#> 5 row_5 col_1 | 18 2.89 | g5 37 + | s1
#> … … … … … … … … …
#> n-4 row_1 col_4 | 9 2.20 | g1 1 - | s4
#> n-3 row_2 col_4 | 4 1.39 | g2 24 + | s4
#> n-2 row_3 col_4 | 20 3.00 | g3 60 + | s4
#> n-1 row_4 col_4 | 3 1.10 | g4 39 - | s4
#> n row_5 col_4 | 5 1.61 | g5 37 + | s4
#> # ℹ n = 20
#> # ℹ 1 more variable: condition <chr>
# restore default print
use_show_default()
se_simple
#> # A SummarizedExperiment-tibble Abstraction: 5 × 4
#> .features .samples | counts logcounts | gene length direction | sample
#> <chr> <chr> | <int> <dbl> | <chr> <int> <chr> | <chr>
#> 1 row_1 col_1 | 14 2.64 | g1 1 - | s1
#> 2 row_2 col_1 | 19 2.94 | g2 24 + | s1
#> 3 row_3 col_1 | 16 2.77 | g3 60 + | s1
#> 4 row_4 col_1 | 11 2.40 | g4 39 - | s1
#> 5 row_5 col_1 | 18 2.89 | g5 37 + | s1
#> … … … … … … … … …
#> n-4 row_1 col_4 | 9 2.20 | g1 1 - | s4
#> n-3 row_2 col_4 | 4 1.39 | g2 24 + | s4
#> n-2 row_3 col_4 | 20 3.00 | g3 60 + | s4
#> n-1 row_4 col_4 | 3 1.10 | g4 39 - | s4
#> n row_5 col_4 | 5 1.61 | g5 37 + | s4
#> # ℹ n = 20
#> # ℹ 1 more variable: condition <chr>
# explicitly using tibble abstraction
show_tidy(se_simple)
#> # A SummarizedExperiment-tibble Abstraction: 5 × 4
#> .features .samples | counts logcounts | gene length direction | sample
#> <chr> <chr> | <int> <dbl> | <chr> <int> <chr> | <chr>
#> 1 row_1 col_1 | 14 2.64 | g1 1 - | s1
#> 2 row_2 col_1 | 19 2.94 | g2 24 + | s1
#> 3 row_3 col_1 | 16 2.77 | g3 60 + | s1
#> 4 row_4 col_1 | 11 2.40 | g4 39 - | s1
#> 5 row_5 col_1 | 18 2.89 | g5 37 + | s1
#> … … … … … … … … …
#> n-4 row_1 col_4 | 9 2.20 | g1 1 - | s4
#> n-3 row_2 col_4 | 4 1.39 | g2 24 + | s4
#> n-2 row_3 col_4 | 20 3.00 | g3 60 + | s4
#> n-1 row_4 col_4 | 3 1.10 | g4 39 - | s4
#> n row_5 col_4 | 5 1.61 | g5 37 + | s4
#> # ℹ n = 20
#> # ℹ 1 more variable: condition <chr>