From 4450d3957607f8695503c35802ed6bb4d641fda0 Mon Sep 17 00:00:00 2001 From: xiangpin Date: Tue, 1 Jul 2025 15:00:54 +0800 Subject: [PATCH 1/2] add citation --- DESCRIPTION | 3 ++- NAMESPACE | 2 ++ R/zzz.R | 30 ++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 R/zzz.R diff --git a/DESCRIPTION b/DESCRIPTION index 4ad9aba..c6c4997 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -18,7 +18,8 @@ Imports: magrittr, methods, utils, - yulab.utils (>= 0.1.9) + yulab.utils (>= 0.1.9), + pillar Suggests: ggtree URL: https://github.com/YuLab-SMU/aplot, https://yulab-smu.top/aplot/ diff --git a/NAMESPACE b/NAMESPACE index a750dee..e424656 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -66,4 +66,6 @@ importFrom(patchwork,patchworkGrob) importFrom(patchwork,plot_annotation) importFrom(patchwork,plot_layout) importFrom(patchwork,plot_spacer) +importFrom(pillar,style_subtle) importFrom(utils,modifyList) +importFrom(utils,packageDescription) diff --git a/R/zzz.R b/R/zzz.R new file mode 100644 index 0000000..cf1cac5 --- /dev/null +++ b/R/zzz.R @@ -0,0 +1,30 @@ +#' @importFrom utils packageDescription +#' @importFrom pillar style_subtle +.onAttach <- function(libname, pkgname) { + pkgVersion <- packageDescription(pkgname, fields="Version") + msg <- paste0(pkgname, " v", pkgVersion, " ", + "For help: https://github.com/YuLab-SMU/aplot/issues", "\n\n") + + citation <- paste0("If you use ", pkgname, + " in published research, please cite the paper:\n\n", + aplot_citations()) + + packageStartupMessage(paste0(strwrap(pillar::style_subtle(paste0(msg, citation, suppressmsg(pkgname)))), collapse="\n")) +} + +aplot_citations <- function(){ + paste("Shuangbin Xu, Qianwen Wang, Shaodi Wen, Junrui Li, Nan He, Ming Li, Thomas Hackl, Rui Wang, + Dongqiang Zeng, Shixiang Wang, Shensuo Li, Chunhui Gao, Lang Zhou, Shaoguo Tao, Zijing Xie, + Lin Deng, and Guangchuang Yu.", + "aplot: Simplifying the creation of complex graphs to visualize associations across diverse data types.", + "The Innovation. 2025, 6(9):100958. doi: 10.1016/j.xinn.2025.100958\n\n", + "Export the citation to BibTex by citation('aplot')\n\n" + ) + +} + +suppressmsg <- function(pkgname){ + paste0("This message can be suppressed by:\n", + "suppressPackageStartupMessages(library(", pkgname ,"))" + ) +} From 87637c90e91b618de5ef3985a56ddda4d9d02e53 Mon Sep 17 00:00:00 2001 From: xushuangbin Date: Tue, 1 Jul 2025 16:51:39 +0800 Subject: [PATCH 2/2] fixed tag_levels issue of plot_list when ggplot2 > 3.5.2 --- NAMESPACE | 2 +- R/plot-list.R | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index e424656..f515726 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -45,6 +45,7 @@ importFrom(ggplot2,element_text) importFrom(ggplot2,ggplot) importFrom(ggplot2,ggplotGrob) importFrom(ggplot2,ggplot_add) +importFrom(ggplot2,ggplot_build) importFrom(ggplot2,ggsave) importFrom(ggplot2,is.ggplot) importFrom(ggplot2,labs) @@ -67,5 +68,4 @@ importFrom(patchwork,plot_annotation) importFrom(patchwork,plot_layout) importFrom(patchwork,plot_spacer) importFrom(pillar,style_subtle) -importFrom(utils,modifyList) importFrom(utils,packageDescription) diff --git a/R/plot-list.R b/R/plot-list.R index 5a6a543..e2a71a1 100644 --- a/R/plot-list.R +++ b/R/plot-list.R @@ -22,7 +22,6 @@ ##' @importFrom ggplot2 theme ##' @importFrom ggplot2 element_text ##' @importFrom ggplot2 labs -##' @importFrom utils modifyList ##' @importFrom ggfun ggbreak2ggplot ##' @export ##' @author Guangchuang Yu @@ -93,7 +92,7 @@ plot_list <- function(..., gglist = NULL, - +#' @importFrom ggplot2 ggplot_build plot_list2 <- function(gglist = NULL, ncol = NULL, nrow = NULL, @@ -117,11 +116,11 @@ plot_list2 <- function(gglist = NULL, ) if (!is.null(tag_levels) || !is.null(labels)) { - pt <- p$theme$plot.tag + pt <- ggplot_build(p)$plot$theme$plot.tag if (is.null(pt)){ pt <- ggplot2::element_text() } - pt <- modifyList(pt, list(size = tag_size)) + pt$size <- tag_size p <- p + plot_annotation(tag_levels=tag_levels) & theme(plot.tag = pt) }