RN to EC Mapping Not Working for Some Nodes
0
0
Entering edit mode
Ramirj49 • 0
@a345c8dc
Last seen 6 months ago
United States

Hi all,

I'm making pathway diagrams for the Lysine Biosynthesis pathway using ggkegg, but for some reason the mapping between reaction numbers and ec numbers doesn't work for some nodes. For example, one reaction number that I'm trying to map is "rn:R04199", but when I run my code the corresponding node doesn't get highlighted. However, when I try other reaction numbers it works fine so I'm confused what the issue is.

I'm using this link to map RN to EC numbers: https://rest.kegg.jp/link/reaction/ec I checked and the link has the rn to ec conversion in it so it should work. Does anyone know what could be causing the issue?

Here's my code:

# Load libraries
library(ggkegg)
library(BiocFileCache)
library(viridis)

# Fetch and cache RN to EC map
url <- "https://rest.kegg.jp/link/reaction/ec"
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") |>
  setNames(convert$V2)

# Define the pathway ID
pathway_id <- "dosa00300"  # Change depending on the pathway you want to map

# Create a graph of the pathway
g <- pathway(pathway_id) |>
  mutate(ec = rntoec[reaction])

# Define a vector of node names to highlight
nodes_to_highlight <- reaction

# Add log fold changes (LFCs) to the graph
LFC_vector <- LFCs  # Make sure LFCs is a vector with values for each corresponding reaction number

g <- g %>%
  mutate(
    LFC = ifelse(reaction %in% nodes_to_highlight, LFC_vector, NA),
    Color = ifelse(LFC <= -1, "red", ifelse(LFC >= 1, "green", NA)) # red for repressed genes and green for induced genes
  )

# Create a pathway diagram with colors to visualize LFCs
gg <- g |>
  filter(type %in% c("compound", "gene")) |>
  ggraph(layout = "manual", x = x, y = y) +
  geom_node_rect(aes(fill = Color), size = 5) +  # Use Color for the fill aesthetic
  scale_fill_identity() + # Use identity scale for custom colors
  overlay_raw_map("dosa00300") + # Make diagram look better (change depending on pathway you're mapping)
  theme_minimal() +  # Set background to white
  theme_void() +  # Remove x and y axis
  ggtitle("Induced (Green) and Repressed (Red) Genes in Lysine Biosythesis Pathway - 0 hr Timepoint")

gg
RStudio ggkegg • 291 views
ADD COMMENT

Login before adding your answer.

Traffic: 793 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

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

Powered by the version 2.3.6