Skip to content

Commit e2dce00

Browse files
committed
Update version to 1.15.2, add S7 as a suggested dependency, and improve README formatting for better readability. Enhance ggplot method for compatibility with ggplot2 4.0.0 using S7 methods.
1 parent 987165f commit e2dce00

File tree

6 files changed

+75
-39
lines changed

6 files changed

+75
-39
lines changed

DESCRIPTION

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Type: Package
22
Package: tidySummarizedExperiment
33
Title: Brings SummarizedExperiment to the Tidyverse
4-
Version: 1.15.1
4+
Version: 1.15.2
55
Authors@R: c(person("Stefano", "Mangiola", email = "mangiolastefano@gmail.com",
66
role = c("aut", "cre")) )
77
Description: The tidySummarizedExperiment package provides a set of tools for creating and
@@ -46,7 +46,8 @@ Suggests:
4646
markdown,
4747
rmarkdown,
4848
plotly,
49-
rbibutils
49+
rbibutils,
50+
S7
5051
VignetteBuilder:
5152
knitr
5253
RdMacros:

R/ggplot2_methods.R

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#' @name ggplot
22
#' @rdname ggplot
33
#' @inherit ggplot2::ggplot
4-
#' @title Create a new \code{ggplot} from a \code{tidyseurat}
4+
#' @title Create a new \code{ggplot} from a \code{SummarizedExperiment}
55
#' @return `ggplot`
66
#'
77
#' @examples
@@ -29,3 +29,30 @@ ggplot.SummarizedExperiment <- function(data=NULL, mapping=aes(),
2929
as_tibble() %>%
3030
ggplot2::ggplot(mapping=mapping)
3131
}
32+
33+
# S7 method for ggplot2 4.0.0+ compatibility
34+
register_s7_ggplot_method <- function() {
35+
if (requireNamespace("S7", quietly = TRUE)) {
36+
S7 <- getNamespace("S7")
37+
# Check if ggplot and SummarizedExperiment are S7 classes
38+
is_s7_class <- function(x) inherits(x, "S7_class")
39+
ggplot_s7 <- tryCatch(get("ggplot", envir = asNamespace("ggplot2")), error = function(e) NULL)
40+
se_s7 <- tryCatch(get("SummarizedExperiment", envir = asNamespace("SummarizedExperiment")), error = function(e) NULL)
41+
if (!is.null(ggplot_s7) && !is.null(se_s7) && is_s7_class(ggplot_s7) && is_s7_class(se_s7)) {
42+
S7$method(ggplot_s7, se_s7) <- function(data=NULL, mapping=aes(), ..., environment=parent.frame()) {
43+
.cols <- enquos(..., .ignore_empty="all") %>%
44+
map(~ quo_name(.x)) %>% unlist()
45+
if (is_sample_feature_deprecated_used(data, .cols)) {
46+
data <- ping_old_special_column_into_metadata(data)
47+
}
48+
data %>%
49+
as_tibble() %>%
50+
ggplot2::ggplot(mapping=mapping)
51+
}
52+
}
53+
}
54+
}
55+
56+
.onLoad <- function(libname, pkgname) {
57+
register_s7_ggplot_method()
58+
}

README.Rmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ Here we plot the distribution of counts per sample.
209209

210210
```{r plot1}
211211
pasilla_tidy %>%
212-
tidySummarizedExperiment::ggplot(aes(counts + 1, group=.sample, color=`type`)) +
212+
ggplot(aes(counts + 1, group=.sample, color=`type`)) +
213213
geom_density() +
214214
scale_x_log10() +
215215
my_theme

README.md

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,35 @@ tidySummarizedExperiment - part of tidytranscriptomics
22
================
33

44
<!-- badges: start -->
5-
5+
66
[![Lifecycle:maturing](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://www.tidyverse.org/lifecycle/#maturing)
77
[![R build
88
status](https://github.com/stemangiola/tidySummarizedExperiment/workflows/R-CMD-check-bioc/badge.svg)](https://github.com/stemangiola/tidySummarizedExperiment/actions)
99
<!-- badges: end -->
1010

11-
**Brings SummarizedExperiment to the tidyverse!**
11+
**Brings SummarizedExperiment to the tidyverse!**
1212

1313
website:
1414
[stemangiola.github.io/tidySummarizedExperiment/](https://stemangiola.github.io/tidySummarizedExperiment/)
1515

16-
Another [nice introduction](https://carpentries-incubator.github.io/bioc-intro/60-next-steps/index.html) by carpentries-incubator.
16+
Another [nice
17+
introduction](https://carpentries-incubator.github.io/bioc-intro/60-next-steps/index.html)
18+
by carpentries-incubator.
1719

1820
Please also have a look at
1921

20-
- [tidySingleCellExperiment](https://stemangiola.github.io/tidySingleCellExperiment/)
21-
for tidy manipulation of SingleCellExperiment objects
22-
- [tidyseurat](https://stemangiola.github.io/tidyseurat/) for tidy
23-
manipulation of Seurat objects
24-
- [tidybulk](https://stemangiola.github.io/tidybulk/) for tidy
25-
analysis of RNA sequencing data
26-
- [nanny](https://github.com/stemangiola/nanny) for tidy high-level
27-
data analysis and manipulation
28-
- [tidygate](https://github.com/stemangiola/tidygate) for adding
29-
custom gate information to your tibble
30-
- [tidyHeatmap](https://stemangiola.github.io/tidyHeatmap/) for
31-
heatmaps produced with tidy principles
22+
- [tidySingleCellExperiment](https://stemangiola.github.io/tidySingleCellExperiment/)
23+
for tidy manipulation of SingleCellExperiment objects
24+
- [tidyseurat](https://stemangiola.github.io/tidyseurat/) for tidy
25+
manipulation of Seurat objects
26+
- [tidybulk](https://stemangiola.github.io/tidybulk/) for tidy analysis
27+
of RNA sequencing data
28+
- [nanny](https://github.com/stemangiola/nanny) for tidy high-level data
29+
analysis and manipulation
30+
- [tidygate](https://github.com/stemangiola/tidygate) for adding custom
31+
gate information to your tibble
32+
- [tidyHeatmap](https://stemangiola.github.io/tidyHeatmap/) for heatmaps
33+
produced with tidy principles
3234

3335
# Introduction
3436

@@ -43,9 +45,9 @@ tidyverse worlds.
4345

4446
## Functions/utilities available
4547

46-
| SummarizedExperiment-compatible Functions | Description |
47-
|-------------------------------------------|------------------------------------------------------------------------------------|
48-
| `all` | After all `tidySummarizedExperiment` is a SummarizedExperiment object, just better |
48+
| SummarizedExperiment-compatible Functions | Description |
49+
|----|----|
50+
| `all` | After all `tidySummarizedExperiment` is a SummarizedExperiment object, just better |
4951

5052
| tidyverse Packages | Description |
5153
|--------------------|---------------------------------------------|
@@ -98,7 +100,7 @@ pasilla_tidy
98100
```
99101

100102
## # A SummarizedExperiment-tibble abstraction: 102,193 × 5
101-
## [90m# Transcripts=14599 | Samples=7 | Assays=counts[39m
103+
## # Features=14599 | Samples=7 | Assays=counts
102104
## .feature .sample counts condition type
103105
## <chr> <chr> <int> <chr> <chr>
104106
## 1 FBgn0000003 untrt1 0 untreated single_end
@@ -111,7 +113,7 @@ pasilla_tidy
111113
## 8 FBgn0000024 untrt1 10 untreated single_end
112114
## 9 FBgn0000028 untrt1 0 untreated single_end
113115
## 10 FBgn0000032 untrt1 1446 untreated single_end
114-
## # … with 40 more rows
116+
## # 40 more rows
115117

116118
**But it is a SummarizedExperiment object after all**
117119

@@ -136,7 +138,7 @@ pasilla_tidy %>%
136138
```
137139

138140
## # A SummarizedExperiment-tibble abstraction: 1 × 5
139-
## [90m# Transcripts=1 | Samples=1 | Assays=counts[39m
141+
## # Features=1 | Samples=1 | Assays=counts
140142
## .feature .sample counts condition type
141143
## <chr> <chr> <int> <chr> <chr>
142144
## 1 FBgn0000003 untrt1 0 untreated single_end
@@ -149,7 +151,7 @@ pasilla_tidy %>%
149151
```
150152

151153
## # A SummarizedExperiment-tibble abstraction: 58,396 × 5
152-
## [90m# Transcripts=14599 | Samples=4 | Assays=counts[39m
154+
## # Features=14599 | Samples=4 | Assays=counts
153155
## .feature .sample counts condition type
154156
## <chr> <chr> <int> <chr> <chr>
155157
## 1 FBgn0000003 untrt1 0 untreated single_end
@@ -162,7 +164,7 @@ pasilla_tidy %>%
162164
## 8 FBgn0000024 untrt1 10 untreated single_end
163165
## 9 FBgn0000028 untrt1 0 untreated single_end
164166
## 10 FBgn0000032 untrt1 1446 untreated single_end
165-
## # … with 40 more rows
167+
## # 40 more rows
166168

167169
We can use `select` to choose columns.
168170

@@ -184,7 +186,7 @@ pasilla_tidy %>%
184186
## 8 untrt1
185187
## 9 untrt1
186188
## 10 untrt1
187-
## # … with 102,183 more rows
189+
## # 102,183 more rows
188190

189191
We can use `count` to count how many rows we have for each sample.
190192

@@ -231,7 +233,7 @@ pasilla_tidy %>%
231233
```
232234

233235
## # A SummarizedExperiment-tibble abstraction: 102,193 × 5
234-
## [90m# Transcripts=14599 | Samples=7 | Assays=counts[39m
236+
## # Features=14599 | Samples=7 | Assays=counts
235237
## .feature .sample counts condition sequencing
236238
## <chr> <chr> <int> <chr> <chr>
237239
## 1 FBgn0000003 untrt1 0 untreated single_end
@@ -244,7 +246,7 @@ pasilla_tidy %>%
244246
## 8 FBgn0000024 untrt1 10 untreated single_end
245247
## 9 FBgn0000028 untrt1 0 untreated single_end
246248
## 10 FBgn0000032 untrt1 1446 untreated single_end
247-
## # … with 40 more rows
249+
## # 40 more rows
248250

249251
We could use `mutate` to create a column. For example, we could create a
250252
new type column that contains single and paired instead of single_end
@@ -256,7 +258,7 @@ pasilla_tidy %>%
256258
```
257259

258260
## # A SummarizedExperiment-tibble abstraction: 102,193 × 5
259-
## [90m# Transcripts=14599 | Samples=7 | Assays=counts[39m
261+
## # Features=14599 | Samples=7 | Assays=counts
260262
## .feature .sample counts condition type
261263
## <chr> <chr> <int> <chr> <chr>
262264
## 1 FBgn0000003 untrt1 0 untreated single
@@ -269,7 +271,7 @@ pasilla_tidy %>%
269271
## 8 FBgn0000024 untrt1 10 untreated single
270272
## 9 FBgn0000028 untrt1 0 untreated single
271273
## 10 FBgn0000032 untrt1 1446 untreated single
272-
## # … with 40 more rows
274+
## # 40 more rows
273275

274276
We could use `unite` to combine multiple columns into a single column.
275277

@@ -279,7 +281,7 @@ pasilla_tidy %>%
279281
```
280282

281283
## # A SummarizedExperiment-tibble abstraction: 102,193 × 4
282-
## [90m# Transcripts=14599 | Samples=7 | Assays=counts[39m
284+
## # Features=14599 | Samples=7 | Assays=counts
283285
## .feature .sample counts group
284286
## <chr> <chr> <int> <chr>
285287
## 1 FBgn0000003 untrt1 0 untreated_single_end
@@ -292,7 +294,7 @@ pasilla_tidy %>%
292294
## 8 FBgn0000024 untrt1 10 untreated_single_end
293295
## 9 FBgn0000028 untrt1 0 untreated_single_end
294296
## 10 FBgn0000032 untrt1 1446 untreated_single_end
295-
## # … with 40 more rows
297+
## # 40 more rows
296298

297299
We can also combine commands with the tidyverse pipe `%>%`.
298300

@@ -340,7 +342,7 @@ pasilla_tidy %>%
340342
## 8 FBgn0000024 untrt1 10 untreated single_end 7
341343
## 9 FBgn0000028 untrt1 0 untreated single_end 0.429
342344
## 10 FBgn0000032 untrt1 1446 untreated single_end 1085.
343-
## # … with 86,503 more rows
345+
## # 86,503 more rows
344346

345347
# Plotting
346348

@@ -371,7 +373,7 @@ Here we plot the distribution of counts per sample.
371373

372374
``` r
373375
pasilla_tidy %>%
374-
tidySummarizedExperiment::ggplot(aes(counts + 1, group=.sample, color=`type`)) +
376+
ggplot(aes(counts + 1, group=.sample, color=`type`)) +
375377
geom_density() +
376378
scale_x_log10() +
377379
my_theme

inst/NEWS.rd

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
\name{NEWS}
22
\title{News for Package \pkg{tidySummarizedExperiment}}
33

4+
\section{Changes in version 1.16.0, Bioconductor 3.17 Release}{
5+
\itemize{
6+
\item Prepared for ggplot2 4.0.0 compatibility with S7 methods.
7+
\item Added conditional S7 method for ggplot while maintaining S3 method for current ggplot2 versions.
8+
\item Added S7 as suggested dependency for future ggplot2 4.0.0 compatibility.
9+
}}
10+
411
\section{Changes in version 1.4.0, Bioconductor 3.14 Release}{
512
\itemize{
613
\item Improved join_*() functions.

man/ggplot.Rd

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

0 commit comments

Comments
 (0)