diff --git a/DESCRIPTION b/DESCRIPTION index 01dd6eb..6fed080 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: ggkegg Type: Package Title: KEGG pathway visualization by ggplot2 -Version: 1.1.10 +Version: 1.1.11 Authors@R: person("Noriaki", "Sato", email = "nori@hgc.jp", role = c("cre", "aut")) Description: This package aims to import, parse, and analyze KEGG data such as KEGG PATHWAY and KEGG MODULE. The package supports visualizing KEGG information using ggplot2 and ggraph through using the grammar of graphics. The package enables the direct visualization of the results from various omics analysis packages. License: MIT + file LICENSE diff --git a/R/overlay_functions.R b/R/overlay_functions.R index b5921fe..3a3250f 100644 --- a/R/overlay_functions.R +++ b/R/overlay_functions.R @@ -16,6 +16,7 @@ #' Override `adjust` #' @param use_cache whether to use BiocFileCache() #' @param interpolate parameter in annotation_raster() +#' @param high_res Use high resolution (2x) image for the overlay #' @import magick #' @return ggplot2 object #' @export @@ -34,7 +35,8 @@ overlay_raw_map <- function(pid=NULL, directory=NULL, adjust_manual_y=NULL, clip=FALSE, use_cache=TRUE, - interpolate=TRUE) { + interpolate=TRUE, + high_res=FALSE) { structure(list(pid=pid, transparent_colors=transparent_colors, adjust=adjust, @@ -43,7 +45,8 @@ overlay_raw_map <- function(pid=NULL, directory=NULL, adjust_manual_y=adjust_manual_y, directory=directory, use_cache=use_cache, - interpolate=interpolate), + interpolate=interpolate, + high_res=high_res), class="overlay_raw_map") } @@ -65,16 +68,26 @@ ggplot_add.overlay_raw_map <- function(object, plot, object_name) { if (is.null(object$pid)) { infer <- plot$data$pathway_id |> unique() object$pid <- infer[!is.na(infer)] + if (object$high_res) { + ## Convert to reference ID + cur_id <- object$pid + object$pid <- paste0("map", + regmatches(cur_id, gregexpr("[[:digit:]]+", cur_id)) %>% unlist()) + } } if (!grepl("[[:digit:]]", object$pid)) { warning("Looks like not KEGG ID for pathway") return(1) } ## Return the image URL, download and cache - url <- paste0(as.character(pathway(object$pid, - use_cache=object$use_cache, - directory=object$directory, - return_image=TRUE))) + ## From 1.1.10 + url <- paste0("https://rest.kegg.jp/get/",object$pid,"/image") + if (object$high_res) { + if (!startsWith(object$pid, "map")) { + stop("High resolution image can be obtained for the reference pathway.") + } + url <- paste0(url, "2x") + } if (object$use_cache) { bfc <- BiocFileCache() path <- bfcrpath(bfc, url) diff --git a/man/overlay_raw_map.Rd b/man/overlay_raw_map.Rd index 692bd18..da9b043 100644 --- a/man/overlay_raw_map.Rd +++ b/man/overlay_raw_map.Rd @@ -13,7 +13,8 @@ overlay_raw_map( adjust_manual_y = NULL, clip = FALSE, use_cache = TRUE, - interpolate = TRUE + interpolate = TRUE, + high_res = FALSE ) } \arguments{ @@ -39,6 +40,8 @@ Override `adjust`} \item{use_cache}{whether to use BiocFileCache()} \item{interpolate}{parameter in annotation_raster()} + +\item{high_res}{Use high resolution (2x) image for the overlay} } \value{ ggplot2 object