Skip to content

Commit 40e161c

Browse files
committed
v1.3.4 various updates on finding names in node
1 parent d0a9786 commit 40e161c

13 files changed

+211
-54
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: ggkegg
22
Type: Package
33
Title: Analyzing and visualizing KEGG information using the grammar of graphics
4-
Version: 1.3.3
4+
Version: 1.3.4
55
Authors@R: person("Noriaki", "Sato", email = "[email protected]", role = c("cre", "aut"))
66
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.
77
License: MIT + file LICENSE

R/ggkegg.R

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,9 @@ ggkegg <- function(pid,
217217
#' @param white_background fill background color white
218218
#' @param how how to match the node IDs with the queries 'any' or 'all'
219219
#' @param infer if TRUE, append the prefix to queried IDs based on pathway ID
220+
#' @param name name of column to match for
221+
#' @param sep separater for name, default to " "
222+
#' @param remove_dot remove "..." in the name
220223
#' @export
221224
#' @examples
222225
#' if (require("clusterProfiler")) {
@@ -227,7 +230,8 @@ ggkegg <- function(pid,
227230
#' @return ggraph with overlaid KEGG map
228231
#'
229232
rawMap <- function(enrich, pathway_number=1, pid=NULL,
230-
fill_color="red", how="any", white_background=TRUE, infer=FALSE) {
233+
fill_color="red", how="any", white_background=TRUE, infer=FALSE,
234+
name="name", sep=" ", remove_dot=TRUE) {
231235

232236
number <- length(enrich)
233237
if (length(fill_color) != number) {
@@ -257,17 +261,17 @@ rawMap <- function(enrich, pathway_number=1, pid=NULL,
257261
qqcat("Changing prefix of pathway ID from map to ko\n")
258262
pid <- gsub("map","ko",pid)
259263
}
260-
261264
if (number == 1) {
262-
g <- pathway(pid) |> mutate(cp=append_cp(enrich, how=how, pid=pid, infer=infer))
265+
g <- pathway(pid) %>% mutate(cp=append_cp(!!enrich, how=!!how, pid=!!pid, infer=!!infer,
266+
name=!!name, sep=!!sep, remove_dot=!!remove_dot))
263267
gg <- ggraph(g, layout="manual", x=.data$x, y=.data$y)+
264268
geom_node_rect(fill=fill_color, aes(filter=.data$cp))+
265269
overlay_raw_map()+theme_void()
266270
} else {
267271
g <- pathway(pid)
268272
for (i in seq_len(number)) {
269273
g <- g |> mutate(!!paste0("cp",i) :=append_cp(enrich[[i]],
270-
how=how, pid=pid, infer=infer))
274+
how=!!how, pid=!!pid, infer=!!infer, name=!!name, sep=!!sep, remove_dot=!!remove_dot))
271275
}
272276
V(g)$space <- V(g)$width/number
273277
gg <- ggraph(g, layout="manual", x=.data$x, y=.data$y)
@@ -299,12 +303,14 @@ rawMap <- function(enrich, pathway_number=1, pid=NULL,
299303
#'
300304
#' @param values named vector, or list of them
301305
#' @param pid pathway id
302-
#' @param column column name on node table of the graph
303306
#' @param white_background fill background color white
304307
#' @param how how to match the node IDs with the queries 'any' or 'all'
305308
#' @param auto_add automatically add prefix based on pathway prefix
306309
#' @param man_graph provide manual tbl_graph
307310
#' @param show_type type to be shown
311+
#' @param column name of column to match for
312+
#' @param sep separater for name, default to " "
313+
#' @param remove_dot remove "..." in the name
308314
#' typically, "gene", "ortholog", or "compound"
309315
#' @export
310316
#' @examples
@@ -314,7 +320,8 @@ rawMap <- function(enrich, pathway_number=1, pid=NULL,
314320
#' @return ggraph with overlaid KEGG map
315321
#'
316322
rawValue <- function(values, pid=NULL, column="name", show_type="gene",
317-
how="any", white_background=TRUE, auto_add=FALSE, man_graph=NULL) {
323+
how="any", white_background=TRUE, auto_add=FALSE, man_graph=NULL,
324+
sep=" ", remove_dot=TRUE) {
318325
if (is.list(values)) {
319326
number <- length(values)
320327
if (auto_add) {
@@ -337,7 +344,7 @@ rawValue <- function(values, pid=NULL, column="name", show_type="gene",
337344
}
338345
if (number == 1) {
339346
g <- pgraph |> mutate(value=node_numeric(values,
340-
name=column, how=how))
347+
name=column, how=how, sep=sep, remove_dot=remove_dot))
341348
gg <- ggraph(g, layout="manual", x=.data$x, y=.data$y)+
342349
geom_node_rect(aes(fill=.data$value,
343350
filter=.data$type %in% show_type))+

0 commit comments

Comments
 (0)