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...
Thank 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)