Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ S3method(ctl_new_rowid_pillar,SE_print_abstraction)
S3method(print,SummarizedExperiment)
S3method(tbl_format_header,SE_print_abstraction)
S3method(tbl_format_header,tidySummarizedExperiment)
export(test_tidy_message)
export(tidy_message)
importClassesFrom(SummarizedExperiment,SummarizedExperiment)
importFrom(S4Vectors,coolcat)
importFrom(S4Vectors,metadata)
Expand Down
45 changes: 45 additions & 0 deletions R/tidyprint_message.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#' Print styled tidyprint messages
#'
#' @param message A character string containing the message to display.
#' @param type The type of message to display ("info", "success", "warning", "danger"). Defaults to "info".
#' @export
#' @examples
#' tidy_message("Loading data...", type = "info")
#' tidy_message("Data loaded successfully!", type = "success")
tidy_message <- function(message, type = c("info", "success", "warning", "danger")) {
type <- match.arg(type, choices = c("info", "success", "warning", "danger"))

calling_package <- utils::packageName(parent.frame())
prefix_package <- ifelse(is.null(calling_package), "Console", calling_package)

# prefix <- switch(
# type,
# info = paste0(prefix_package, " says"),
# success = paste0(prefix_package, " success"),
# warning = paste0(prefix_package, " warning"),
# danger = paste0(prefix_package, " error")
# )

prefix = paste0(prefix_package, " says")

style_fun <- switch(
type,
info = cli::cli_alert_info,
success = cli::cli_alert_success,
warning = cli::cli_alert_warning,
danger = cli::cli_alert_danger
)

style_fun("{prefix}: {message}")
}

#' Test tidy_message function
#' @export
#' @examples
#' test_tidy_message()
test_tidy_message <- function() {
tidy_message("This is an informational message send within tidyprint package.")
tidy_message("Operation completed successfully!", type = "success")
tidy_message("Potential issue detected.", type = "warning")
tidy_message("Operation failed.", type = "danger")
}
59 changes: 22 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ tidyprint

<!-- badges: end -->

**tidyprint** is an R package that provides multiple printing styles for
`SummarizedExperiment` objects. You can choose among:
**tidyprint** is an R package that provides a centralised tidy display
strategy for biological data (e.g. SummarizedExperiment), and
centralised messaging styles for the `tidyomics` packages. To facilitate
the discussion about data display, we compare here four data diplay:

1. **SummarizedExperiment** (default): Standard R/SummarizedExperiment
printing style.
1. **SummarizedExperiment**: Standard R/SummarizedExperiment printing
style.

2. **tidyprint_1**: Newly designed tibble abstraction, combines styles
from **tidySummarizedExperiment** and **plyxp**
Expand All @@ -27,17 +29,17 @@ it easy to switch between these printing styles.

## 1. Installation

You need the \`\` package to install from GitHub. If you don’t have it,
install via:
You need the `remotes` package to install from GitHub. If you don’t have
it, install via:

``` r
install.packages("devtools")
install.packages("remotes")
```

Then install **tidyprint** from GitHub:

``` r
devtools::install_github("tidyomics/tidyprint")
remotes::install_github("tidyomics/tidyprint")
```

------------------------------------------------------------------------
Expand Down Expand Up @@ -126,24 +128,6 @@ se_airway %>% print(design = "tidyprint_1")
#> 309552 ENSG00000283123 SRR1039521 | 0 | | treated N061011 GSM1275875
```

You can also limit the number of displayed rows by setting `n_print` (or
a similar argument in your code):

``` r

se_airway %>% print(design = "tidyprint_1", n_print = 5)
#> # A SummarizedExperiment-tibble abstraction:
#> # Features=38694 | Samples=8 | Assays=counts
#> .features .samples `|` counts `|` `|` dex celltype geo_id
#> <chr> <chr> <|> <chr> <|> <|> <chr> <chr> <chr>
#> 1 ENSG00000000003 SRR1039508 | 723 | | control N61311 GSM1275862
#> 2 ENSG00000000005 SRR1039508 | 0 | | control N61311 GSM1275862
#> 3 ENSG00000000419 SRR1039508 | 467 | | control N61311 GSM1275862
#> --------------- ---------- -- --- -- -- ------- ------- ----------
#> 309551 ENSG00000283120 SRR1039521 | 0 | | treated N061011 GSM1275875
#> 309552 ENSG00000283123 SRR1039521 | 0 | | treated N061011 GSM1275875
```

### 2.4 **tidySummarizedExperiment**

Use the “tidySummarizedExperiment” design to view your data in a
Expand Down Expand Up @@ -194,20 +178,21 @@ se_airway %>% print(design = "plyxp")
#> 10 ENSG00000283123 SRR1039521 | 0 | | treated N061011 GSM1275875
```

You can also limit the number of displayed rows by setting `n_print` (or
a similar argument in your code):
# Messaging function

We integrated a messaging function providing standardized, visually
appealing messages for packages within the tidyomics ecosystem. It
automatically detects the calling package to provide contextualized
messaging, such as “tidyprint says” or “tidybulk says”, enhancing
consistency and readability across projects.

``` r

se_airway %>% print(design = "plyxp", n_print = 5)
#> # A tibble: 5 × 9
#> .features .samples `|` counts `|` `|` dex celltype geo_id
#> <chr> <chr> <|> <dbl> <|> <|> <chr> <chr> <chr>
#> 1 ENSG00000000003 SRR1039508 | 723 | | control N61311 GSM1275862
#> 2 ENSG00000000005 SRR1039508 | 0 | | control N61311 GSM1275862
#> 3 ENSG00000000419 SRR1039508 | 467 | | control N61311 GSM1275862
#> 4 ENSG00000283120 SRR1039521 | 0 | | treated N061011 GSM1275875
#> 5 ENSG00000283123 SRR1039521 | 0 | | treated N061011 GSM1275875
test_tidy_message()
#> ℹ tidyprint says: This is an informational message send within tidyprint package.
#> ✔ tidyprint says: Operation completed successfully!
#> ! tidyprint says: Potential issue detected.
#> ✖ tidyprint says: Operation failed.
```

## Session info
Expand Down
14 changes: 14 additions & 0 deletions man/test_tidy_message.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions man/tidy_message.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions tests/testthat/test-print_methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,8 @@ test_that("tidyprint_1 print works", {
test_that("Invalid design throws an error", {
expect_error(print(se_airway, design = "invalidDesign"), "should be one of")
})

# test for message
test_that("tidy_message works correctly", {
expect_message(tidy_message("Test info message"), "says: Test info message")
})
26 changes: 10 additions & 16 deletions vignettes/Introduction.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ find_figure <- function(names){

<!-- badges: end -->

**tidyprint** is an R package that provides multiple printing styles for `SummarizedExperiment` objects. You can choose among:
**tidyprint** is an R package that provides a centralised tidy display strategy for biological data (e.g. SummarizedExperiment), and centralised messaging styles for the `tidyomics` packages. To facilitate the discussion about data display, we compare here four data diplay:

1. **SummarizedExperiment** (default): Standard R/SummarizedExperiment printing style.
1. **SummarizedExperiment**: Standard R/SummarizedExperiment printing style.

2. **tidyprint_1**: Newly designed tibble abstraction, combines styles from **tidySummarizedExperiment** and **plyxp**

Expand All @@ -73,16 +73,16 @@ Depending on your workflow and desired console output, `tidyprint` makes it easy

## 1. Installation

You need the \`\` package to install from GitHub. If you don’t have it, install via:
You need the `remotes` package to install from GitHub. If you don’t have it, install via:

```{r eval=FALSE}
install.packages("devtools")
install.packages("remotes")
```

Then install **tidyprint** from GitHub:

```{r eval=FALSE}
devtools::install_github("tidyomics/tidyprint")
remotes::install_github("tidyomics/tidyprint")
```

------------------------------------------------------------------------
Expand Down Expand Up @@ -137,15 +137,6 @@ se_airway %>% print(design = "tidyprint_1")

```

You can also limit the number of displayed rows by setting `n_print` (or a similar argument in your code):

```{r}

se_airway %>% print(design = "tidyprint_1", n_print = 5)

```



### 2.4 **tidySummarizedExperiment**

Expand All @@ -169,14 +160,17 @@ se_airway %>% print(design = "plyxp")

```

You can also limit the number of displayed rows by setting `n_print` (or a similar argument in your code):
# Messaging function

We integrated a messaging function providing standardized, visually appealing messages for packages within the tidyomics ecosystem. It automatically detects the calling package to provide contextualized messaging, such as "tidyprint says" or "tidybulk says", enhancing consistency and readability across projects.

```{r}

se_airway %>% print(design = "plyxp", n_print = 5)
test_tidy_message()

```


## Session info

```{r}
Expand Down
58 changes: 24 additions & 34 deletions vignettes/Introduction.html
Original file line number Diff line number Diff line change
Expand Up @@ -362,11 +362,13 @@ <h1 class="title toc-ignore">tidyprint</h1>
<!-- badges: start -->
<p><a href="https://lifecycle.r-lib.org/articles/stages.html#experimental"><img src="data:image/sv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VvbWV0cmljUHJlY2lzaW9uIiBmb250LXNpemU9IjExMCI+CiAgICAgICAgPHRleHQgYXJpYS1oaWRkZW49InRydWUiIHg9IjI4NSIgeT0iMTUwIiBmaWxsPSIjMDEwMTAxIiBmaWxsLW9wYWNpdHk9Ii4zIiB0cmFuc2Zvcm09InNjYWxlKC4xKSIgdGV4dExlbmd0aD0iNDUwIj5saWZlY3ljbGU8L3RleHQ+CiAgICAgICAgPHRleHQgeD0iMjg1IiB5PSIxNDAiIHRyYW5zZm9ybT0ic2NhbGUoLjEpIiBmaWxsPSIjZmZmIiB0ZXh0TGVuZ3RoPSI0NTAiPmxpZmVjeWNsZTwvdGV4dD4KICAgICAgICA8dGV4dCBhcmlhLWhpZGRlbj0idHJ1ZSIgeD0iOTU1IiB5PSIxNTAiIGZpbGw9IiMwMTAxMDEiIGZpbGwtb3BhY2l0eT0iLjMiIHRyYW5zZm9ybT0ic2NhbGUoLjEpIiB0ZXh0TGVuZ3RoPSI3MzAiPmV4cGVyaW1lbnRhbDwvdGV4dD4KICAgICAgICA8dGV4dCB4PSI5NTUiIHk9IjE0MCIgdHJhbnNmb3JtPSJzY2FsZSguMSkiIGZpbGw9IiNmZmYiIHRleHRMZW5ndGg9IjczMCI+ZXhwZXJpbWVudGFsPC90ZXh0PgogICAgPC9nPgo8L3N2Zz4K" alt="Lifecycle:experimental" /></a></p>
<!-- badges: end -->
<p><strong>tidyprint</strong> is an R package that provides multiple
printing styles for <code>SummarizedExperiment</code> objects. You can
choose among:</p>
<p><strong>tidyprint</strong> is an R package that provides a
centralised tidy display strategy for biological data
(e.g. SummarizedExperiment), and centralised messaging styles for the
<code>tidyomics</code> packages. To facilitate the discussion about data
display, we compare here four data diplay:</p>
<ol style="list-style-type: decimal">
<li><p><strong>SummarizedExperiment</strong> (default): Standard
<li><p><strong>SummarizedExperiment</strong>: Standard
R/SummarizedExperiment printing style.</p></li>
<li><p><strong>tidyprint_1</strong>: Newly designed tibble abstraction,
combines styles from <strong>tidySummarizedExperiment</strong> and
Expand All @@ -382,11 +384,11 @@ <h1 class="title toc-ignore">tidyprint</h1>
<hr />
<div id="installation" class="section level2">
<h2>1. Installation</h2>
<p>You need the `` package to install from GitHub. If you don’t have it,
install via:</p>
<pre class="r"><code>install.packages(&quot;devtools&quot;)</code></pre>
<p>You need the <code>remotes</code> package to install from GitHub. If
you don’t have it, install via:</p>
<pre class="r"><code>install.packages(&quot;remotes&quot;)</code></pre>
<p>Then install <strong>tidyprint</strong> from GitHub:</p>
<pre class="r"><code>devtools::install_github(&quot;tidyomics/tidyprint&quot;)</code></pre>
<pre class="r"><code>remotes::install_github(&quot;tidyomics/tidyprint&quot;)</code></pre>
<hr />
</div>
<div id="demo" class="section level2">
Expand Down Expand Up @@ -461,20 +463,6 @@ <h3>2.3 <strong>tidyprint_1</strong></h3>
#&gt; 309550 ENSG00000283119 SRR1039521 | 0 | | treated N061011 GSM1275875
#&gt; 309551 ENSG00000283120 SRR1039521 | 0 | | treated N061011 GSM1275875
#&gt; 309552 ENSG00000283123 SRR1039521 | 0 | | treated N061011 GSM1275875</code></pre>
<p>You can also limit the number of displayed rows by setting
<code>n_print</code> (or a similar argument in your code):</p>
<pre class="r"><code>
se_airway %&gt;% print(design = &quot;tidyprint_1&quot;, n_print = 5)
#&gt; # A SummarizedExperiment-tibble abstraction:
#&gt; # Features=38694 | Samples=8 | Assays=counts
#&gt; .features .samples `|` counts `|` `|` dex celltype geo_id
#&gt; &lt;chr&gt; &lt;chr&gt; &lt;|&gt; &lt;chr&gt; &lt;|&gt; &lt;|&gt; &lt;chr&gt; &lt;chr&gt; &lt;chr&gt;
#&gt; 1 ENSG00000000003 SRR1039508 | 723 | | control N61311 GSM1275862
#&gt; 2 ENSG00000000005 SRR1039508 | 0 | | control N61311 GSM1275862
#&gt; 3 ENSG00000000419 SRR1039508 | 467 | | control N61311 GSM1275862
#&gt; --------------- ---------- -- --- -- -- ------- ------- ----------
#&gt; 309551 ENSG00000283120 SRR1039521 | 0 | | treated N061011 GSM1275875
#&gt; 309552 ENSG00000283123 SRR1039521 | 0 | | treated N061011 GSM1275875</code></pre>
</div>
<div id="tidysummarizedexperiment" class="section level3">
<h3>2.4 <strong>tidySummarizedExperiment</strong></h3>
Expand Down Expand Up @@ -519,20 +507,21 @@ <h3>2.5 <strong>plyxp</strong></h3>
#&gt; 8 ENSG00000283119 SRR1039521 | 0 | | treated N061011 GSM1275875
#&gt; 9 ENSG00000283120 SRR1039521 | 0 | | treated N061011 GSM1275875
#&gt; 10 ENSG00000283123 SRR1039521 | 0 | | treated N061011 GSM1275875</code></pre>
<p>You can also limit the number of displayed rows by setting
<code>n_print</code> (or a similar argument in your code):</p>
<pre class="r"><code>
se_airway %&gt;% print(design = &quot;plyxp&quot;, n_print = 5)
#&gt; # A tibble: 5 × 9
#&gt; .features .samples `|` counts `|` `|` dex celltype geo_id
#&gt; &lt;chr&gt; &lt;chr&gt; &lt;|&gt; &lt;dbl&gt; &lt;|&gt; &lt;|&gt; &lt;chr&gt; &lt;chr&gt; &lt;chr&gt;
#&gt; 1 ENSG00000000003 SRR1039508 | 723 | | control N61311 GSM1275862
#&gt; 2 ENSG00000000005 SRR1039508 | 0 | | control N61311 GSM1275862
#&gt; 3 ENSG00000000419 SRR1039508 | 467 | | control N61311 GSM1275862
#&gt; 4 ENSG00000283120 SRR1039521 | 0 | | treated N061011 GSM1275875
#&gt; 5 ENSG00000283123 SRR1039521 | 0 | | treated N061011 GSM1275875</code></pre>
</div>
</div>
<div id="messaging-function" class="section level1">
<h1>Messaging function</h1>
<p>We integrated a messaging function providing standardized, visually
appealing messages for packages within the tidyomics ecosystem. It
automatically detects the calling package to provide contextualized
messaging, such as “tidyprint says” or “tidybulk says”, enhancing
consistency and readability across projects.</p>
<pre class="r"><code>
test_tidy_message()
#&gt; ℹ tidyprint says: This is an informational message send within tidyprint package.
#&gt; ✔ tidyprint says: Operation completed successfully!
#&gt; ! tidyprint says: Potential issue detected.
#&gt; ✖ tidyprint says: Operation failed.</code></pre>
<div id="session-info" class="section level2">
<h2>Session info</h2>
<pre class="r"><code>
Expand Down Expand Up @@ -592,6 +581,7 @@ <h2>Session info</h2>
#&gt; [55] knitr_1.49 htmltools_0.5.8.1
#&gt; [57] rmarkdown_2.29 compiler_4.4.0</code></pre>
</div>
</div>



Expand Down
Loading