Skip to content

Commit 0071478

Browse files
committed
Refactor ggplot method registration to use S7::method directly for improved clarity and compatibility with ggplot2.
1 parent 67b9bd9 commit 0071478

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

R/ggplot2_methods.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ ggplot.SummarizedExperiment <- function(data=NULL, mapping=aes(),
3333
# S7 method for ggplot2 4.0.0+ compatibility
3434
register_s7_ggplot_method <- function() {
3535
if (requireNamespace("S7", quietly = TRUE)) {
36-
S7 <- getNamespace("S7")
3736
# Check if ggplot and SummarizedExperiment are S7 classes
3837
is_s7_class <- function(x) inherits(x, "S7_class")
3938
ggplot_s7 <- tryCatch(get("ggplot", envir = asNamespace("ggplot2")), error = function(e) NULL)
4039
se_s7 <- tryCatch(get("SummarizedExperiment", envir = asNamespace("SummarizedExperiment")), error = function(e) NULL)
4140
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()) {
41+
# Use S7::method directly for the assignment
42+
S7::method(ggplot_s7, se_s7) <- function(data=NULL, mapping=aes(), ..., environment=parent.frame()) {
4343
.cols <- enquos(..., .ignore_empty="all") %>%
4444
map(~ quo_name(.x)) %>% unlist()
4545
if (is_sample_feature_deprecated_used(data, .cols)) {

0 commit comments

Comments
 (0)