Name Mapping#

When using mantra’s neo4j database to generate a metabolic network matching experimental data, you will need to convert feature names or their database IDs to internal IDs.

Microbial Organisms#

Microbes are simply accessed by their species name, e.g. “Bacteroides uniformis”. Importantly, make sure names start with a capital letter and that separation is happening through whitespaces and not underscores or similar.

Metabolites#

Recommended database IDs are KEGG and HMDB, followed by Reactome and Virtual Metabolic Human. Some other database like ChEBI or NCBI are supported, but are likely to give less matches.

For mapping metabolite names and database IDs, we provide some functions. Their usage is shown in the following code snippets.

We start by loading the required packages/functions and load a pre-defined set of metabolites, specified by their “common” name.

 1import json
 2import pathlib
 3
 4from pymantra.namemapping import metaboanalyst_name_mapping, NameMapper
 5
 6
 7# just a list of metabolite names, you can find the file here:
 8# TODO: add github file link
 9metabolites = json.load(
10    open(pathlib.Path(__file__).parent.absolute() / "metabolites.json", "r"))
11print(metabolites)

Next, we query the database IDs for these common names. For this, mantra uses the Metaboanalyst API. In case you already have database IDs for your metabolites, you can skip this step.

13# getting database IDs from metabolite names
14# can be skipped, if at least one ID type per metabolite is known
15# this might take a few second to run
16name_map = metaboanalyst_name_mapping(metabolites)

Lastly, we use an internal database to convert from (in this case) HMDB IDs to mantra IDs. For all available database sources options please see the documentation of NameMapper.

18# we use HMDB IDs to map to mantra IDs
19mapper = NameMapper()
20mantra_ids = {
21    hmdb_id: mapper.map_id(hmdb_id, "hmdb", "internal")
22    for hmdb_id in name_map["HMDB"]
23}
24print(mantra_ids)

Full Example Code#

 1import json
 2import pathlib
 3
 4from pymantra.namemapping import metaboanalyst_name_mapping, NameMapper
 5
 6
 7# just a list of metabolite names, you can find the file here:
 8# TODO: add github file link
 9metabolites = json.load(
10    open(pathlib.Path(__file__).parent.absolute() / "metabolites.json", "r"))
11print(metabolites)
12
13# getting database IDs from metabolite names
14# can be skipped, if at least one ID type per metabolite is known
15# this might take a few second to run
16name_map = metaboanalyst_name_mapping(metabolites)
17
18# we use HMDB IDs to map to mantra IDs
19mapper = NameMapper()
20mantra_ids = {
21    hmdb_id: mapper.map_id(hmdb_id, "hmdb", "internal")
22    for hmdb_id in name_map["HMDB"]
23}
24print(mantra_ids)