diff --git a/DESCRIPTION b/DESCRIPTION index 410f9b2..9995c59 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: ggkegg Type: Package Title: KEGG pathway visualization by ggplot2 -Version: 1.1.11 +Version: 1.1.12 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/NAMESPACE b/NAMESPACE index dda4d21..192377c 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -3,6 +3,7 @@ S3method(ggplot_add,geom_kegg) S3method(ggplot_add,geom_node_rect_kegg) S3method(ggplot_add,overlay_raw_map) +export(add_title) export(append_cp) export(append_label_position) export(assign_deseq2) diff --git a/R/overlay_functions.R b/R/overlay_functions.R index b079d7d..74669b9 100644 --- a/R/overlay_functions.R +++ b/R/overlay_functions.R @@ -200,7 +200,7 @@ ggkeggsave <- function(filename, plot, dpi=300, wscale=90, hscale=90) { #' @export #' @importFrom grDevices dev.off png #' @import gtable -#' @return output the image +#' @return output the image and return the path #' @examples #' \dontrun{ #' ouput_overlay_image(ggraph(pathway("hsa04110"))) @@ -301,4 +301,36 @@ output_overlay_image <- function(gg, with_legend=TRUE, out <- paste0(pid, "_ggkegg.png") } image_write(flat, out) + return(out) +} + + + +#' addTitle +#' +#' Add the title to the image produced by output_overlay_image +#' using magick. +#' +#' @param out the image +#' @param title the title +#' @param size the size +#' @param height title height +#' @param color bg color +#' @param titleColor title color +#' @param gravity positioning of the title in the blank image +#' @export +#' @return output the image +add_title <- function(out, title=NULL, size=20, height=30, color="white", + titleColor="black", gravity="west") { + + img <- image_read(out) + info <- image_info(img) + w <- info$width + h <- info$height + blank <- image_blank(width=w, height=height, color=color) + imganno <- image_annotate(blank, title, size = size, + color=titleColor, gravity=gravity) + res <- image_append(c(imganno, img), stack=TRUE) + image_write(res, out) + return(res) } \ No newline at end of file diff --git a/man/add_title.Rd b/man/add_title.Rd new file mode 100644 index 0000000..2f3db59 --- /dev/null +++ b/man/add_title.Rd @@ -0,0 +1,38 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/overlay_functions.R +\name{add_title} +\alias{add_title} +\title{addTitle} +\usage{ +add_title( + out, + title = NULL, + size = 20, + height = 30, + color = "white", + titleColor = "black", + gravity = "west" +) +} +\arguments{ +\item{out}{the image} + +\item{title}{the title} + +\item{size}{the size} + +\item{height}{title height} + +\item{color}{bg color} + +\item{titleColor}{title color} + +\item{gravity}{positioning of the title in the blank image} +} +\value{ +output the image +} +\description{ +Add the title to the image produced by output_overlay_image +using magick. +} diff --git a/man/output_overlay_image.Rd b/man/output_overlay_image.Rd index f325705..2ec6f97 100644 --- a/man/output_overlay_image.Rd +++ b/man/output_overlay_image.Rd @@ -45,7 +45,7 @@ output_overlay_image( \item{legend_space}{legend spacing specification (in pixel)} } \value{ -output the image +output the image and return the path } \description{ The function first exports the image, combine it with the original image.