# (1) a toy example (a very small subsample of a microarray data set)
#
datafilename <- system.file("extdata", "transcripto_very_small_sample.txt",
package = "DRomics")
# to test the package on a small but not very small data set
# use the following commented line
# 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)
set.seed(1234) # to get reproducible results with a so small number of iterations
(b <- bmdboot(r, niter = 5)) # with a non reasonable value for niter
# !!!! TO GET CORRECT RESULTS
# !!!! niter SHOULD BE FIXED FAR LARGER , e.g. to 1000
# !!!! but the run will be longer
b$res
plot(b) # plot of BMD.zSD after removing of BMDs with infinite upper bounds
# \donttest{
# same plot in raw scale (without log transformation of BMD values)
plot(b, BMD_log_transfo = FALSE)
# plot of BMD.zSD without removing of BMDs
# with infinite upper bounds
plot(b, remove.infinite = FALSE)
# }
# bootstrap on only a subsample of items
# with a greater number of iterations
# \donttest{
chosenitems <- r$res$id[1:5]
(b.95 <- bmdboot(r, items = chosenitems,
niter = 1000, progressbar = TRUE))
b.95$res
# Plot of fits with BMD values and confidence intervals
# with the default BMD.zSD
plot(f, items = chosenitems, BMDoutput = b.95, BMDtype = "zSD")
# with the default BMD.xfold
plot(f, items = chosenitems, BMDoutput = b.95, BMDtype = "xfold")
# same bootstrap but changing the default confidence level (0.95) to 0.90
(b.90 <- bmdboot(r, items = chosenitems,
niter = 1000, conf.level = 0.9, progressbar = TRUE))
b.90$res
# }
# (2) an example on a microarray data set (a subsample of a greater data set)
#
# \donttest{
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))
(b <- bmdboot(r, niter = 100)) # niter to put at 1000 for a better precision
# different plots of BMD-zSD
plot(b)
plot(b, by = "trend")
plot(b, by = "model")
plot(b, by = "typology")
# a plot of BMD-xfold (by default BMD-zSD is plotted)
plot(b, BMDtype = "xfold")
# }
# (3) Comparison of parallel and non parallel implementations
#
# \donttest{
# to be tested with a greater number of iterations
if(!requireNamespace("parallel", quietly = TRUE)) {
if(parallel::detectCores() > 1) {
system.time(b1 <- bmdboot(r, niter = 100, progressbar = TRUE))
system.time(b2 <- bmdboot(r, niter = 100, progressbar = FALSE, parallel = "snow", ncpus = 2))
}}
# }
Run the code above in your browser using DataLab