| trans_metab | R Documentation |
trans_metab object for metabolite analysis.This class is a wrapper for a series of metabolite analysis, including origin inference and pathway enrichment.
new()Create the trans_metab object.
trans_metab$new(metab = NULL, microb = NULL)
metabdefault NULL; metabolite data. A microtable object or data.frame object.
If the input is a data.frame object, the function can judge whether it is abundance table and preprocess the data.
microbdefault NULL; A microtable object.
data_metab and data_microb stored in the object.
\donttest{
data(soil_metab)
data(soil_microb)
t1 <- trans_metab$new(metab = soil_metab, microb = soil_microb)
}
cal_match()Matching compound names against the database from TidyMass2 (DOI: 10.1038/s41467-026-68464-7) to facilitate the acquisition of standardized nomenclature. An alternative way is to use MetaboAnalyst website (https://www.metaboanalyst.ca/faces/upload/ConvertView.xhtml).
trans_metab$cal_match( database_path = "./metorigindb_split_202602", method = "jw", maxDist = 0.3, ... )
database_pathdefault "./metorigindb_split_202602"; directory path of the downloaded database. Please download the pre-collated metorigindb database (RData format) from zenodo (https://zenodo.org/records/18618912) and extract the compressed archive.
methoddefault "jw"; method of approximate string matching. Default "jw" is Jaro-Winkler distance.
See the method parameter of amatch function in stringdist package.
maxDistdefault 0.3; See the maxDist parameter of amatch function in stringdist package.
...parameters passed to amatch function of stringdist package.
res_match table stored in the object.
\dontrun{
t1$cal_match()
}
cal_origin()Metabolite origin inference based on the preprocessed database from TidyMass2 (DOI: 10.1038/s41467-026-68464-7)
trans_metab$cal_origin( database_path = "./metorigindb_split_202602", match_col = "names", match_names_distance = 0, bac_level = "Genus" )
database_pathdefault "./metorigindb_split_202602"; directory path of the downloaded database. Please download the pre-collated metorigindb database (RData format) from zenodo (https://zenodo.org/records/18618912) and extract the compressed archive.
match_coldefault "names"; How to match to the data of metorigindb. Default "names" means using the input names of metabolites. If the tax_table has other columns like "HMDB_ID" or "KEGG_ID", the user can provide more items, like c("names", "HMDB_ID"). The program will automatically identify the corresponding columns from the input data based on keywords such as HMDB or KEGG, and then match them with the database.
match_names_distancedefault 0; distance threshold used if the res_match_table is found in the object,
which is calculated from the cal_match function. Available for the "names" option in match_col parameter.
bac_leveldefault "Genus"; which bacteria level is used to parse the taxa in the data_microb of object.
The function can automatically match the taxa those found in the input data.
res_origin_rawtable table and res_origin_list list stored in the object.
res_origin_rawtable is the origin table extracted from the metorigindb database based on the match of name or other ID.
In res_origin_list, name is the metabolite; each element is the taxa that may produce the metabolite.
\dontrun{
t1$cal_origin()
t1$cal_origin(match_col = c("names", "HMDB_ID", "KEGG_ID"))
}
cal_origin_network()Metabolite-bacteria network based on the res_origin_list data from the cal_origin function
trans_metab$cal_origin_network()
igraph format network.
\dontrun{
t1$cal_origin_network()
}
cal_pathway()Map metabolites to pathways based on a database (KEGG, MetaCyc, Reactome, or custom).
trans_metab$cal_pathway(
db_type = c("kegg", "metacyc", "reactome", "custom")[1],
db_path = NULL,
id_type = NULL,
save_db = FALSE
)db_typedefault "kegg"; pathway database type, one of "kegg", "metacyc", "reactome", "custom".
db_pathdefault NULL; pathway database file path (RData format). For KEGG: if NULL, will attempt to fetch from KEGG REST API. For MetaCyc/Reactome/Custom: must provide local database file path.
id_typedefault NULL; column name in tax_table containing metabolite IDs. If NULL, will be automatically set based on db_type: "KEGG_ID" for kegg, "METACYC_ID" for metacyc, "REACTOME_ID" for reactome, "CUSTOM_ID" for custom.
save_dbdefault FALSE; whether save the fetched database (KEGG) to the local folder.
res_pathway_map (data.frame) stored in the object.
Contains columns: pathway_id, pathway_name, metab_id, metab_name.
\dontrun{
# KEGG pathway mapping (online)
t1$cal_pathway()
# KEGG pathway mapping (local database)
t1$cal_pathway(db_type = "kegg", db_path = "kegg_pathway_db.RData")
}
cal_pathway_enrich()Perform pathway enrichment analysis for target metabolites using Fisher's exact test.
trans_metab$cal_pathway_enrich( target_metabs = NULL, background_metabs = NULL, p_adjust_method = "BH", p_cutoff = 0.05, min_metab_count = 3 )
target_metabscharacter vector; target metabolite names (row names in tax_table), e.g., differential metabolites. If NULL, will use all metabolites in the pathway mapping.
background_metabscharacter vector; background metabolite names (row names in tax_table). If NULL, will use all metabolites in the pathway mapping result.
p_adjust_methoddefault "BH"; p-value adjustment method. See p.adjust function.
p_cutoffdefault 0.05; significance threshold for adjusted p-value.
min_metab_countdefault 3; minimum number of background metabolites in a pathway for enrichment test.
res_pathway_enrich data.frame stored in the object.
Contains: pathway_id, pathway_name, metab_count, background_count,
enrichment_factor, p_value, p_adjust, significant.
\dontrun{
t1$cal_pathway()
target <- rownames(t1$data_metab$otu_table)[1:10]
t1$cal_pathway_enrich(target_metabs = target)
}
plot_pathway_enrich()Visualize pathway enrichment analysis results.
trans_metab$plot_pathway_enrich(
plot_type = c("bubble", "bar")[1],
top_n = 20,
color_by = "p_adjust",
size_by = "metab_count",
order_by = "p_adjust",
color_gradient_low = "#132B43",
color_gradient_high = "#56B1F7"
)plot_typedefault "bubble"; plot type, "bubble" or "bar".
top_ndefault 20; number of top pathways to display.
color_bydefault "p_adjust"; column name for color mapping.
size_bydefault "metab_count"; column name for size mapping (only for bubble plot).
order_bydefault "p_adjust"; column name for ordering pathways.
color_gradient_lowdefault "#132B43"; color for low values (e.g., high p-value = not significant).
color_gradient_highdefault "#56B1F7"; color for high values (e.g., low p-value = significant).
ggplot2 object.
\dontrun{
t1$cal_pathway()
target <- rownames(t1$data_metab$otu_table)[1:10]
t1$cal_pathway_enrich(target_metabs = target)
t1$plot_pathway_enrich()
}
cal_pathway_network()Build metabolite-pathway network based on pathway mapping and enrichment results.
trans_metab$cal_pathway_network( significant_only = TRUE, p_cutoff = 0.05, use_enrichment = TRUE )
significant_onlydefault TRUE; whether to use only significant enriched pathways.
p_cutoffdefault 0.05; p-value cutoff for significant pathways (used only when significant_only = TRUE).
use_enrichmentdefault TRUE; whether to require enrichment results. If FALSE, build network from all pathway mappings.
igraph object representing metabolite-pathway bipartite network.
\dontrun{
t1$cal_pathway()
target <- rownames(t1$data_metab$otu_table)[1:50]
t1$cal_pathway_enrich(target_metabs = target)
net <- t1$cal_pathway_network()
}
clone()The objects of this class are cloneable with this method.
trans_metab$clone(deep = FALSE)
deepWhether to make a deep clone.
## ------------------------------------------------
## Method `trans_metab$new`
## ------------------------------------------------
data(soil_metab)
data(soil_microb)
t1 <- trans_metab$new(metab = soil_metab, microb = soil_microb)
## ------------------------------------------------
## Method `trans_metab$cal_match`
## ------------------------------------------------
## Not run:
t1$cal_match()
## End(Not run)
## ------------------------------------------------
## Method `trans_metab$cal_origin`
## ------------------------------------------------
## Not run:
t1$cal_origin()
t1$cal_origin(match_col = c("names", "HMDB_ID", "KEGG_ID"))
## End(Not run)
## ------------------------------------------------
## Method `trans_metab$cal_origin_network`
## ------------------------------------------------
## Not run:
t1$cal_origin_network()
## End(Not run)
## ------------------------------------------------
## Method `trans_metab$cal_pathway`
## ------------------------------------------------
## Not run:
# KEGG pathway mapping (online)
t1$cal_pathway()
# KEGG pathway mapping (local database)
t1$cal_pathway(db_type = "kegg", db_path = "kegg_pathway_db.RData")
## End(Not run)
## ------------------------------------------------
## Method `trans_metab$cal_pathway_enrich`
## ------------------------------------------------
## Not run:
t1$cal_pathway()
target <- rownames(t1$data_metab$otu_table)[1:10]
t1$cal_pathway_enrich(target_metabs = target)
## End(Not run)
## ------------------------------------------------
## Method `trans_metab$plot_pathway_enrich`
## ------------------------------------------------
## Not run:
t1$cal_pathway()
target <- rownames(t1$data_metab$otu_table)[1:10]
t1$cal_pathway_enrich(target_metabs = target)
t1$plot_pathway_enrich()
## End(Not run)
## ------------------------------------------------
## Method `trans_metab$cal_pathway_network`
## ------------------------------------------------
## Not run:
t1$cal_pathway()
target <- rownames(t1$data_metab$otu_table)[1:50]
t1$cal_pathway_enrich(target_metabs = target)
net <- t1$cal_pathway_network()
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.