clusterProfiler icon indicating copy to clipboard operation
clusterProfiler copied to clipboard

ko2name run error

Open zhaohanshuang opened this issue 1 year ago • 1 comments

Hi, When I try to run the following command, I don't get the metabolic pathway for the ko2name comment, they are all NA My is data is bacterial metagenomics, how is this going to be solved? data <- read.table("ID.txt", header = TRUE) x <- bitr_kegg(data$ID,"kegg","Path","ko") y <- ko2name(x$Path)

1689475420256

thanks! ID.txt

zhaohanshuang avatar Jul 16 '23 02:07 zhaohanshuang

Maybe this alternative code be of help to achieve your goal? Specifically the content of the KEGGPATHID2NAME slot? (which I 'extracted' as term2name).

Both term2gene and term2name can be used for the generic functions enricher and GSEA; both are part of clusterProfiler. Be sure to check the help pages for these functions!


> library(clusterProfiler)
> 
> ko.pathways <- download_KEGG(species="ko")
> 
> term2gene <- ko.pathways$KEGGPATHID2EXTID
> 
> term2name <- ko.pathways$KEGGPATHID2NAME
> 
> head(term2gene)
      from     to
2  ko00010 K00001
4  ko00010 K00002
6  ko00010 K00016
8  ko00010 K00114
10 ko00010 K00121
12 ko00010 K00128
> 
> head(term2name)
     from                                           to
1 ko01100                           Metabolic pathways
2 ko01110        Biosynthesis of secondary metabolites
3 ko01120 Microbial metabolism in diverse environments
4 ko01200                            Carbon metabolism
5 ko01210              2-Oxocarboxylic acid metabolism
6 ko01212                        Fatty acid metabolism
> 
> 
> packageVersion("clusterProfiler")
[1] ‘4.8.2’
>

** added**

... and then for example (using the object x you generated):

> rownames(term2name) <- term2name[,"from"]
> out <- term2name[x$Path,]
> 
> head(out)
           from                                to
ko00010 ko00010      Glycolysis / Gluconeogenesis
ko00051 ko00051   Fructose and mannose metabolism
ko00053 ko00053 Ascorbate and aldarate metabolism
ko00071 ko00071            Fatty acid degradation
ko00100 ko00100              Steroid biosynthesis
ko00120 ko00120    Primary bile acid biosynthesis
> 
> tail(out)
             from                                                to
ko05143   ko05143                           African trypanosomiasis
ko05204   ko05204             Chemical carcinogenesis - DNA adducts
ko05204.1 ko05204             Chemical carcinogenesis - DNA adducts
ko05207   ko05207     Chemical carcinogenesis - receptor activation
ko05208   ko05208 Chemical carcinogenesis - reactive oxygen species
ko05219   ko05219                                    Bladder cancer
> 

guidohooiveld avatar Jul 19 '23 08:07 guidohooiveld