Skip to content

Commit 824df8e

Browse files
authored
Merge branch 'main' into stemangiola-patch-1
2 parents 21476fe + f831b57 commit 824df8e

File tree

8 files changed

+145
-72
lines changed

8 files changed

+145
-72
lines changed

NAMESPACE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ S3method(ctl_new_rowid_pillar,SE_print_abstraction)
55
S3method(print,SummarizedExperiment)
66
S3method(tbl_format_header,SE_print_abstraction)
77
S3method(tbl_format_header,tidySummarizedExperiment)
8+
export(test_tidy_message)
9+
export(tidy_message)
810
importClassesFrom(SummarizedExperiment,SummarizedExperiment)
911
importFrom(S4Vectors,coolcat)
1012
importFrom(S4Vectors,metadata)

R/tidyprint_message.R

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#' Print styled tidyprint messages
2+
#'
3+
#' @param message A character string containing the message to display.
4+
#' @param type The type of message to display ("info", "success", "warning", "danger"). Defaults to "info".
5+
#' @export
6+
#' @examples
7+
#' tidy_message("Loading data...", type = "info")
8+
#' tidy_message("Data loaded successfully!", type = "success")
9+
tidy_message <- function(message, type = c("info", "success", "warning", "danger")) {
10+
type <- match.arg(type, choices = c("info", "success", "warning", "danger"))
11+
12+
calling_package <- utils::packageName(parent.frame())
13+
prefix_package <- ifelse(is.null(calling_package), "Console", calling_package)
14+
15+
# prefix <- switch(
16+
# type,
17+
# info = paste0(prefix_package, " says"),
18+
# success = paste0(prefix_package, " success"),
19+
# warning = paste0(prefix_package, " warning"),
20+
# danger = paste0(prefix_package, " error")
21+
# )
22+
23+
prefix = paste0(prefix_package, " says")
24+
25+
style_fun <- switch(
26+
type,
27+
info = cli::cli_alert_info,
28+
success = cli::cli_alert_success,
29+
warning = cli::cli_alert_warning,
30+
danger = cli::cli_alert_danger
31+
)
32+
33+
style_fun("{prefix}: {message}")
34+
}
35+
36+
#' Test tidy_message function
37+
#' @export
38+
#' @examples
39+
#' test_tidy_message()
40+
test_tidy_message <- function() {
41+
tidy_message("This is an informational message send within tidyprint package.")
42+
tidy_message("Operation completed successfully!", type = "success")
43+
tidy_message("Potential issue detected.", type = "warning")
44+
tidy_message("Operation failed.", type = "danger")
45+
}

README.md

Lines changed: 22 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ tidyprint
77

88
<!-- badges: end -->
99

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

13-
1. **SummarizedExperiment** (default): Standard R/SummarizedExperiment
14-
printing style.
15+
1. **SummarizedExperiment**: Standard R/SummarizedExperiment printing
16+
style.
1517

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

2830
## 1. Installation
2931

30-
You need the \`\` package to install from GitHub. If you don’t have it,
31-
install via:
32+
You need the `remotes` package to install from GitHub. If you don’t have
33+
it, install via:
3234

3335
``` r
34-
install.packages("devtools")
36+
install.packages("remotes")
3537
```
3638

3739
Then install **tidyprint** from GitHub:
3840

3941
``` r
40-
devtools::install_github("tidyomics/tidyprint")
42+
remotes::install_github("tidyomics/tidyprint")
4143
```
4244

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

129-
You can also limit the number of displayed rows by setting `n_print` (or
130-
a similar argument in your code):
131-
132-
``` r
133-
134-
se_airway %>% print(design = "tidyprint_1", n_print = 5)
135-
#> # A SummarizedExperiment-tibble abstraction:
136-
#> # Features=38694 | Samples=8 | Assays=counts
137-
#> .features .samples `|` counts `|` `|` dex celltype geo_id
138-
#> <chr> <chr> <|> <chr> <|> <|> <chr> <chr> <chr>
139-
#> 1 ENSG00000000003 SRR1039508 | 723 | | control N61311 GSM1275862
140-
#> 2 ENSG00000000005 SRR1039508 | 0 | | control N61311 GSM1275862
141-
#> 3 ENSG00000000419 SRR1039508 | 467 | | control N61311 GSM1275862
142-
#> --------------- ---------- -- --- -- -- ------- ------- ----------
143-
#> 309551 ENSG00000283120 SRR1039521 | 0 | | treated N061011 GSM1275875
144-
#> 309552 ENSG00000283123 SRR1039521 | 0 | | treated N061011 GSM1275875
145-
```
146-
147131
### 2.4 **tidySummarizedExperiment**
148132

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

197-
You can also limit the number of displayed rows by setting `n_print` (or
198-
a similar argument in your code):
181+
# Messaging function
182+
183+
We integrated a messaging function providing standardized, visually
184+
appealing messages for packages within the tidyomics ecosystem. It
185+
automatically detects the calling package to provide contextualized
186+
messaging, such as “tidyprint says” or “tidybulk says”, enhancing
187+
consistency and readability across projects.
199188

200189
``` r
201190

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

213198
## Session info

man/test_tidy_message.Rd

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/tidy_message.Rd

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-print_methods.R

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,8 @@ test_that("tidyprint_1 print works", {
5555
test_that("Invalid design throws an error", {
5656
expect_error(print(se_airway, design = "invalidDesign"), "should be one of")
5757
})
58+
59+
# test for message
60+
test_that("tidy_message works correctly", {
61+
expect_message(tidy_message("Test info message"), "says: Test info message")
62+
})

vignettes/Introduction.Rmd

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Depending on your workflow and desired console output, `tidyprint` makes it easy
7373

7474
## 1. Installation
7575

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

7878
```{r eval=FALSE}
7979
install.packages("remotes")
@@ -159,6 +159,18 @@ se_airway %>% print(design = "plyxp")
159159
160160
```
161161

162+
163+
# Messaging function
164+
165+
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.
166+
167+
```{r}
168+
169+
test_tidy_message()
170+
171+
```
172+
173+
162174
## Session info
163175

164176
```{r}

vignettes/Introduction.html

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -362,11 +362,13 @@ <h1 class="title toc-ignore">tidyprint</h1>
362362
<!-- badges: start -->
363363
<p><a href="https://lifecycle.r-lib.org/articles/stages.html#experimental"><img src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi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g9IjI4NSIgeT0iMTUwIiBmaWxsPSIjMDEwMTAxIiBmaWxsLW9wYWNpdHk9Ii4zIiB0cmFuc2Zvcm09InNjYWxlKC4xKSIgdGV4dExlbmd0aD0iNDUwIj5saWZlY3ljbGU8L3RleHQ+CiAgICAgICAgPHRleHQgeD0iMjg1IiB5PSIxNDAiIHRyYW5zZm9ybT0ic2NhbGUoLjEpIiBmaWxsPSIjZmZmIiB0ZXh0TGVuZ3RoPSI0NTAiPmxpZmVjeWNsZTwvdGV4dD4KICAgICAgICA8dGV4dCBhcmlhLWhpZGRlbj0idHJ1ZSIgeD0iOTU1IiB5PSIxNTAiIGZpbGw9IiMwMTAxMDEiIGZpbGwtb3BhY2l0eT0iLjMiIHRyYW5zZm9ybT0ic2NhbGUoLjEpIiB0ZXh0TGVuZ3RoPSI3MzAiPmV4cGVyaW1lbnRhbDwvdGV4dD4KICAgICAgICA8dGV4dCB4PSI5NTUiIHk9IjE0MCIgdHJhbnNmb3JtPSJzY2FsZSguMSkiIGZpbGw9IiNmZmYiIHRleHRMZW5ndGg9IjczMCI+ZXhwZXJpbWVudGFsPC90ZXh0PgogICAgPC9nPgo8L3N2Zz4K" alt="Lifecycle:experimental" /></a></p>
364364
<!-- badges: end -->
365-
<p><strong>tidyprint</strong> is an R package that provides multiple
366-
printing styles for <code>SummarizedExperiment</code> objects. You can
367-
choose among:</p>
365+
<p><strong>tidyprint</strong> is an R package that provides a
366+
centralised tidy display strategy for biological data
367+
(e.g. SummarizedExperiment), and centralised messaging styles for the
368+
<code>tidyomics</code> packages. To facilitate the discussion about data
369+
display, we compare here four data diplay:</p>
368370
<ol style="list-style-type: decimal">
369-
<li><p><strong>SummarizedExperiment</strong> (default): Standard
371+
<li><p><strong>SummarizedExperiment</strong>: Standard
370372
R/SummarizedExperiment printing style.</p></li>
371373
<li><p><strong>tidyprint_1</strong>: Newly designed tibble abstraction,
372374
combines styles from <strong>tidySummarizedExperiment</strong> and
@@ -382,11 +384,11 @@ <h1 class="title toc-ignore">tidyprint</h1>
382384
<hr />
383385
<div id="installation" class="section level2">
384386
<h2>1. Installation</h2>
385-
<p>You need the `` package to install from GitHub. If you don’t have it,
386-
install via:</p>
387-
<pre class="r"><code>install.packages(&quot;devtools&quot;)</code></pre>
387+
<p>You need the <code>remotes</code> package to install from GitHub. If
388+
you don’t have it, install via:</p>
389+
<pre class="r"><code>install.packages(&quot;remotes&quot;)</code></pre>
388390
<p>Then install <strong>tidyprint</strong> from GitHub:</p>
389-
<pre class="r"><code>devtools::install_github(&quot;tidyomics/tidyprint&quot;)</code></pre>
391+
<pre class="r"><code>remotes::install_github(&quot;tidyomics/tidyprint&quot;)</code></pre>
390392
<hr />
391393
</div>
392394
<div id="demo" class="section level2">
@@ -461,20 +463,6 @@ <h3>2.3 <strong>tidyprint_1</strong></h3>
461463
#&gt; 309550 ENSG00000283119 SRR1039521 | 0 | | treated N061011 GSM1275875
462464
#&gt; 309551 ENSG00000283120 SRR1039521 | 0 | | treated N061011 GSM1275875
463465
#&gt; 309552 ENSG00000283123 SRR1039521 | 0 | | treated N061011 GSM1275875</code></pre>
464-
<p>You can also limit the number of displayed rows by setting
465-
<code>n_print</code> (or a similar argument in your code):</p>
466-
<pre class="r"><code>
467-
se_airway %&gt;% print(design = &quot;tidyprint_1&quot;, n_print = 5)
468-
#&gt; # A SummarizedExperiment-tibble abstraction:
469-
#&gt; # Features=38694 | Samples=8 | Assays=counts
470-
#&gt; .features .samples `|` counts `|` `|` dex celltype geo_id
471-
#&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;
472-
#&gt; 1 ENSG00000000003 SRR1039508 | 723 | | control N61311 GSM1275862
473-
#&gt; 2 ENSG00000000005 SRR1039508 | 0 | | control N61311 GSM1275862
474-
#&gt; 3 ENSG00000000419 SRR1039508 | 467 | | control N61311 GSM1275862
475-
#&gt; --------------- ---------- -- --- -- -- ------- ------- ----------
476-
#&gt; 309551 ENSG00000283120 SRR1039521 | 0 | | treated N061011 GSM1275875
477-
#&gt; 309552 ENSG00000283123 SRR1039521 | 0 | | treated N061011 GSM1275875</code></pre>
478466
</div>
479467
<div id="tidysummarizedexperiment" class="section level3">
480468
<h3>2.4 <strong>tidySummarizedExperiment</strong></h3>
@@ -519,20 +507,21 @@ <h3>2.5 <strong>plyxp</strong></h3>
519507
#&gt; 8 ENSG00000283119 SRR1039521 | 0 | | treated N061011 GSM1275875
520508
#&gt; 9 ENSG00000283120 SRR1039521 | 0 | | treated N061011 GSM1275875
521509
#&gt; 10 ENSG00000283123 SRR1039521 | 0 | | treated N061011 GSM1275875</code></pre>
522-
<p>You can also limit the number of displayed rows by setting
523-
<code>n_print</code> (or a similar argument in your code):</p>
524-
<pre class="r"><code>
525-
se_airway %&gt;% print(design = &quot;plyxp&quot;, n_print = 5)
526-
#&gt; # A tibble: 5 × 9
527-
#&gt; .features .samples `|` counts `|` `|` dex celltype geo_id
528-
#&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;
529-
#&gt; 1 ENSG00000000003 SRR1039508 | 723 | | control N61311 GSM1275862
530-
#&gt; 2 ENSG00000000005 SRR1039508 | 0 | | control N61311 GSM1275862
531-
#&gt; 3 ENSG00000000419 SRR1039508 | 467 | | control N61311 GSM1275862
532-
#&gt; 4 ENSG00000283120 SRR1039521 | 0 | | treated N061011 GSM1275875
533-
#&gt; 5 ENSG00000283123 SRR1039521 | 0 | | treated N061011 GSM1275875</code></pre>
534510
</div>
535511
</div>
512+
<div id="messaging-function" class="section level1">
513+
<h1>Messaging function</h1>
514+
<p>We integrated a messaging function providing standardized, visually
515+
appealing messages for packages within the tidyomics ecosystem. It
516+
automatically detects the calling package to provide contextualized
517+
messaging, such as “tidyprint says” or “tidybulk says”, enhancing
518+
consistency and readability across projects.</p>
519+
<pre class="r"><code>
520+
test_tidy_message()
521+
#&gt; ℹ tidyprint says: This is an informational message send within tidyprint package.
522+
#&gt; ✔ tidyprint says: Operation completed successfully!
523+
#&gt; ! tidyprint says: Potential issue detected.
524+
#&gt; ✖ tidyprint says: Operation failed.</code></pre>
536525
<div id="session-info" class="section level2">
537526
<h2>Session info</h2>
538527
<pre class="r"><code>
@@ -592,6 +581,7 @@ <h2>Session info</h2>
592581
#&gt; [55] knitr_1.49 htmltools_0.5.8.1
593582
#&gt; [57] rmarkdown_2.29 compiler_4.4.0</code></pre>
594583
</div>
584+
</div>
595585

596586

597587

0 commit comments

Comments
 (0)