From 0d13b054ae7f4e427be010fb7c584418903b1059 Mon Sep 17 00:00:00 2001 From: noriakis Date: Sat, 2 Dec 2023 10:27:25 +0900 Subject: [PATCH] return_graph argument in highlight_entities --- R/highlight_functions.R | 6 ++++-- man/highlight_entities.Rd | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/R/highlight_functions.R b/R/highlight_functions.R index b256351..44ec64b 100644 --- a/R/highlight_functions.R +++ b/R/highlight_functions.R @@ -19,6 +19,7 @@ #' @param fill_color highlight color, default to 'tomato' #' @param legend_name legend name, NULL to suppress #' @param use_cache use cache or not +#' @param return_graph return tbl_graph instead of plot #' @return overlaid map #' @examples #' highlight_entities("hsa04110", c("CDKN2A"), legend_name="interesting") @@ -27,7 +28,7 @@ highlight_entities <- function(pathway, set, how="any", num_combine=mean, name="graphics_name", sep=",", no_sep=FALSE, show_type="gene", fill_color="tomato", - legend_name=NULL, use_cache=FALSE) { + legend_name=NULL, use_cache=FALSE, return_graph=FALSE) { graph <- pathway(pathway, use_cache=use_cache) x <- get.vertex.attribute(graph, name) @@ -53,7 +54,7 @@ highlight_entities <- function(pathway, set, how="any", } }, FUN.VALUE=TRUE) graph <- graph |> mutate(highlight=vec) - + if (return_graph) {return(graph)} res <- ggraph(graph, layout="manual", x=.data$x, y=.data$y) + geom_node_rect(aes(filter=.data$type %in% show_type, fill=.data$highlight))+ @@ -79,6 +80,7 @@ highlight_entities <- function(pathway, set, how="any", } }) |> unlist() graph <- graph |> mutate(highlight=vec) + if (return_graph) {return(graph)} res <- ggraph(graph, layout="manual", x=.data$x, y=.data$y) + geom_node_rect(aes(filter=.data$type %in% show_type, fill=.data$highlight))+ diff --git a/man/highlight_entities.Rd b/man/highlight_entities.Rd index 95d74ea..f4a730e 100644 --- a/man/highlight_entities.Rd +++ b/man/highlight_entities.Rd @@ -15,7 +15,8 @@ highlight_entities( show_type = "gene", fill_color = "tomato", legend_name = NULL, - use_cache = FALSE + use_cache = FALSE, + return_graph = FALSE ) } \arguments{ @@ -43,6 +44,8 @@ is in query.} \item{legend_name}{legend name, NULL to suppress} \item{use_cache}{use cache or not} + +\item{return_graph}{return tbl_graph instead of plot} } \value{ overlaid map