This is a test version of Biostars. For the public version, visit https://www.biostars.org.
R code for KEGG pathways output

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

0 answers

No answers yet.

Log in to answer this question.