# (1)
# A toy example on a very small subsample of a microarray data set
datafilename <- system.file("extdata", "transcripto_very_small_sample.txt", package="DRomics")
o <- microarraydata(datafilename, check = TRUE, norm.method = "cyclicloess")
s_quad <- itemselect(o, select.method = "quadratic", FDR = 0.01)
f <- drcfit(s_quad, progressbar = TRUE)
r <- bmdcalc(f)
# Plot of all the BMD values with color dose-response gradient
#
bmdplotwithgradient(r$res, BMDtype = "zSD")
# \donttest{
# Same plot without signal scaling
#
bmdplotwithgradient(r$res, BMDtype = "zSD", scaling = FALSE)
# Plot of all the BMD values with color dose-response gradient
# with definition of xmax from the maximal tested dose
#
bmdplotwithgradient(r$res, BMDtype = "zSD",
xmax = max(f$omicdata$dose))
# Add of item labels
bmdplotwithgradient(r$res, BMDtype = "zSD",
xmax = max(f$omicdata$dose), add.label = TRUE)
# The same plot in raw scale (we can fix xmin at 0 in this case)
#
bmdplotwithgradient(r$res, BMDtype = "zSD", xmin = 0,
BMD_log_transfo = FALSE)
# The same plot in log scale with defining xmin and xmax at a chosen values
#
bmdplotwithgradient(r$res, BMDtype = "zSD",
xmin = min(f$omicdata$dose[f$omicdata$dose != 0] / 2),
xmax = max(f$omicdata$dose),
BMD_log_transfo = TRUE)
# Plot of all the BMD values with color dose-response gradient
# faceted by response trend and shaped by model
#
bmdplotwithgradient(r$res, BMDtype = "zSD",
facetby = "trend", shapeby = "model")
# same plot changing the names of the facets
levels(r$res$trend)
levels(r$res$trend) <- c("bell shape", "decreasing", "increasing", "U shape")
bmdplotwithgradient(r$res, BMDtype = "zSD",
facetby = "trend", shapeby = "model")
# same plot changing the labels of the legends
# and inversing the two guides
if (require(ggplot2)) bmdplotwithgradient(r$res, BMDtype = "zSD",
facetby = "trend", shapeby = "model") +
labs(col = "signal value", shape = "model") +
guides(colour = guide_colourbar(order = 1),
shape = guide_legend(order = 2))
# (2)
# 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
extendedres <- merge(x = res, y = annot, by.x = "id", by.y = "metab.code")
head(extendedres)
### (2.a) BMDplot with gradient by pathway
bmdplotwithgradient(extendedres, BMDtype = "zSD",
facetby = "path_class",
xmax = 7.76, # maximal tested dose in those data
shapeby = "trend")
### (2.a) BMDplot with gradient by pathway without scaling
bmdplotwithgradient(extendedres, BMDtype = "zSD",
facetby = "path_class", xmax = 7.76,
shapeby = "trend", scaling = FALSE)
# (2.b) BMDplot with gradient by pathway
# forcing the limits of the colour gradient at other
# values than observed minimal and maximal values of the signal
bmdplotwithgradient(extendedres, BMDtype = "zSD",
facetby = "path_class",
shapeby = "trend",
limits4colgradient = c(-1, 1))
# (2.c) The same example changing the gradient colors and the line size
bmdplotwithgradient(extendedres, BMDtype = "zSD",
facetby = "path_class",
shapeby = "trend",
line.size = 3,
lowercol = "darkgreen", uppercol = "orange")
# (2.d) The same example with only lipid metabolism pathclass
# and identification of the metabolites
LMres <- extendedres[extendedres$path_class == "Lipid metabolism", ]
bmdplotwithgradient(LMres, BMDtype = "zSD",
line.size = 3,
add.label = TRUE, label.size = 3)
# (3)
# An example on a microarray data set (a subsample of a greater data set)
#
datafilename <- system.file("extdata", "transcripto_sample.txt", package="DRomics")
(o <- microarraydata(datafilename, check = TRUE, norm.method = "cyclicloess"))
(s_quad <- itemselect(o, select.method = "quadratic", FDR = 0.001))
(f <- drcfit(s_quad, progressbar = TRUE))
(r <- bmdcalc(f))
bmdplotwithgradient(r$res, BMDtype = "zSD",
facetby = "trend",
shapeby = "model")
# without scaling
bmdplotwithgradient(r$res, BMDtype = "zSD",
scaling = FALSE, facetby = "trend",
shapeby = "model")
# }
Run the code above in your browser using DataLab