This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Is there a way to download the KEGG output (gene - KO) directly?

Hello everyone!

I'm thinking of getting the KEGG/Koala/Kofamscan output of around 50 bacteria.

The output should be something like this:

gene_01 K?????

gene_02 K?????

gene_03 K?????

Usually I would get the genome from NCBI, annotate the genes using RAST or other gene annotation tools, then run the AA fasta into Kofamscan to get the final output.

I was just wondering if there is a way to get the KO output file directly.

Bioinformatics is not our strong suit so I usually try out things as I go about our research.

Thank you in advance!

-Adham

Edit: Deleted this part as I realized that you cannot get the htext for KOs from BRITE; and I manually edited the pathway htext:

I tried manually editing the htext files but it takes a bit of time...

kegg gene annotation

1 answer

I have old code that rips this using KEGGREST. Not guaranteed to be most efficient but should suit you.

library(KEGGREST)

res <- keggLink('pathway', 'hsa')
pathways <- data.frame(
  kegg_gene_id=names(res),
  kegg_pathway_id=as.character(res)
)

do.query <- function(id_lst) {
  res <- list()
  i <- 1
  while ( i < length(id_lst) ) {
    j <- min(length(id_lst), i+9)
    qry <- keggGet(id_lst[i:j])
    res <- c(res, qry)
    i <- j + 1
  }
  res
}

ids <- unique(pathways$kegg_pathway_id)
res <- do.query(ids)
path2name <- data.frame(
  kegg_pathway_id=ids,
  pathway_name=sapply(res, function(x) { x$NAME})
)

ids <- unique(pathways$kegg_gene_id)
res <- do.query(ids)

gene2name <- data.frame(
  kegg_gene_id=ids,
  gene_name=sapply(res, function(x) { x$NAME }),
  gene_symbol=sapply(res, function(x) { gsub('([^,]+).*', '\\1', x$SYMBOL) })
)

pathways <- merge(pathways, path2name, by='kegg_pathway_id')
pathways <- merge(pathways, gene2name, by='kegg_gene_id')

head(pathways)

Thank you for this!

Tried installing KEGGREST but kept running into problems during installation.

I'll try looking into it some more and will try to add updates.

-Adham

Log in to answer this question.