library(metpath)
#> metpath 1.0.2 (2022-09-19 20:04:20)
#> 
#> Attaching package: 'metpath'
#> The following object is masked from 'package:stats':
#> 
#>     filter

Brief introduction

Two widely used metabolic pathways are utilized in metpath, namely KEGG and HMDB/SMPDB.

KEGG pathway

We can just download the KEGG online or from the metpaht pacakge.

kegg_hsa_pathway = 
  get_kegg_pathway(local = TRUE, organism = "hsa", threads = 3)

The date when the pathway database is downloaded will show.

kegg_hsa_pathway
#> ---------Pathway source&version---------
#> KEGG & 2021-12-13 
#> -----------Pathway information------------
#> 345 pathways 
#> 334 pathways have genes 
#> 0 pathways have proteins 
#> 281 pathways have compounds 
#> Pathway class (top 10): Metabolism; Carbohydrate metabolism;Metabolism; Lipid metabolism 
#> 

Just type the pathway and the information of it will show.

We can also download the latest version of KEGG pathway. Make sure the internet is good and it will take a while to download.

kegg_hsa_pathway2 = 
  get_kegg_pathway(local = FALSE, organism = "hsa", threads = 3)
kegg_hsa_pathway2
#> ---------Pathway source&version---------
#> KEGG & 2022-02-19 
#> -----------Pathway information------------
#> 345 pathways 
#> 334 pathways have genes 
#> 0 pathways have proteins 
#> 281 pathways have compounds 
#> Pathway class (top 10): Metabolism; Carbohydrate metabolism;Metabolism; Lipid metabolism 
#> 

KEGG compound

We can also get the KEGG compound database using metpath.

kegg_compound = 
  get_kegg_compound(local = TRUE, threads = 5)
kegg_compound
#> -----------Base information------------
#> Version: 2021-12-21 
#> Source: KEGG 
#> Link: https://www.genome.jp/kegg/compound/ 
#> Creater: Xiaotao Shen ( shenxt@stanford.edu )
#> Without RT informtaion
#> -----------Spectral information------------
#> There are 13 items of metabolites in database:
#> Lab.ID; Compound.name; mz; RT; CAS.ID; HMDB.ID; KEGG.ID; Formula; mz.pos; mz.neg; Submitter; PubChem.ID; synonym 
#> There are 16395 metabolites in total
#> There are 0 metabolites in positive mode with MS2 spectra.
#> There are 0 metabolites in negative mode with MS2 spectra.
#> Collision energy in positive mode (number:):
#> Total number: 0 
#>  
#> Collision energy in negative mode:
#> Total number: 0 
#>  
#> 

We can also download the online KEGG compound database. But it will take a long time.

kegg_compound2 = 
  get_kegg_compound(local = FALSE, threads = 5)

HMDB pathway

We can just download the HMDB online or from the metpaht pacakge.

hmdb_hsa_pathway = 
  get_hmdb_pathway(threads = 3)

The date when the pathway database is downloaded will show.

hmdb_hsa_pathway
#> ---------Pathway source&version---------
#> SMPDB & 2021-03-02 
#> -----------Pathway information------------
#> 48703 pathways 
#> 0 pathways have genes 
#> 48642 pathways have proteins 
#> 48674 pathways have compounds 
#> Pathway class (top 10): Metabolic;primary_pathway 
#> 

Just type the pathway and the information of it will show.

HMDB compound

We can also get the HMDB compound database using metpath.

hmdb_compound = 
  get_hmdb_compound(threads = 5)
hmdb_compound
#> -----------Base information------------
#> Version: 2021-12-21 
#> Source: HMDB 
#> Link: http://www.hmdb.ca/ 
#> Creater: Xiaotao Shen ( shenxt@stanford.edu )
#> Without RT informtaion
#> -----------Spectral information------------
#> There are 40 items of metabolites in database:
#> Lab.ID; Compound.name; mz; RT; CAS.ID; HMDB.ID; KEGG.ID; Formula; Biospecimen.locations; Tissue.locations; Status; Secondary.accession.numbers; Synonyms; Average.molecular.weight; IUPQC.name; Traditional.IUPAC.name; SMILES; inchi; inchikey; State; Foodb.ID; Chemspider.ID; Pubchem.compound.ID; Drugbank.ID; CHEBI.ID; PDB.ID; Phenol.explorer.compound.ID; Knapsack.ID; BIGG.ID; Wikipedia.ID; METLIN.ID; Biocyc.ID; Kingdom; Super.class; Class; Sub.class; Source; Pathway; Pathway2; Disease 
#> There are 114004 metabolites in total
#> There are 0 metabolites in positive mode with MS2 spectra.
#> There are 0 metabolites in negative mode with MS2 spectra.
#> Collision energy in positive mode (number:):
#> Total number: 0 
#>  
#> Collision energy in negative mode:
#> Total number: 0 
#>  
#> 

Processing of pathway class

Brief information of pathway database

length(kegg_hsa_pathway)
#> [1] 345
get_pathway_class(kegg_hsa_pathway)
#> # A tibble: 43 × 2
#>    class                                                                       n
#>    <chr>                                                                   <int>
#>  1 Cellular Processes; Cell growth and death                                   8
#>  2 Cellular Processes; Cell motility                                           1
#>  3 Cellular Processes; Cellular community - eukaryotes                         5
#>  4 Cellular Processes; Transport and catabolism                                7
#>  5 Environmental Information Processing; Membrane transport                    1
#>  6 Environmental Information Processing; Signal transduction                  26
#>  7 Environmental Information Processing; Signaling molecules and interact…     5
#>  8 Genetic Information Processing; Folding, sorting and degradation            7
#>  9 Genetic Information Processing; Replication and repair                      7
#> 10 Genetic Information Processing; Transcription                               3
#> # … with 33 more rows

Accessor

kegg_hsa_pathway[1:5]
#> ---------Pathway source&version---------
#> KEGG & 2021-12-13 
#> -----------Pathway information------------
#> 5 pathways 
#> 5 pathways have genes 
#> 0 pathways have proteins 
#> 5 pathways have compounds 
#> Pathway class (top 10): Metabolism; Carbohydrate metabolism 
#> 
head(names(kegg_hsa_pathway))
#> [1] "hsa00010" "hsa00020" "hsa00030" "hsa00040" "hsa00051" "hsa00052"
names(kegg_hsa_pathway[c("hsa00010", "hsa00020")])
#> [1] "hsa00010" "hsa00020"

Extract data

database_info(kegg_hsa_pathway)
#> $source
#> [1] "KEGG"
#> 
#> $version
#> [1] "2021-12-13"