Skip to content

Commit

Permalink
another trial to lighten examples and tests for passing CRAN check
Browse files Browse the repository at this point in the history
  • Loading branch information
Marie-Laure DELIGNETTE-MULLER committed Sep 22, 2020
1 parent 295aba8 commit 3427a64
Show file tree
Hide file tree
Showing 16 changed files with 97 additions and 75 deletions.
8 changes: 4 additions & 4 deletions man/RNAseqdata.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ Marie-Laure Delignette-Muller
# (see ? Zhou for details)
#
datafilename <- system.file("extdata", "RNAseq_sample.txt", package="DRomics")
(o <- RNAseqdata(datafilename, check = TRUE, transfo.method = "rlog"))
plot(o)
(o <- RNAseqdata(datafilename, check = TRUE, transfo.method = "vst"))
plot(o, range = 1e6)

# If you want to use your own data set just replace datafilename,
# the first argument of RNAseqdata(),
Expand All @@ -143,8 +143,8 @@ plot(o)
# Zhou_kidney_pce (see ?Zhou for details)
data(Zhou_kidney_pce)
subsample <- Zhou_kidney_pce[1:1000, ]
(o <- RNAseqdata(subsample, check = TRUE, transfo.method = "rlog"))
plot(o)
(o <- RNAseqdata(subsample, check = TRUE, transfo.method = "vst"))
plot(o, range = 1e6)


# (2) transformation with two methods on the whole data set
Expand Down
4 changes: 3 additions & 1 deletion man/Scenedesmus.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ data(Scenedesmus_metab)
head(Scenedesmus_metab)
str(Scenedesmus_metab)

\donttest{

# (1.2) import and check of metabolomics data
#
(o_metab <- metabolomicdata(Scenedesmus_metab))
Expand Down Expand Up @@ -76,7 +78,7 @@ r_apical <- bmdcalc(f_apical, z = 1)
r_apical$res



}
}

\keyword{ datasets }% at least one, from doc/KEYWORDS
3 changes: 2 additions & 1 deletion man/Zhou.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ head(Zhou_liver_pce)
data(Zhou_liver_tce)
head(Zhou_liver_tce)

\donttest{

# (2) import, check, normalization and transformation of a sample
# of one of those datasets
#
Expand All @@ -59,7 +61,6 @@ plot(o)
# (3) analysis of the whole dataset (for kidney and PCE)
# (may be long to run)

\donttest{
d <- Zhou_kidney_pce
(o <- RNAseqdata(d))
plot(o)
Expand Down
4 changes: 3 additions & 1 deletion man/bmdcalc.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,10 @@ datafilename <- system.file("extdata", "transcripto_very_small_sample.txt", pack
plot(r)

# changing the values of z and x for BMD calculation
\donttest{
(rb <- bmdcalc(f, z = 2, x = 50))
plot(rb)
plot(rb)
}

# (2) an example on a microarray data set (a subsample of a greater data set)
#
Expand Down
2 changes: 0 additions & 2 deletions man/bmdplotwithgradient.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ bmdplotwithgradient(r$res, BMDtype = "zSD",
#
bmdplotwithgradient(r$res, BMDtype = "zSD",
facetby = "trend", shapeby = "model")
}

# (2)
# Plot of BMD values with color dose-response gradient
Expand Down Expand Up @@ -187,7 +186,6 @@ bmdplotwithgradient(extendedres, BMDtype = "zSD",
facetby = "path_class",
shapeby = "trend")

\donttest{
# (2.b) The same example forcing the limits of the colour gradient at other
# values than observed minimal and maximal values of the signal
bmdplotwithgradient(extendedres, BMDtype = "zSD",
Expand Down
8 changes: 6 additions & 2 deletions man/continuousanchoringdata.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ datafilename <- system.file("extdata", "apical_anchoring.txt", package = "DRomic

o <- continuousanchoringdata(datafilename, check = TRUE)
print(o)
\donttest{
plot(o)

}
# If you want to use your own data set just replace datafilename,
# the first argument of continuousanchoringdata(),
# by the name of your data file (e.g. "mydata.txt")
Expand All @@ -112,8 +113,11 @@ plot(o)
# Use of an R object of class data.frame
# on the same example (see ?Scenedesmus for details)
data(Scenedesmus_apical)
(o <- continuousanchoringdata(Scenedesmus_apical))
o <- continuousanchoringdata(Scenedesmus_apical)
print(o)
\donttest{
plot(o)
}


}
7 changes: 3 additions & 4 deletions man/curvesplot.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ f <- drcfit(s_quad, progressbar = TRUE)
#
curvesplot(f$fitres, xmax = max(f$omicdata$dose))

\donttest{

# the same plot with dose in log scale (need x != 0 in input)
curvesplot(f$fitres, xmin = 0.1, xmax = max(f$omicdata$dose),
dose_log_transfo = TRUE)
Expand All @@ -107,9 +109,6 @@ curvesplot(r$res, xmax = max(f$omicdata$dose), facetby = "trend")
curvesplot(r$res, xmax = max(f$omicdata$dose), facetby = "trend",
free.y.scales = TRUE)


\donttest{

# (2)
# Plot of all the curves without shifting y0 values to 0
#
Expand All @@ -136,7 +135,6 @@ datafilename <- system.file("extdata", "transcripto_sample.txt", package="DRomic
(r <- bmdcalc(f))

curvesplot(f$fitres, xmax = max(f$omicdata$dose), facetby = "typology")
}


# (5) An example from data published by Larras et al. 2020
Expand Down Expand Up @@ -169,3 +167,4 @@ curvesplot(LMres, facetby = "id", npoints = 100, line.size = 1,


}
}
14 changes: 7 additions & 7 deletions man/drcfit.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ datafilename <- system.file("extdata", "transcripto_very_small_sample.txt", pack
# 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.05))
(f <- drcfit(s_quad, progressbar = TRUE))
o <- microarraydata(datafilename, check = TRUE, norm.method = "cyclicloess")
s_quad <- itemselect(o, select.method = "quadratic", FDR = 0.05)
f <- drcfit(s_quad, progressbar = TRUE)

# Default plot
plot(f)
Expand All @@ -177,11 +177,11 @@ plot(f, plot.type = "dose_residuals", dose_log_transfo = TRUE)

# plot of residuals as function of the fitted value
plot(f, plot.type = "fitted_residuals")
}


# (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"))
Expand All @@ -202,15 +202,15 @@ head(f$fitres)

# Look at the table of results for unsuccessful fits
head(f$unfitres)
}


# (3) Comparison of parallel and non paralell implementations on a
# larger selection of items
#
\donttest{

s_quad <- itemselect(o, select.method = "quadratic", FDR = 0.05)
system.time(f1 <- drcfit(s_quad, progressbar = TRUE))
system.time(f2 <- drcfit(s_quad, progressbar = FALSE, parallel = "snow", ncpus = 2))

}
}
6 changes: 3 additions & 3 deletions man/ecdfplotwithCI.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ s_quad <- itemselect(o, select.method = "quadratic", FDR = 0.001)
f <- drcfit(s_quad, progressbar = TRUE)
r <- bmdcalc(f)
set.seed(1) # to get reproducible results with a so small number of iterations
(b <- bmdboot(r, niter = 10)) # with a non reasonable value for niter
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

# manual ecdf plot of the bootstrap results as an ecdf distribution
# on BMD, plot that could also be obtained with plot(b)
# in this simple case
Expand All @@ -78,6 +78,7 @@ a <- b$res[is.finite(b$res$BMD.zSD.upper), ]
ecdfplotwithCI(variable = a$BMD.zSD, CI.lower = a$BMD.zSD.lower,
CI.upper = a$BMD.zSD.upper, CI.col = "red")

\donttest{

# (2) An example from data published by Larras et al. 2020
# in Journal of Hazardous Materials
Expand Down Expand Up @@ -120,7 +121,6 @@ ecdfplotwithCI(variable = annotres$BMD.zSD,

# (3) 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"))
Expand Down
3 changes: 3 additions & 0 deletions man/itemselect.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ datafilename <- system.file("extdata", "transcripto_sample.txt", package="DRomic
#
(s_quad <- itemselect(o, select.method = "quadratic", FDR = 0.05))

\donttest{

# 1.b using the linear trend test
#
(s_lin <- itemselect(o, select.method = "linear", FDR = 0.05))
Expand All @@ -142,3 +144,4 @@ datafilename <- system.file("extdata", "transcripto_sample.txt", package="DRomic
(s_quad.2 <- itemselect(o, select.method = "quadratic", FDR = 0.001))

}
}
5 changes: 4 additions & 1 deletion man/microarraydata.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ Marie-Laure Delignette-Muller
# (an example on a subsample of a greater data set published in Larras et al. 2018
# Transcriptomic effect of triclosan in the chlorophyte Scenedesmus vacuolatus)
#
datafilename <- system.file("extdata", "transcripto_sample.txt", package="DRomics")
datafilename <- system.file("extdata", "transcripto_very_small_sample.txt",
package="DRomics")
o <- microarraydata(datafilename, check = TRUE, norm.method = "cyclicloess")
print(o)
plot(o)
Expand All @@ -126,6 +127,7 @@ plot(o)
# when it is used with its default field separator (sep argument)
# Tabs are recommended.

\donttest{

# (2) normalization with other methods
(o.2 <- microarraydata(datafilename, check = TRUE, norm.method = "quantile"))
Expand All @@ -134,3 +136,4 @@ plot(o.2)
plot(o.3)

}
}
3 changes: 3 additions & 0 deletions man/targetplot.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ f <- drcfit(s_quad, progressbar = TRUE)
targetitems <- c("88.1", "1", "3", "15")
targetplot(targetitems, f = f)

\donttest{

# The same plot in x log scale
#
targetplot(targetitems, f = f, dose_log_transfo = TRUE)
Expand All @@ -67,3 +69,4 @@ targetplot(targetitems, f = f, dose_log_transfo = TRUE) +
targetplot(targetitems, f = f, add.fit = FALSE)

}
}
47 changes: 19 additions & 28 deletions tests/examplewithRNAseq.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
library(DRomics)
visualize <- FALSE # put to TRUE for a manual check of plots
doboot <- FALSE

# importation and check of RNAseq data and normalization
# with respect to library size and transformation
# options to put in shiny : transfo.method (2 methods, rlog or vst)
datafilename <- system.file("extdata", "RNAseq_sample.txt", package="DRomics")
(o <- RNAseqdata(datafilename, check = TRUE, transfo.method = "vst"))
plot(o)
plot(o, range = 1e6)

if (visualize) # too long computation !
{
Expand Down Expand Up @@ -48,27 +49,18 @@ if(visualize) # too long computation !
}


# item selection using the quadratic method
# options to put in shiny : select.method (3 methods), FDR (numerical positive value < 1)
(s_quad <- itemselect(o, select.method = "quadratic", FDR = 0.001))
if (visualize)
{
# item selection using the quadratic method
# options to put in shiny : select.method (3 methods), FDR (numerical positive value < 1)
(s_quad <- itemselect(o, select.method = "quadratic", FDR = 0.001))
(s_lin <- itemselect(o, select.method = "linear", FDR = 0.001))
(s_ANOVA <- itemselect(o, select.method = "ANOVA", FDR = 0.001))
}

# no options in shiny
(f <- drcfit(s_quad, progressbar = TRUE))
if (visualize)
{
(f <- drcfit(s_quad, progressbar = TRUE))
f$fitres
plot(f)

}


if (visualize)
{
# various plot of fitted curves (without data)
curvesplot(f$fitres, xmax = max(f$omicdata$dose),
facetby = "model", colorby = "model")
Expand All @@ -79,26 +71,21 @@ if (visualize)
curvesplot(f$fitres[f$fitres$trend == "bell", ], xmax = max(f$omicdata$dose),
facetby = "id")

}

if (visualize)
{
curvesplot(f$fitres[f$fitres$trend == "U", ], xmax = max(f$omicdata$dose),
facetby = "id")
}


# calculation of benchmark doses
# options in shiny : z (numerical positive value), x (numerical positive value : percentage)
(r <- bmdcalc(f, z = 1, x = 10))
if (visualize)
(r.2 <- bmdcalc(f, z = 2, x = 50))
if (visualize)
{
(r <- bmdcalc(f, z = 1, x = 10))
(r.2 <- bmdcalc(f, z = 2, x = 50))

# plot of BMD
# options in shiny : BMDtype (2 possibilities), plottype (3 possibilities), by (3 possibilities)
# hist.bins (integer for hist only)
if (visualize)
{
plot(r, BMDtype = "zSD", plottype = "ecdf", by = "none")

plot(r, BMDtype = "xfold", plottype = "ecdf", by = "none")
Expand All @@ -109,11 +96,15 @@ if (visualize)
plot(r, plottype = "hist", by = "trend", hist.bins = 10)
}

# Calculation of confidence intervals on BMDs by Bootstrap
niter <- 1000
niter <- 10
b <- bmdboot(r, niter = niter) # niter should be fixed at least at 1000 to get a reasonable precision
if (visualize) plot(b)
if (doboot)
{
# Calculation of confidence intervals on BMDs by Bootstrap
niter <- 1000
niter <- 10
b <- bmdboot(r, niter = niter) # niter should be fixed at least at 1000 to get a reasonable precision
if (visualize) plot(b)

}

if(visualize) # too long computation !
{
Expand Down
15 changes: 10 additions & 5 deletions tests/examplewithanchoringdata.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
library(DRomics)
visualize <- FALSE # put to TRUE for a manual check of plots
doboot <- FALSE

# importation and check of apical anchoring data
# datafilename <- system.file("extdata", "apical_anchoring.txt", package="DRomics")
Expand Down Expand Up @@ -59,8 +60,12 @@ if (visualize)
}

# Calculation of confidence intervals on BMDs by Bootstrap
niter <- 1000
niter <- 10
(b <- bmdboot(r, niter = niter)) # niter should be fixed at least at 1000 to get a reasonable precision
if (visualize)
plot(b)
if (doboot)
{
niter <- 1000
niter <- 10
(b <- bmdboot(r, niter = niter)) # niter should be fixed at least at 1000 to get a reasonable precision
if (visualize)
plot(b)

}
Loading

0 comments on commit 3427a64

Please sign in to comment.