R code for KEGG pathways output
0
0
Entering edit mode
6 months ago
doramora ▴ 10

Hello! I was trying to write a code in R, where I input all my genes names and I wanted to get an output as two columns "gene name - KEGG pathways". This code kind of work, if the amount of genes is not more than 500. I've got 8000 genes and after 500 in the second column I see "No pathways found" only. Maybe you can see a prodlem in my code? Or this is just a KEGGREST threshold...

enter image description hereThank you.

library(KEGGREST)
library(dplyr)

genes_txt <- read.table('C:\\gene_numbers.txt')
genes <- as.data.frame(genes_txt)


get_kegg_pathways <- function(gene) {
  pathway_info <- tryCatch({
    keggGet(gene)
  }, error = function(e) {
    return(NULL)
  })
  if (!is.null(pathway_info[[1]]$PATHWAY)) {
    pathways <- pathway_info[[1]]$PATHWAY
    return(paste(pathways, collapse = "; "))
  } 
   else {
    return("No pathways found")
  }
  }

pathways_new <- sapply(genes, get_kegg_pathways)
df <- data.frame(pathways_new)
KEGGREST dplyr KEGG R • 289 views
ADD COMMENT

Login before adding your answer.

Traffic: 1957 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