Andres Suarez

Generation

generate functionWed, 14 Jun 2023

i have a list with the kegg ID of compound and i need to link this compound with the with the metabolic pathway involved, using KEGGREST R package

library(KEGGREST) library(data.table) kg_id <- 'C00008' # using the kegg_get function to link the compound with the pathway # using the compound_pathway function to link again the compound with the pathway # flatten the list # convert to data.frame # function to get the pathway associated with the compound get_pathway <- function(kg_id){ pw <- NULL pw <- kegg_get(kg_id, db = "compound", option = "pathway")$data pw <- compound_pathway(kg_id) pw <- unlist(pw) pw <- as.data.frame(pw, stringsAsFactors = FALSE) return(pw) } # function to parse the pathway get_pathway(kg_id)

Want to kickstart your project?Use the new AI Studio to create your code