# (1)
# Plot of BMD values with color dose-response gradient
# faceted by metabolic pathway (from annotation of the selected items)
# and shaped by dose-response trend
# An example from the paper published by Larras et al. 2020
# in Journal of Hazardous Materials
# https://doi.org/10.1016/j.jhazmat.2020.122727
# A example of plot obtained with this function is in Figure 5 in Larras et al. 2020
# the dataframe with metabolomic results (output $res of bmdcalc() or bmdboot() functions)
resfilename <- system.file("extdata", "triclosanSVmetabres.txt", package="DRomics")
res <- read.table(resfilename, header = TRUE, stringsAsFactors = TRUE)
str(res)
# the dataframe with annotation of each item identified in the previous file
# each item may have more than one annotation (-> more than one line)
annotfilename <- system.file("extdata", "triclosanSVmetabannot.txt", package="DRomics")
annot <- read.table(annotfilename, header = TRUE, stringsAsFactors = TRUE)
str(annot)
# Merging of both previous dataframes
# in order to obtain an extenderes dataframe
metabextendedres <- merge(x = res, y = annot, by.x = "id", by.y = "metab.code")
head(metabextendedres)
### (1.a) BMDplot by pathway shaped by trend
bmdplot(metabextendedres, BMDtype = "zSD",
facetby = "path_class",
shapeby = "trend")
# \donttest{
### (1.b) BMDplot by pathway with items labels
bmdplot(metabextendedres, BMDtype = "zSD",
facetby = "path_class",
add.label = TRUE,
label.size = 2)
### (1.c) BMDplot by pathway with confidence intervals
bmdplot(metabextendedres, BMDtype = "zSD",
facetby = "path_class",
add.CI = TRUE)
### (1.d) BMDplot by pathway with confidence intervals
# in BMD raw scale (not default log scale)
bmdplot(metabextendedres, BMDtype = "zSD",
facetby = "path_class",
add.CI = TRUE,
BMD_log_transfo = FALSE)
### (1.e) BMDplot by pathway with confidence intervals
# colored by trend and playing with graphical parameters
bmdplot(metabextendedres, BMDtype = "zSD",
facetby = "path_class",
add.CI = TRUE,
colorby = "trend",
point.size = 2,
point.alpha = 0.5,
line.size = 0.8,
line.alpha = 0.5)
# (2)
# An example with two molecular levels
#
# Import the dataframe with transcriptomic results
contigresfilename <- system.file("extdata", "triclosanSVcontigres.txt", package = "DRomics")
contigres <- read.table(contigresfilename, header = TRUE, stringsAsFactors = TRUE)
str(contigres)
# Import the dataframe with functional annotation (or any other descriptor/category
# you want to use, here KEGG pathway classes)
contigannotfilename <- system.file("extdata", "triclosanSVcontigannot.txt", package = "DRomics")
contigannot <- read.table(contigannotfilename, header = TRUE, stringsAsFactors = TRUE)
str(contigannot)
# Merging of both previous dataframes
contigextendedres <- merge(x = contigres, y = contigannot, by.x = "id", by.y = "contig")
# to see the structure of this dataframe
str(contigextendedres)
### Merge metabolomic and transcriptomic results
extendedres <- rbind(metabextendedres, contigextendedres)
extendedres$molecular.level <- factor(c(rep("metabolites", nrow(metabextendedres)),
rep("contigs", nrow(contigextendedres))))
str(extendedres)
### BMD plot per pathway with molecular level coding for color
bmdplot(extendedres, BMDtype = "zSD",
facetby = "path_class",
colorby = "molecular.level",
point.alpha = 0.3)
### BMD plot per pathway and per molecular level
# for a selection of pathways
chosen_path_class <- c("Membrane transport", "Lipid metabolism")
ischosen <- is.element(extendedres$path_class, chosen_path_class)
bmdplot(extendedres[ischosen, ], BMDtype = "zSD",
facetby = "path_class",
facetby2 = "molecular.level",
colorby = "trend",
point.size = 2,
add.CI = TRUE)
# }
Run the code above in your browser using DataLab