diff --git a/DESCRIPTION b/DESCRIPTION index 33671f4..04633a5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: plyxp Title: Data masks for SummarizedExperiment enabling dplyr-like manipulation -Version: 0.99.23 +Version: 0.99.24 Authors@R: c( person("Justin", "Landis", email = "jtlandis314@gmail.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-5501-4934")), diff --git a/NEWS b/NEWS index 98eb989..209bc4c 100644 --- a/NEWS +++ b/NEWS @@ -1,9 +1,14 @@ +## plyxp 0.99.24 + +* Since `plyxp` does not have a conflict with `tidySummarizedExperiment` anymore, + we have removed package startup messages warning of potential conflicts. + ## plyxp 0.99.21 * Fixed documentation of `?plyxp::mutate` and other dplyr functions reexported by `plyxp`. -* `PlySummarizedExperiment` should be able to hold any `SummarizedExperiment` +* `PlySummarizedExperiment` should be able to hold any `SummarizedExperiment` object ## plyxp 0.99.20 diff --git a/R/zzz.R b/R/zzz.R index fb0dccc..73f6088 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -1,101 +1,101 @@ -conflict_info <- c( - "Note that these packages are exclusive and present different APIs ", - "for working with {.cls SummarizedExperiment} objects. As such conflicts ", - "and unexpected behaviors may arise!" -) +# conflict_info <- c( +# "Note that these packages are exclusive and present different APIs ", +# "for working with {.cls SummarizedExperiment} objects. As such conflicts ", +# "and unexpected behaviors may arise!" +# ) + +# rule <- function (pad = "-", gap = 2L) { +# paste0(rep(pad, getOption("width") - gap), collapse = "") +# } + +# tidySE_opt <- list(quote(tidySummarizedExperiment), "tidySummarizedExperiment") + +# attaching_tidySE <- function(expr) { +# if (is_call(expr, name = "library")) { +# call <- match.call(library, call = expr) +# out <- tidySE_opt |> +# vapply(identical, y = call$package, logical(1)) |> +# any() +# return(out) +# } +# FALSE + +# } -rule <- function (pad = "-", gap = 2L) { - paste0(rep(pad, getOption("width") - gap), collapse = "") -} -tidySE_opt <- list(quote(tidySummarizedExperiment), "tidySummarizedExperiment") -attaching_tidySE <- function(expr) { - if (is_call(expr, name = "library")) { - call <- match.call(library, call = expr) - out <- tidySE_opt |> - vapply(identical, y = call$package, logical(1)) |> - any() - return(out) - } - FALSE - -} +# you_have_loaded <- function(pkg1, pkg2, .class = NULL) { +# if (!is.null(.class)) { +# local_options(cli.message_class = .class) +# } +# withRestarts({ +# cli::cli_rule() +# cli::cli_alert_warning( +# "you have loaded {.pkg {pkg1}} after {.pkg {pkg2}}\n" +# ) +# cli::cli_text("") +# cli::cli_text(conflict_info) +# cli::cli_text("") +# }, +# muffleMessage = function() NULL) +# } +# # a package can either be loaded, or completely attached. R only informs +# # of conflicts when the package is loaded, and when attached these can be +# # overwritten silently -you_have_loaded <- function(pkg1, pkg2, .class = NULL) { - if (!is.null(.class)) { - local_options(cli.message_class = .class) - } - withRestarts({ - cli::cli_rule() - cli::cli_alert_warning( - "you have loaded {.pkg {pkg1}} after {.pkg {pkg2}}\n" - ) - cli::cli_text("") - cli::cli_text(conflict_info) - cli::cli_text("") - }, - muffleMessage = function() NULL) - -} +# .onAttach <- function(libname, pkgname) { +# # check if `tidySummarizedExperiment` is already loaded +# conflict <- grep("tidySummarizedExperiment", search(), value = TRUE) +# if (length(conflict)) { +# you_have_loaded("plyxp","tidySummarizedExperiment", +# .class = c("packageStartupMessage", "message")) +# } +# # set hook for if `tidySummarizedExperiment` gets attached latter +# setHook( +# packageEvent(pkgname = "tidySummarizedExperiment", +# event = "attach"), +# function(...) { +# you_have_loaded("tidySummarizedExperiment","plyxp", +# .class = c("packageStartupMessage", "message")) +# } -# a package can either be loaded, or completely attached. R only informs -# of conflicts when the package is loaded, and when attached these can be -# overwritten silently +# ) +# # hook for when tidySummarizedExperiment:: is used after plyxp is attached +# setHook( +# packageEvent(pkgname = "tidySummarizedExperiment", +# event = "onLoad"), +# function(...) { +# calls <- sys.calls() +# called_via_library <- vapply(calls, attaching_tidySE, logical(1)) +# if (!any(called_via_library)) { +# # if this callback was not executed via library(tidySummarizedExperiment) +# # then warn that plyxp dplyr methods have likely been overwritten! +# # otherwise, let the .onAttach method warn the user +# cli::cli_inform( +# .frequency = "regularly", +# .frequency_id = "tidySummarizedExperiment_loaded_after_plyxp_attach", +# class = "plyxp_loaded_conflict", +# message = c( +# "!" = paste0( +# "You have likely loaded {.pkg tidySummarizedExperiment} after ", +# "{.pkg plyxp} via {.code tidySummarizedExperiment::...}" +# ), +# "*" = paste(conflict_info, collapse = ""), +# "!" = "This has likely caused {.pkg dplyr} methods from {.pkg plyxp} to be over-written!", +# "i" = "If this wasn't your intention, consider restarting your R session")) +# } -.onAttach <- function(libname, pkgname) { - # check if `tidySummarizedExperiment` is already loaded - conflict <- grep("tidySummarizedExperiment", search(), value = TRUE) - if (length(conflict)) { - you_have_loaded("plyxp","tidySummarizedExperiment", - .class = c("packageStartupMessage", "message")) - } - # set hook for if `tidySummarizedExperiment` gets attached latter - setHook( - packageEvent(pkgname = "tidySummarizedExperiment", - event = "attach"), - function(...) { - you_have_loaded("tidySummarizedExperiment","plyxp", - .class = c("packageStartupMessage", "message")) - } - - ) - # hook for when tidySummarizedExperiment:: is used after plyxp is attached - setHook( - packageEvent(pkgname = "tidySummarizedExperiment", - event = "onLoad"), - function(...) { - calls <- sys.calls() - called_via_library <- vapply(calls, attaching_tidySE, logical(1)) - if (!any(called_via_library)) { - # if this callback was not executed via library(tidySummarizedExperiment) - # then warn that plyxp dplyr methods have likely been overwritten! - # otherwise, let the .onAttach method warn the user - cli::cli_inform( - .frequency = "regularly", - .frequency_id = "tidySummarizedExperiment_loaded_after_plyxp_attach", - class = "plyxp_loaded_conflict", - message = c( - "!" = paste0( - "You have likely loaded {.pkg tidySummarizedExperiment} after ", - "{.pkg plyxp} via {.code tidySummarizedExperiment::...}" - ), - "*" = paste(conflict_info, collapse = ""), - "!" = "This has likely caused {.pkg dplyr} methods from {.pkg plyxp} to be over-written!", - "i" = "If this wasn't your intention, consider restarting your R session")) - } - - } - ) -} +# } +# ) +# } -.onDetach <- function(libpath) { - # remove verbose message when `plyxp` is removed from attach list - setHook(packageEvent("tidySummarizedExperiment", "attach"), NULL, "replace") - setHook(packageEvent("tidySummarizedExperiment", "onLoad"), NULL, "replace") -} +# .onDetach <- function(libpath) { +# # remove verbose message when `plyxp` is removed from attach list +# setHook(packageEvent("tidySummarizedExperiment", "attach"), NULL, "replace") +# setHook(packageEvent("tidySummarizedExperiment", "onLoad"), NULL, "replace") +# } # check_dplyr_s3_method <- function(method) { # tbl <- getNamespace("dplyr")[[".__S3MethodsTable__."]]