Trouble Adding Log Fold Changes to KEGG Pathway Visualization
Entering edit mode
3 months ago
ramirj49 • 0

Hi everyone,

Right now I'm trying to visualize the glycolysis pathway for Oryza Sativa with log fold change values for my genes of interest using the ggkegg package in R. I got the pathway visualization to work and was able to highlight nodes of interest, but I'm not sure how to add log fold changes for these target genes without affected the nodes I'm not interested in. Can anyone help me with this? Thanks!

This is what the data frame I'm using looks like:

enter image description here

This is the code that I used to make the pathway visualization:

# Create a map of glycolysis pathway for Oryza Sativa + map EC number labels

# Fetch and cache RN to EC map
url <- paste0("")
bfc <- BiocFileCache()
path <- bfcrpath(bfc, url)
convert <- data.frame(data.table::fread(path, header = FALSE, sep = "\t"))
rntoec <- convert$V1 |>
  strsplit(":") |>
  vapply("[", 2, FUN.VALUE = "a") |>
# Map the EC number to gene nodes
g <- pathway("dosa00010") |>
  mutate(ec = rntoec[reaction])
# Define a vector of node names to highlight
nodes_to_highlight <- c("rn:R01786","rn:R01600","rn:R00756","rn:R00762",

# Add the "highlight" column
g <- g |>
  mutate(highlight = ifelse(reaction %in% nodes_to_highlight, "genes present in data",
                                                                 "genes not present"))
# Visualize the pathway with EC number labels and highlighted nodes
gg <- g |>
  filter(type %in% c("compound", "gene")) |>
  ggraph(layout = "manual", x = x, y = y) +
  geom_edge_link(aes(color = subtype_name)) +
  geom_node_rect(aes(fill = highlight), size = 5) +  # Set the fill color based on "highlight" column
  geom_node_shadowtext(aes(label = ec, filter = type == "gene"), color = "black",
                       bg.colour = "white", size = 2) +
  geom_node_text(aes(label = name, filter = type == "compound"),
                 color = "grey50", size = 2, repel = TRUE) +
  scale_fill_manual(values = c("genes not present" = "lightpink",
                               "genes present in data" = "yellow")) +  # Define fill colors for "genes not present" and "genes present"
KEGG RStudio • 305 views

Login before adding your answer.

Traffic: 1185 users visited in the last hour
Help About
Access RSS

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6