├── .gitignore
├── data
├── datalist
├── sb.RData
├── tdat.rda
├── quantSB.rda
└── soneson2016.rda
├── docs
├── favicon.ico
├── reference
│ ├── figures
│ │ └── sbhex.png
│ └── BDData-set.html
├── articles
│ ├── summarizedbenchmark-figure1.png
│ ├── summarizedbenchmark-figure2.png
│ ├── QuantificationBenchmark_files
│ │ └── figure-html
│ │ │ └── pcaPlot-1.png
│ ├── CaseStudy-RNAseqQuantification_files
│ │ └── figure-html
│ │ │ └── pcaPlot-1.png
│ ├── SummarizedBenchmark-FullCaseStudy_files
│ │ └── figure-html
│ │ │ ├── unnamed-chunk-13-1.png
│ │ │ └── unnamed-chunk-14-1.png
│ └── CaseStudy-SingleCellSimulation_files
│ │ └── figure-html
│ │ ├── plot-performace-metrics-1.png
│ │ ├── plot-sim-result-comparison-1.png
│ │ └── plot-sim-result-comparison-2.png
├── pkgdown.yml
├── link.svg
├── docsearch.js
├── pkgdown.js
└── pkgdown.css
├── man
├── figures
│ └── sbhex.png
├── BDData-show.Rd
├── BDMethod-show.Rd
├── BenchDesign-show.Rd
├── BDMethodList-show.Rd
├── sb.Rd
├── modmethod.Rd
├── BDData-class.Rd
├── BDMethodList-class.Rd
├── allSB.Rd
├── groundTruths.Rd
├── compareBDMethod.Rd
├── tdat.Rd
├── plotROC.Rd
├── groundTruths-setter.Rd
├── availableMetrics.Rd
├── mcols-setter.Rd
├── tidyUpMetrics.Rd
├── BDData-setter.Rd
├── hashBDData.Rd
├── assayNames-setter.Rd
├── BDMethodList-setter.Rd
├── compareBDData.Rd
├── BDMethod-class.Rd
├── plotMethodsOverlap.Rd
├── printMethod.Rd
├── dropMethod.Rd
├── performanceMetrics-setter.Rd
├── performanceMetrics.Rd
├── BenchDesign-class.Rd
├── BDMethod-setter.Rd
├── addPerformanceMetric.Rd
├── SummarizedBenchmark-class.Rd
├── tidyBDMethod.Rd
├── BDData.Rd
├── BDMethodList.Rd
├── modifyMethod.Rd
├── BenchDesign.Rd
├── compareBenchDesigns.Rd
├── SummarizedBenchmark.Rd
├── expandMethod.Rd
├── BDMethod.Rd
├── updateBench.Rd
├── estimateMetrics.Rd
├── addMethod.Rd
└── buildBench.Rd
├── tests
├── testthat.R
└── testthat
│ ├── test_plottingFunctions.R
│ ├── test_SummarizedBenchmark.R
│ ├── test_addPerformanceFunction.R
│ ├── test_metricsRerun.R
│ ├── test_estimatePerformanceMetrics.R
│ ├── test-updateBench.R
│ └── test-BDMethod.R
├── vignettes
├── summarizedbenchmark-figure1.png
├── summarizedbenchmark-figure2.png
├── library.bib
└── Feature-ErrorHandling.Rmd
├── .Rbuildignore
├── SummarizedBenchmark.Rproj
├── R
├── data-soneson2016.R
├── data-quant.R
├── data-tdat.R
├── BDMethodList-accessors.R
├── BDData-show.R
├── BDMethodList-show.R
├── printMethod.R
├── dropMethod.R
├── BenchDesign-accessors.R
├── BenchDesign-show.R
├── BDMethod-show.R
├── BenchDesign-constructor.R
├── DefaultMetrics.R
├── PlottingFunctions.R
├── BDMethod-constructor.R
├── BDData-constructor.R
├── BDMethodList-constructor.R
├── modifyMethod.R
├── SummarizedBenckmark-constructor.R
├── BDMethod-tidy.R
├── SummarizedBenckmark-accessors.R
├── addMethod.R
├── printUpdateBench.R
└── expandMethod.R
├── inst
├── CITATION
└── NEWS.Rd
├── DESCRIPTION
├── README.md
├── README.Rmd
├── NAMESPACE
└── _pkgdown.yml
/.gitignore:
--------------------------------------------------------------------------------
1 | .Rproj.user
2 | .Rhistory
3 | .RData
4 | .Ruserdata
5 | README.html
--------------------------------------------------------------------------------
/data/datalist:
--------------------------------------------------------------------------------
1 | quantSB: allSB
2 | sb
3 | soneson2016: truthdat txi
4 | tdat
5 |
--------------------------------------------------------------------------------
/data/sb.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/areyesq89/SummarizedBenchmark/HEAD/data/sb.RData
--------------------------------------------------------------------------------
/data/tdat.rda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/areyesq89/SummarizedBenchmark/HEAD/data/tdat.rda
--------------------------------------------------------------------------------
/data/quantSB.rda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/areyesq89/SummarizedBenchmark/HEAD/data/quantSB.rda
--------------------------------------------------------------------------------
/docs/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/areyesq89/SummarizedBenchmark/HEAD/docs/favicon.ico
--------------------------------------------------------------------------------
/data/soneson2016.rda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/areyesq89/SummarizedBenchmark/HEAD/data/soneson2016.rda
--------------------------------------------------------------------------------
/man/figures/sbhex.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/areyesq89/SummarizedBenchmark/HEAD/man/figures/sbhex.png
--------------------------------------------------------------------------------
/tests/testthat.R:
--------------------------------------------------------------------------------
1 | library("testthat")
2 | library("SummarizedBenchmark")
3 |
4 | test_check("SummarizedBenchmark")
5 |
--------------------------------------------------------------------------------
/docs/reference/figures/sbhex.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/areyesq89/SummarizedBenchmark/HEAD/docs/reference/figures/sbhex.png
--------------------------------------------------------------------------------
/vignettes/summarizedbenchmark-figure1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/areyesq89/SummarizedBenchmark/HEAD/vignettes/summarizedbenchmark-figure1.png
--------------------------------------------------------------------------------
/vignettes/summarizedbenchmark-figure2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/areyesq89/SummarizedBenchmark/HEAD/vignettes/summarizedbenchmark-figure2.png
--------------------------------------------------------------------------------
/docs/articles/summarizedbenchmark-figure1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/areyesq89/SummarizedBenchmark/HEAD/docs/articles/summarizedbenchmark-figure1.png
--------------------------------------------------------------------------------
/docs/articles/summarizedbenchmark-figure2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/areyesq89/SummarizedBenchmark/HEAD/docs/articles/summarizedbenchmark-figure2.png
--------------------------------------------------------------------------------
/.Rbuildignore:
--------------------------------------------------------------------------------
1 | ^docs$
2 | ^.travis\.yml$
3 | ^_pkgdown\.yml$
4 | ^.*\.Rproj$
5 | ^\.Rproj\.user$
6 | .Rhistory
7 | .DS_Store
8 | vignettes/site-*
9 | vignettes/*_cache
10 |
11 |
--------------------------------------------------------------------------------
/docs/articles/QuantificationBenchmark_files/figure-html/pcaPlot-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/areyesq89/SummarizedBenchmark/HEAD/docs/articles/QuantificationBenchmark_files/figure-html/pcaPlot-1.png
--------------------------------------------------------------------------------
/docs/articles/CaseStudy-RNAseqQuantification_files/figure-html/pcaPlot-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/areyesq89/SummarizedBenchmark/HEAD/docs/articles/CaseStudy-RNAseqQuantification_files/figure-html/pcaPlot-1.png
--------------------------------------------------------------------------------
/docs/articles/SummarizedBenchmark-FullCaseStudy_files/figure-html/unnamed-chunk-13-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/areyesq89/SummarizedBenchmark/HEAD/docs/articles/SummarizedBenchmark-FullCaseStudy_files/figure-html/unnamed-chunk-13-1.png
--------------------------------------------------------------------------------
/docs/articles/SummarizedBenchmark-FullCaseStudy_files/figure-html/unnamed-chunk-14-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/areyesq89/SummarizedBenchmark/HEAD/docs/articles/SummarizedBenchmark-FullCaseStudy_files/figure-html/unnamed-chunk-14-1.png
--------------------------------------------------------------------------------
/docs/articles/CaseStudy-SingleCellSimulation_files/figure-html/plot-performace-metrics-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/areyesq89/SummarizedBenchmark/HEAD/docs/articles/CaseStudy-SingleCellSimulation_files/figure-html/plot-performace-metrics-1.png
--------------------------------------------------------------------------------
/docs/articles/CaseStudy-SingleCellSimulation_files/figure-html/plot-sim-result-comparison-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/areyesq89/SummarizedBenchmark/HEAD/docs/articles/CaseStudy-SingleCellSimulation_files/figure-html/plot-sim-result-comparison-1.png
--------------------------------------------------------------------------------
/docs/articles/CaseStudy-SingleCellSimulation_files/figure-html/plot-sim-result-comparison-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/areyesq89/SummarizedBenchmark/HEAD/docs/articles/CaseStudy-SingleCellSimulation_files/figure-html/plot-sim-result-comparison-2.png
--------------------------------------------------------------------------------
/man/BDData-show.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/BDData-show.R
3 | \docType{methods}
4 | \name{show,BDData-method}
5 | \alias{show,BDData-method}
6 | \title{Show BDData object}
7 | \usage{
8 | \S4method{show}{BDData}(object)
9 | }
10 | \arguments{
11 | \item{object}{BDData object to show}
12 | }
13 | \value{
14 | Print description of BDData object to console
15 | }
16 | \description{
17 | Show BDData object
18 | }
19 |
--------------------------------------------------------------------------------
/man/BDMethod-show.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/BDMethod-show.R
3 | \docType{methods}
4 | \name{show,BDMethod-method}
5 | \alias{show,BDMethod-method}
6 | \title{Show BDMethod object}
7 | \usage{
8 | \S4method{show}{BDMethod}(object)
9 | }
10 | \arguments{
11 | \item{object}{BDMethod object to show}
12 | }
13 | \value{
14 | Print description of BDMethod object to console
15 | }
16 | \description{
17 | Show BDMethod object
18 | }
19 |
--------------------------------------------------------------------------------
/SummarizedBenchmark.Rproj:
--------------------------------------------------------------------------------
1 | Version: 1.0
2 |
3 | RestoreWorkspace: Default
4 | SaveWorkspace: Default
5 | AlwaysSaveHistory: Default
6 |
7 | EnableCodeIndexing: Yes
8 | UseSpacesForTab: Yes
9 | NumSpacesForTab: 2
10 | Encoding: UTF-8
11 |
12 | RnwWeave: Sweave
13 | LaTeX: pdfLaTeX
14 |
15 | AutoAppendNewline: Yes
16 | StripTrailingWhitespace: Yes
17 |
18 | BuildType: Package
19 | PackageUseDevtools: Yes
20 | PackageInstallArgs: --no-multiarch --with-keep.source
21 | PackageRoxygenize: rd,collate,namespace
22 |
--------------------------------------------------------------------------------
/man/BenchDesign-show.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/BenchDesign-show.R
3 | \docType{methods}
4 | \name{show,BenchDesign-method}
5 | \alias{show,BenchDesign-method}
6 | \title{Show BenchDesign object}
7 | \usage{
8 | \S4method{show}{BenchDesign}(object)
9 | }
10 | \arguments{
11 | \item{object}{BenchDesign object to show}
12 | }
13 | \value{
14 | Print description of BenchDesign object to console
15 | }
16 | \description{
17 | Show BenchDesign object
18 | }
19 |
--------------------------------------------------------------------------------
/man/BDMethodList-show.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/BDMethodList-show.R
3 | \docType{methods}
4 | \name{show,BDMethodList-method}
5 | \alias{show,BDMethodList-method}
6 | \title{Show BDMethodList object}
7 | \usage{
8 | \S4method{show}{BDMethodList}(object)
9 | }
10 | \arguments{
11 | \item{object}{BDMethodList object to show}
12 | }
13 | \value{
14 | Print description of BDMethodList object to console
15 | }
16 | \description{
17 | Show BDMethodList object
18 | }
19 |
--------------------------------------------------------------------------------
/R/data-soneson2016.R:
--------------------------------------------------------------------------------
1 | #' SummarizedBenchmark example
2 | #'
3 | #' @name sb
4 | #' @description This object contains the example data from the \code{iCOBRA} package reformatted as a
5 | #' \code{SummarizedBenchmark} object. It consists of differential expression results from \code{DESeq2}
6 | #' \code{edgeR} and \code{limma}-voom.
7 | #' @source Example data from the \code{iCOBRA} package.
8 | #' @aliases truthdat txi
9 | #' @docType data
10 | #' @keywords data SummarizedBenchmark
11 | #' @examples
12 | #' data(sb)
13 | NULL
14 |
--------------------------------------------------------------------------------
/docs/pkgdown.yml:
--------------------------------------------------------------------------------
1 | pandoc: 2.1.1
2 | pkgdown: 1.3.0
3 | pkgdown_sha: ~
4 | articles:
5 | CaseStudy-RNAseqQuantification: CaseStudy-RNAseqQuantification.html
6 | CaseStudy-SingleCellSimulation: CaseStudy-SingleCellSimulation.html
7 | Feature-ErrorHandling: Feature-ErrorHandling.html
8 | Feature-Iterative: Feature-Iterative.html
9 | Feature-Parallel: Feature-Parallel.html
10 | SummarizedBenchmark-ClassDetails: SummarizedBenchmark-ClassDetails.html
11 | SummarizedBenchmark-FullCaseStudy: SummarizedBenchmark-FullCaseStudy.html
12 | SummarizedBenchmark-Introduction: SummarizedBenchmark-Introduction.html
13 |
14 |
--------------------------------------------------------------------------------
/R/data-quant.R:
--------------------------------------------------------------------------------
1 | #' SummarizedBenchmark object of isoform quantification results
2 | #'
3 | #' @name allSB
4 | #' @aliases allSB,quantSB
5 | #' @description This object is a \code{SummarizedBenchmark} object containing isoform quantifications from salmon, sailfish and kallisto
6 | #' from 4 mouse samples (2 hearts and 2 brains) part of the Mouse BodyMap. Its generation is described in one of the vignettes of this package.
7 | #' @source Mouse BodyMap (Li et al, 2014). SRA accession numbers SRR5273705, SRR5273689, SRR5273699 and SRR5273683.
8 | #' @docType data
9 | #' @keywords data
10 | #' @examples
11 | #' data(quantSB)
12 | NULL
13 |
--------------------------------------------------------------------------------
/man/sb.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/data-soneson2016.R
3 | \docType{data}
4 | \name{sb}
5 | \alias{sb}
6 | \alias{truthdat}
7 | \alias{txi}
8 | \title{SummarizedBenchmark example}
9 | \source{
10 | Example data from the \code{iCOBRA} package.
11 | }
12 | \description{
13 | This object contains the example data from the \code{iCOBRA} package reformatted as a
14 | \code{SummarizedBenchmark} object. It consists of differential expression results from \code{DESeq2}
15 | \code{edgeR} and \code{limma}-voom.
16 | }
17 | \examples{
18 | data(sb)
19 | }
20 | \keyword{SummarizedBenchmark}
21 | \keyword{data}
22 |
--------------------------------------------------------------------------------
/man/modmethod.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/modifyMethod.R
3 | \name{.modmethod}
4 | \alias{.modmethod}
5 | \title{Modify BenchDesign Method}
6 | \usage{
7 | .modmethod(m, q, .overwrite)
8 | }
9 | \arguments{
10 | \item{m}{method}
11 |
12 | \item{q}{quosure list of new parameters}
13 |
14 | \item{.overwrite}{logical whether to overwrite parameters}
15 | }
16 | \value{
17 | modified method.
18 | }
19 | \description{
20 | Given a method defined in a BenchDesign, this helper function
21 | returns a modified method with new parameters defined as a
22 | list of quosures.
23 | }
24 | \author{
25 | Patrick Kimes
26 | }
27 | \keyword{internal}
28 |
--------------------------------------------------------------------------------
/man/BDData-class.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/AllClasses.R
3 | \docType{class}
4 | \name{BDData-class}
5 | \alias{BDData-class}
6 | \title{BDData class}
7 | \description{
8 | Container for data in a BenchDesign object.
9 | }
10 | \section{Slots}{
11 |
12 | \describe{
13 | \item{\code{data}}{a list or MD5 hash of the data.}
14 |
15 | \item{\code{type}}{a character string indicating whether the data slot
16 | contains the 'data' or a 'md5hash' of the data.}
17 | }}
18 |
19 | \seealso{
20 | \code{\link{BDData}}, \code{\link{BenchDesign-class}}, \code{\link{BDMethod-class}}, \code{\link{BDMethodList-class}}
21 | }
22 | \author{
23 | Patrick Kimes
24 | }
25 |
--------------------------------------------------------------------------------
/man/BDMethodList-class.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/AllClasses.R
3 | \docType{class}
4 | \name{BDMethodList-class}
5 | \alias{BDMethodList-class}
6 | \title{BDMethodList class}
7 | \description{
8 | Extension of the SimpleList class to contain a list of BDMethod
9 | objects. The class serves as the primary container for the set of
10 | methods in the BenchDesign class.
11 |
12 | New BDMethodList objects can be created using the
13 | \code{\link{BDMethodList}} constructor.
14 | }
15 | \seealso{
16 | \code{\link{BDMethodList}}, \code{\link{BenchDesign-class}}, \code{\link{BDMethod-class}}, \code{\link{BDData-class}}
17 | }
18 | \author{
19 | Patrick Kimes
20 | }
21 |
--------------------------------------------------------------------------------
/inst/CITATION:
--------------------------------------------------------------------------------
1 | citEntry(entry="article",
2 | title = "Reproducible and replicable comparisons using SummarizedBenchmark.",
3 | author = personList(
4 | as.person("Patrick Kimes"),
5 | as.person("Alejandro Reyes")),
6 | year = 2019,
7 | journal = "Bioinformatics",
8 | volume = 35,
9 | issue = 1,
10 | pages = "137",
11 | doi = "10.1093/bioinformatics/bty627",
12 | textVersion =
13 | paste("Patrick Kimes and Alejandro Reyes (2019)",
14 | "Reproducible and replicable comparisons using SummarizedBenchmark.",
15 | "Bioinformatics (2019) 35(1):137. doi:10.1093/bioinformatics/bty627" ) )
16 |
--------------------------------------------------------------------------------
/R/data-tdat.R:
--------------------------------------------------------------------------------
1 | #' Example data.frame containing results for 50 two-sample t-tests.
2 | #'
3 | #' @format
4 | #' a data.frame that contains the results of 50 simulated two-sample
5 | #' t-tests, with each row corresponding to an independent test. The
6 | #' data.frame includes the following 5 columns:
7 | #' 1. H = binary 0/1 whether data for the test was simulated under the null (0) or alternative (1)
8 | #' 2. test_statistic = test-statistics of the t-test
9 | #' 3. effect_size = mean difference between the two sample groups
10 | #' 4. pval = p-value of the t-test
11 | #' 5. SE = standard error of the t-test
12 | #'
13 | #' @name tdat
14 | #' @docType data
15 | #' @keywords data
16 | #' @examples
17 | #' data(tdat)
18 | NULL
19 |
--------------------------------------------------------------------------------
/man/allSB.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/data-quant.R
3 | \docType{data}
4 | \name{allSB}
5 | \alias{allSB}
6 | \alias{allSB,quantSB}
7 | \title{SummarizedBenchmark object of isoform quantification results}
8 | \source{
9 | Mouse BodyMap (Li et al, 2014). SRA accession numbers SRR5273705, SRR5273689, SRR5273699 and SRR5273683.
10 | }
11 | \description{
12 | This object is a \code{SummarizedBenchmark} object containing isoform quantifications from salmon, sailfish and kallisto
13 | from 4 mouse samples (2 hearts and 2 brains) part of the Mouse BodyMap. Its generation is described in one of the vignettes of this package.
14 | }
15 | \examples{
16 | data(quantSB)
17 | }
18 | \keyword{data}
19 |
--------------------------------------------------------------------------------
/man/groundTruths.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/AllGenerics.R,
3 | % R/SummarizedBenckmark-accessors.R
4 | \docType{methods}
5 | \name{groundTruths}
6 | \alias{groundTruths}
7 | \alias{groundTruths,SummarizedBenchmark-method}
8 | \title{Get ground truths in SummarizedBenchmark object}
9 | \usage{
10 | groundTruths(object, ...)
11 |
12 | \S4method{groundTruths}{SummarizedBenchmark}(object, ...)
13 | }
14 | \arguments{
15 | \item{object}{a \code{SummarizedBenchmark} object.}
16 |
17 | \item{...}{further arguments, perhaps used by methods.}
18 | }
19 | \value{
20 | modified BenchDesign object
21 | }
22 | \description{
23 | Method to get groundTruths in SummarizedBenchmark object.
24 | }
25 | \author{
26 | Alejandro Reyes
27 | }
28 |
--------------------------------------------------------------------------------
/docs/link.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
13 |
--------------------------------------------------------------------------------
/man/compareBDMethod.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/compareBenchDesigns.R
3 | \name{compareBDMethod}
4 | \alias{compareBDMethod}
5 | \title{Compare BDMethod objects}
6 | \usage{
7 | compareBDMethod(x, y)
8 | }
9 | \arguments{
10 | \item{x}{a \code{BDMethod} object}
11 |
12 | \item{y}{a \code{BDMethod} object}
13 | }
14 | \value{
15 | logical value indicating whether the two objects produced the same
16 | meta data.
17 | }
18 | \description{
19 | Simple comparison of two BDMethod objects based on
20 | meta data.
21 | }
22 | \examples{
23 | bdm1 <- BDMethod(stats::rnorm, params = rlang::quos(n = 100))
24 | bdm2 <- BDMethod(stats::rt, params = rlang::quos(n = 100, df = 1))
25 |
26 | compareBDMethod(bdm1, bdm2)
27 |
28 | }
29 | \seealso{
30 | \code{\link{compareBenchDesigns}}
31 | }
32 | \author{
33 | Patrick Kimes
34 | }
35 |
--------------------------------------------------------------------------------
/man/tdat.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/data-tdat.R
3 | \docType{data}
4 | \name{tdat}
5 | \alias{tdat}
6 | \title{Example data.frame containing results for 50 two-sample t-tests.}
7 | \format{a data.frame that contains the results of 50 simulated two-sample
8 | t-tests, with each row corresponding to an independent test. The
9 | data.frame includes the following 5 columns:
10 | 1. H = binary 0/1 whether data for the test was simulated under the null (0) or alternative (1)
11 | 2. test_statistic = test-statistics of the t-test
12 | 3. effect_size = mean difference between the two sample groups
13 | 4. pval = p-value of the t-test
14 | 5. SE = standard error of the t-test}
15 | \description{
16 | Example data.frame containing results for 50 two-sample t-tests.
17 | }
18 | \examples{
19 | data(tdat)
20 | }
21 | \keyword{data}
22 |
--------------------------------------------------------------------------------
/man/plotROC.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/PlottingFunctions.R
3 | \name{plotROC}
4 | \alias{plotROC}
5 | \title{Plot ROC curve for SummarizedBenchmark object}
6 | \usage{
7 | plotROC(object, assay = "qvalue")
8 | }
9 | \arguments{
10 | \item{object}{A \code{\link{SummarizedBenchmark}} object.}
11 |
12 | \item{assay}{An assay name.}
13 | }
14 | \value{
15 | A ggplot object.
16 | }
17 | \description{
18 | This function inputs a \code{\link{SummarizedBenchmark}} object, looks
19 | for an assay called 'qvalue' and plots receiver operating characteristic curves
20 | for each of the methods to benchmark.
21 | }
22 | \examples{
23 | data(sb)
24 | \dontrun{
25 | plotROC(sb)
26 | }
27 |
28 | }
29 | \seealso{
30 | \code{\link{plotMethodsOverlap}}, \code{\link{estimatePerformanceMetrics}}
31 | }
32 | \author{
33 | Alejandro Reyes
34 | }
35 |
--------------------------------------------------------------------------------
/man/groundTruths-setter.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/AllGenerics.R,
3 | % R/SummarizedBenckmark-accessors.R
4 | \docType{methods}
5 | \name{groundTruths<-}
6 | \alias{groundTruths<-}
7 | \alias{groundTruths<-,SummarizedBenchmark-method}
8 | \title{Set ground truths in SummarizedBenchmark object}
9 | \usage{
10 | groundTruths(object, ...) <- value
11 |
12 | \S4method{groundTruths}{SummarizedBenchmark}(object, ...) <- value
13 | }
14 | \arguments{
15 | \item{object}{a \code{SummarizedBenchmark} object.}
16 |
17 | \item{...}{futher arguments, perhaps used by methods.}
18 |
19 | \item{value}{replacement set of ground truths.}
20 | }
21 | \value{
22 | modified BenchDesign object
23 | }
24 | \description{
25 | Method to set groundTruths in SummarizedBenchmark object.
26 | }
27 | \author{
28 | Alejandro Reyes, Patrick Kimes
29 | }
30 |
--------------------------------------------------------------------------------
/man/availableMetrics.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/DefaultMetrics.R
3 | \name{availableMetrics}
4 | \alias{availableMetrics}
5 | \title{List pre-defined metrics for SummarizedBenchmark objects}
6 | \usage{
7 | availableMetrics()
8 | }
9 | \value{
10 | A data.frame summarizing the default performance metrics provided in this package.
11 | }
12 | \description{
13 | This function returns a data frame summarizing the default performance metrics provided in this package.
14 | The data.frame contains three columns, \code{functions} is the name of the performance metric, \code{description}
15 | is longer description of the performance metric and \code{requiredTruth} is logical depending on whether the
16 | performance metrics require ground truths.
17 | }
18 | \examples{
19 | availableMetrics()
20 |
21 | }
22 | \author{
23 | Alejandro Reyes
24 | }
25 |
--------------------------------------------------------------------------------
/R/BDMethodList-accessors.R:
--------------------------------------------------------------------------------
1 | #' @rdname BDMethod-setter
2 | #' @exportMethod "BDMethod<-"
3 | setReplaceMethod("BDMethod",
4 | signature(x = "BDMethodList", i = "character", value = "BDMethod"),
5 | function (x, i, value) {
6 | x[[i]] <- value
7 | x
8 | })
9 |
10 | #' @rdname BDMethod-setter
11 | #' @exportMethod "BDMethod<-"
12 | setReplaceMethod("BDMethod",
13 | signature(x = "BDMethodList", i = "character", value = "NULL"),
14 | function (x, i, value) {
15 | x[[i]] <- value
16 | x
17 | })
18 |
19 | #' @rdname BDMethod
20 | #' @exportMethod "BDMethod"
21 | setMethod("BDMethod",
22 | signature(x = "BDMethodList"),
23 | function(x, i = 1) {
24 | stopifnot(is(i, "character") || is(i, "numeric"))
25 | x[[i]]
26 | })
27 |
--------------------------------------------------------------------------------
/man/mcols-setter.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/SummarizedBenckmark-accessors.R
3 | \docType{methods}
4 | \name{mcols<-,SummarizedBenchmark-method}
5 | \alias{mcols<-,SummarizedBenchmark-method}
6 | \title{Set meta data columns in SummarizedBenchmark object}
7 | \usage{
8 | \S4method{mcols}{SummarizedBenchmark}(x, ...) <- value
9 | }
10 | \arguments{
11 | \item{x}{A \code{\link[=SummarizedBenchmark-class]{SummarizedBenchmark}} object.}
12 |
13 | \item{...}{Futher arguments, perhaps used by methods.}
14 |
15 | \item{value}{A DataFrame of meta data.}
16 | }
17 | \value{
18 | Modfied \code{\link[=SummarizedBenchmark-class]{SummarizedBenchmark}} object.
19 | }
20 | \description{
21 | Modifies the \code{mcols} slot of a \code{\link[=SummarizedBenchmark-class]{SummarizedBenchmark}}
22 | object.
23 | }
24 | \seealso{
25 | \code{\link[=SummarizedBenchmark-class]{SummarizedBenchmark}}
26 | }
27 | \author{
28 | Alejandro Reyes
29 | }
30 |
--------------------------------------------------------------------------------
/tests/testthat/test_plottingFunctions.R:
--------------------------------------------------------------------------------
1 | context( "plottingFunctions" )
2 | test_that( "test that 'plotROC' and 'plotOverlaps' behave as expected", {
3 | data( sb )
4 | sb <- addPerformanceMetric( sb, evalMetric=c("rejections", "TPR", "TNR", "FDR", "FNR"), assay="qvalue" )
5 | expect_error( plotROC( 1:10 ) )
6 | sb2 <- sb
7 | groundTruths( sb2 ) <- NULL
8 | expect_error( plotROC( sb2 ) )
9 | sb2 <- sb
10 | assayNames( sb2 ) <- paste0( "assay", seq_along( assayNames( sb2 ) ) )
11 | expect_error( plotROC( sb2 ) )
12 | expect_error( plotMethodsOverlap( sb2 ) )
13 | expect_error( plotMethodsOverlap( object=1:10 ) )
14 | expect_error( plotMethodsOverlap( sb, alpha="a" ) )
15 | expect_error( plotMethodsOverlap( sb, alpha=3 ) )
16 | expect_identical(
17 | plotROC( sb )$geom$objname,
18 | plotROC( sb2, assay="assay1" )$geom$objname )
19 | expect_is( plotMethodsOverlap( sb ), "upset" )
20 | expect_is( plotMethodsOverlap( sb2, assay="assay1" ), "upset" )
21 | } )
22 |
--------------------------------------------------------------------------------
/man/tidyUpMetrics.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/PerformanceMetrics.R
3 | \name{tidyUpMetrics}
4 | \alias{tidyUpMetrics}
5 | \title{Tidy up performance metrics in SummarizedBenchmark object}
6 | \usage{
7 | tidyUpMetrics(object)
8 | }
9 | \arguments{
10 | \item{object}{A \code{\link{SummarizedBenchmark}} object.}
11 | }
12 | \value{
13 | A tidy \code{data.frame}
14 | }
15 | \description{
16 | This function takes as input a \code{SummarizedBenchmark} object, extracts the
17 | estimated performance metrics and reformats them into a long-formated data frame.
18 | }
19 | \examples{
20 | data( "sb", package="SummarizedBenchmark" )
21 | sb <- estimateMetricsForAssay( sb, assay="qvalue", evalMetric="rejections",
22 | evalFunction=function( query, truth, alpha=0.1 ){
23 | sum( query < alpha )
24 | },
25 | addColData=TRUE )
26 | tidyUpMetrics( sb )
27 |
28 | }
29 | \seealso{
30 | \code{\link{estimatePerformanceMetrics}}
31 | }
32 | \author{
33 | Alejandro Reyes
34 | }
35 |
--------------------------------------------------------------------------------
/man/BDData-setter.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/AllGenerics.R, R/BenchDesign-accessors.R
3 | \docType{methods}
4 | \name{BDData<-}
5 | \alias{BDData<-}
6 | \alias{BDData<-,BenchDesign,BDDataOrNULL-method}
7 | \title{Set data in BenchDesign object}
8 | \usage{
9 | BDData(x) <- value
10 |
11 | \S4method{BDData}{BenchDesign,BDDataOrNULL}(x) <- value
12 | }
13 | \arguments{
14 | \item{x}{\code{\link[=BenchDesign-class]{BenchDesign}} object.}
15 |
16 | \item{value}{\code{\link[=BDData-class]{BDData}} or \code{NULL}.}
17 | }
18 | \value{
19 | modified BenchDesign object
20 | }
21 | \description{
22 | Adds, removes or replaces \code{\link[=BDData-class]{BDData}} in
23 | \code{\link[=BenchDesign-class]{BenchDesign}} object.
24 | Data can be removed by setting the value to \code{NULL}.
25 | }
26 | \examples{
27 | bd <- BenchDesign()
28 | BDData(bd) <- BDData(data.frame(x1 = runif(5)))
29 | bd
30 |
31 | }
32 | \seealso{
33 | \code{\link{BDData}}
34 | }
35 | \author{
36 | Patrick Kimes
37 | }
38 |
--------------------------------------------------------------------------------
/man/hashBDData.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/AllGenerics.R, R/BDData-constructor.R
3 | \docType{methods}
4 | \name{hashBDData}
5 | \alias{hashBDData}
6 | \alias{hashBDData,BDData-method}
7 | \alias{hashBDData,BenchDesign-method}
8 | \title{Hash data in BDData object}
9 | \usage{
10 | hashBDData(object)
11 |
12 | \S4method{hashBDData}{BDData}(object)
13 |
14 | \S4method{hashBDData}{BenchDesign}(object)
15 | }
16 | \arguments{
17 | \item{object}{a \code{BDData} or \code{BenchDesign} object}
18 | }
19 | \value{
20 | an object of the same class as \code{object} with data
21 | converted to a MD5 hash.
22 | }
23 | \description{
24 | Repliaces data stored in a \code{\link[=BDData-class]{BDData}} object
25 | with the MD5 hash of the data. If the data was already a MD5 hash, the
26 | original object is returned unchanged. The method can be called directly
27 | on \code{\link[=BenchDesign-class]{BenchDesign}} objects to hash the
28 | underlying data as well.
29 | }
30 | \author{
31 | Patrick Kimes
32 | }
33 |
--------------------------------------------------------------------------------
/man/assayNames-setter.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/SummarizedBenckmark-accessors.R
3 | \docType{methods}
4 | \name{assayNames<-,SummarizedBenchmark,character-method}
5 | \alias{assayNames<-,SummarizedBenchmark,character-method}
6 | \title{Set assay names in SummarizedBenchmark object}
7 | \usage{
8 | \S4method{assayNames}{SummarizedBenchmark,character}(x, ...) <- value
9 | }
10 | \arguments{
11 | \item{x}{A \code{\link[=SummarizedBenchmark-class]{SummarizedBenchmark}} object.}
12 |
13 | \item{...}{Futher arguments, perhaps used by methods.}
14 |
15 | \item{value}{A character vector.}
16 | }
17 | \value{
18 | Modfied \code{\link[=SummarizedBenchmark-class]{SummarizedBenchmark}} object.
19 | }
20 | \description{
21 | Modifies the assay names of a \code{\link[=SummarizedBenchmark-class]{SummarizedBenchmark}}
22 | object.
23 | }
24 | \examples{
25 | data(sb)
26 | assayNames(sb)[2] <- "log2FC"
27 |
28 | }
29 | \seealso{
30 | \code{\link[=SummarizedBenchmark-class]{SummarizedBenchmark}}
31 | }
32 | \author{
33 | Alejandro Reyes
34 | }
35 |
--------------------------------------------------------------------------------
/man/BDMethodList-setter.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/AllGenerics.R, R/BenchDesign-accessors.R
3 | \docType{methods}
4 | \name{BDMethodList<-}
5 | \alias{BDMethodList<-}
6 | \alias{BDMethodList<-,BenchDesign,BDMethodList-method}
7 | \title{Set method list in BenchDesign object}
8 | \usage{
9 | BDMethodList(x) <- value
10 |
11 | \S4method{BDMethodList}{BenchDesign,BDMethodList}(x) <- value
12 | }
13 | \arguments{
14 | \item{x}{BenchDesign object.}
15 |
16 | \item{value}{\code{\link[=BDMethodList-class]{BDMethodList}} list of methods.}
17 | }
18 | \value{
19 | modified BenchDesign object
20 | }
21 | \description{
22 | Replaces the \code{\link[=BDMethodList-class]{BDMethodList}} list of methods
23 | in a \code{\link[=BenchDesign-class]{BenchDesign}} object with a specified
24 | \code{\link[=BDMethodList-class]{BDMethodList}} object.
25 | }
26 | \examples{
27 | bd <- BenchDesign()
28 | BDMethodList(bd) <- BDMethodList(avg = BDMethod(x = base::mean))
29 | bd
30 |
31 | }
32 | \seealso{
33 | \code{\link{BDMethod}}, \code{\link{BDMethodList}}
34 | }
35 | \author{
36 | Patrick Kimes
37 | }
38 |
--------------------------------------------------------------------------------
/man/compareBDData.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/compareBenchDesigns.R
3 | \name{compareBDData}
4 | \alias{compareBDData}
5 | \title{Compare BDData objects}
6 | \usage{
7 | compareBDData(x, y)
8 | }
9 | \arguments{
10 | \item{x}{a \code{BDData} or \code{BenchDesign} object}
11 |
12 | \item{y}{a \code{BDData} or \code{BenchDesign} object}
13 | }
14 | \value{
15 | list of two values giving agreement of "data" and "type".
16 | }
17 | \description{
18 | Simple comparison of two BDData objects based on
19 | comparing both type and data hash.
20 | }
21 | \examples{
22 | ## compare data with same MD5 hash value
23 | bdd1 <- BDData(data.frame(x = 1:10))
24 | bdd1h <- hashBDData(bdd1)
25 | compareBDData(bdd1, bdd1h)
26 |
27 | ## compare different data, both same type
28 | bdd2 <- BDData(data.frame(x = 2:11))
29 | bdd2h <- hashBDData(bdd2)
30 | compareBDData(bdd1, bdd2)
31 | compareBDData(bdd1h, bdd2h)
32 |
33 | ## compare completely different data
34 | compareBDData(bdd1, bdd2h)
35 |
36 | }
37 | \seealso{
38 | \code{\link{compareBenchDesigns}}
39 | }
40 | \author{
41 | Patrick Kimes
42 | }
43 |
--------------------------------------------------------------------------------
/tests/testthat/test_SummarizedBenchmark.R:
--------------------------------------------------------------------------------
1 | context("SummarizedBenchmark")
2 | test_that("test='SummarizedBenchmark' returns error messages", {
3 | library(iCOBRA)
4 | data(cobradata_example)
5 | assays <- list(
6 | qvalue=cobradata_example@padj,
7 | logFC=cobradata_example@score )
8 | assays[["qvalue"]]$DESeq2 <- p.adjust(cobradata_example@pval$DESeq2, method="BH")
9 | groundTruth <- DataFrame( cobradata_example@truth[,c("status", "logFC")] )
10 | colnames(groundTruth) <- names( assays )
11 | colData <- DataFrame( method=colnames(assays[[1]]) )
12 | groundTruth <- groundTruth[rownames(assays[[1]]),]
13 | expect_error( SummarizedBenchmark(
14 | assays=assays,
15 | colData=colData,
16 | groundTruth=groundTruth[1:10,] ) )
17 | assays2 <- assays
18 | assays2[[1]] <- assays2[[1]][1:10,]
19 | expect_error( SummarizedBenchmark(
20 | assays=assays2,
21 | colData=colData,
22 | groundTruth=groundTruth ) )
23 | assays2 <- assays
24 | assays2[[1]] <- assays2[[1]][,1:2]
25 | expect_error( SummarizedBenchmark(
26 | assays=assays2,
27 | colData=colData,
28 | groundTruth=groundTruth ) )
29 | } )
30 |
--------------------------------------------------------------------------------
/man/BDMethod-class.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/AllClasses.R
3 | \docType{class}
4 | \name{BDMethod-class}
5 | \alias{BDMethod-class}
6 | \title{BDMethod class}
7 | \description{
8 | Container for individual methods to be compared as part of a benchmark
9 | experiment defined in a BenchDesign object. In the SummarizedBenchmark
10 | framework, methods are defined by a unique combination of functions,
11 | parameters, and any relevant meta data.
12 |
13 | New BDMethod objects can be created using the \code{\link{BDMethod}}
14 | constructor.
15 | }
16 | \section{Slots}{
17 |
18 | \describe{
19 | \item{\code{f}}{a function to be benchmarked}
20 |
21 | \item{\code{fc}}{a captured expression of the function \code{f}}
22 |
23 | \item{\code{params}}{a list of quosures specifying function parameters}
24 |
25 | \item{\code{post}}{a list of functions to be applied to the output of \code{f}}
26 |
27 | \item{\code{meta}}{a list of meta data}
28 | }}
29 |
30 | \seealso{
31 | \code{\link{BDMethod}}, \code{\link{BenchDesign-class}}, \code{\link{BDMethodList-class}}, \code{\link{BDData-class}}
32 | }
33 | \author{
34 | Patrick Kimes
35 | }
36 |
--------------------------------------------------------------------------------
/man/plotMethodsOverlap.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/PlottingFunctions.R
3 | \name{plotMethodsOverlap}
4 | \alias{plotMethodsOverlap}
5 | \title{Plot UpSetR for SummarizedBenchmark object}
6 | \usage{
7 | plotMethodsOverlap(object, assay = "qvalue", alpha = 0.1, ...)
8 | }
9 | \arguments{
10 | \item{object}{A \code{\link{SummarizedBenchmark}} object.}
11 |
12 | \item{assay}{The name of an assay.}
13 |
14 | \item{alpha}{An alpha value.}
15 |
16 | \item{...}{Further arguments passed to \code{\link{upset}}}
17 | }
18 | \value{
19 | An upseR plot.
20 | }
21 | \description{
22 | This function looks for an assay, called by default 'qvalue', and given an alpha threshold,
23 | it binarizes the assay matrix depending on whether its values are below the alpha
24 | threshold. Then it uses the function \code{\link{upset}} to plot the overlaps.
25 | The plot is only generated if at least 2 methods have observations that pass
26 | the alpha threshold.
27 | }
28 | \examples{
29 | data(sb)
30 | \dontrun{
31 | plotMethodsOverlap(sb)
32 | }
33 |
34 | }
35 | \seealso{
36 | \code{\link{plotROC}}, \code{\link{estimatePerformanceMetrics}}
37 | }
38 | \author{
39 | Alejandro Reyes
40 | }
41 |
--------------------------------------------------------------------------------
/man/printMethod.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/printMethod.R
3 | \name{printMethod}
4 | \alias{printMethod}
5 | \alias{printMethods}
6 | \title{Pretty print methods in a BenchDesign object}
7 | \usage{
8 | printMethod(bd, n = NULL)
9 |
10 | printMethods(bd)
11 | }
12 | \arguments{
13 | \item{bd}{BenchDesign object.}
14 |
15 | \item{n}{name of a method in the BenchDesign to show.}
16 | }
17 | \value{
18 | Brief description is returned to console.
19 | }
20 | \description{
21 | Print out details about a method included in
22 | the BenchDesign. The \code{printMethods} function is just a wrapper
23 | to call \code{printMethod} on all methods in the BenchDesign.
24 | }
25 | \examples{
26 | ## create empty BenchDesign
27 | bench <- BenchDesign()
28 |
29 | ## currently no methods
30 | printMethods(bench)
31 |
32 | ## add method
33 | bench <- addMethod(bench, label = "method_a", p.adjust)
34 | bench <- addMethod(bench, label = "method_b", qvalue::qvalue)
35 |
36 | ## show a single method
37 | printMethod(bench, "method_a")
38 |
39 | ## show all methods
40 | printMethods(bench)
41 |
42 | }
43 | \seealso{
44 | \code{\link{BDMethod-class}}, \code{\link{BenchDesign-class}}
45 | }
46 | \author{
47 | Patrick Kimes
48 | }
49 |
--------------------------------------------------------------------------------
/R/BDData-show.R:
--------------------------------------------------------------------------------
1 | .show.BDData <- function(object) {
2 | cat(stringr::str_pad("BenchDesign Data (BDData) ", 60, "right", pad = "-"), "\n")
3 | dtype <- object@type
4 | cat(" type:", object@type, "\n")
5 | if (dtype == "data") {
6 | if (is(object@data, "data.frame")) {
7 | cat(" data:\n")
8 | desc <- as.data.frame(object@data)
9 | } else {
10 | cat(" data summary:\n")
11 | desc <- data.frame(name = seq_len(length(object@data)),
12 | class = unlist(sapply(object@data, class)),
13 | length = unlist(sapply(object@data, length)))
14 | desc$name <- names(object@data)
15 | row.names(desc) <- NULL
16 | }
17 | print(utils::head(desc, n = 10))
18 | if (nrow(desc) > 10)
19 | cat(" ... with", nrow(desc) - 10, "more rows.\n")
20 | }
21 | if (dtype == "md5hash")
22 | cat(" MD5 hash:", stringr::str_trunc(object@data, 50), "\n")
23 | }
24 |
25 | #' Show BDData object
26 | #'
27 | #' @param object BDData object to show
28 | #'
29 | #' @return
30 | #' Print description of BDData object to console
31 | #'
32 | #' @importFrom stringr str_pad
33 | #' @importFrom utils head
34 | #' @rdname BDData-show
35 | setMethod("show", signature(object = "BDData"), .show.BDData)
36 |
--------------------------------------------------------------------------------
/R/BDMethodList-show.R:
--------------------------------------------------------------------------------
1 | .show.BDMethodList <- function(object) {
2 | cat(stringr::str_pad("BenchDesign Method List (BDMethodList) ", 60, "right", "-"), "\n")
3 | cat("list of", length(object), ifelse(length(object) == 1L, "method", "methods"), "\n")
4 | if (length(object) < 1) {
5 | cat(" none\n")
6 | } else {
7 | max_c <- 20
8 | m1 <- max(nchar(names(utils::head(object))))
9 | m1 <- min(m1, max_c)
10 | m2 <- max(nchar(sapply(utils::head(object), function(x) { rlang::quo_text(x@fc) })))
11 | m2 <- min(m2, max_c)
12 | for (n in names(object)) {
13 | p1 <- stringr::str_pad(stringr::str_trunc(n, max_c), m1 + 1, "left", " ")
14 | p2 <- stringr::str_pad(stringr::str_trunc(gsub("\n", ";", rlang::quo_text(object[[n]]@fc)), max_c),
15 | m2 + 1, "right", " ")
16 | cat(" method: ", p1, "; func: ", p2, "\n", sep="")
17 | }
18 | }
19 | }
20 |
21 | #' Show BDMethodList object
22 | #'
23 | #' @param object BDMethodList object to show
24 | #'
25 | #' @return
26 | #' Print description of BDMethodList object to console
27 | #'
28 | #' @importFrom stringr str_pad str_trunc
29 | #' @importFrom rlang quo_text
30 | #' @importFrom utils head
31 | #' @rdname BDMethodList-show
32 | setMethod("show", signature(object = "BDMethodList"), .show.BDMethodList)
33 |
--------------------------------------------------------------------------------
/man/dropMethod.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/dropMethod.R
3 | \name{dropMethod}
4 | \alias{dropMethod}
5 | \title{Remove method from BenchDesign object}
6 | \usage{
7 | dropMethod(bd, label)
8 | }
9 | \arguments{
10 | \item{bd}{\code{\link[=BenchDesign-class]{BenchDesign}} object.}
11 |
12 | \item{label}{Character name of method.}
13 | }
14 | \value{
15 | Modified \code{\link[=BenchDesign-class]{BenchDesign}} object with
16 | specified method dropped.
17 | }
18 | \description{
19 | Takes a \code{\link[=BenchDesign-class]{BenchDesign}} object and the name of an
20 | existing method
21 | and returns a reduced \code{\link[=BenchDesign-class]{BenchDesign}} object with the
22 | method removed.
23 | }
24 | \examples{
25 | ## empty BenchDesign
26 | bench <- BenchDesign()
27 |
28 | ## add methods
29 | bench <- addMethod(bench, label = "bonf", func = p.adjust,
30 | params = rlang::quos(p = pval, method = "bonferroni"))
31 | bench <- addMethod(bench, label = "BH", func = p.adjust,
32 | params = rlang::quos(p = pval, method = "BH"))
33 | BDMethodList(bench)
34 |
35 | ## remove methods
36 | bench <- dropMethod(bench, label = "bonf")
37 | BDMethodList(bench)
38 |
39 | }
40 | \seealso{
41 | \code{\link{modifyMethod}}, \code{\link{expandMethod}}, \code{\link{addMethod}}
42 | }
43 | \author{
44 | Patrick Kimes
45 | }
46 |
--------------------------------------------------------------------------------
/man/performanceMetrics-setter.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/AllGenerics.R,
3 | % R/SummarizedBenckmark-accessors.R
4 | \docType{methods}
5 | \name{performanceMetrics<-}
6 | \alias{performanceMetrics<-}
7 | \alias{performanceMetrics<-,SummarizedBenchmark,SimpleList-method}
8 | \title{Set performance metrics in SummarizedBenchmark object}
9 | \usage{
10 | performanceMetrics(object, ...) <- value
11 |
12 |
13 | \S4method{performanceMetrics}{SummarizedBenchmark,SimpleList}(object) <- value
14 | }
15 | \arguments{
16 | \item{object}{a \code{\link[=SummarizedBenchmark-class]{SummarizedBenchmark}} object.}
17 |
18 | \item{...}{futher arguments, perhaps used by methods.}
19 |
20 | \item{value}{a SimpleList of the same length as the number of assays.}
21 | }
22 | \value{
23 | Silently, the newly specified SimpleList of performance metric lists.
24 | }
25 | \description{
26 | Replaces the list of performance metrics in a
27 | \code{\link[=SummarizedBenchmark-class]{SummarizedBenchmark}} object with
28 | a new list of performance metric lists.
29 | }
30 | \examples{
31 | data(sb)
32 | performanceMetrics(sb)
33 | performanceMetrics(sb) <- SimpleList(qvalue = list(), logFC = list())
34 |
35 | }
36 | \seealso{
37 | \code{\link{addPerformanceMetric}}, \code{\link{estimatePerformanceMetrics}}, \code{\link{performanceMetrics}}
38 | }
39 | \author{
40 | Alejandro Reyes
41 | }
42 |
--------------------------------------------------------------------------------
/man/performanceMetrics.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/AllGenerics.R,
3 | % R/SummarizedBenckmark-accessors.R
4 | \docType{methods}
5 | \name{performanceMetrics}
6 | \alias{performanceMetrics}
7 | \alias{performanceMetrics,SummarizedBenchmark-method}
8 | \title{Get performance metrics in SummarizedBenchmark object}
9 | \usage{
10 | performanceMetrics(object, ...)
11 |
12 | \S4method{performanceMetrics}{SummarizedBenchmark}(object, assay = NULL)
13 | }
14 | \arguments{
15 | \item{object}{a \code{\link[=SummarizedBenchmark-class]{SummarizedBenchmark}} object.}
16 |
17 | \item{...}{futher arguments, perhaps used by methods.}
18 |
19 | \item{assay}{a character string indicating an assay name.}
20 | }
21 | \value{
22 | A SimpleList with one element for each assay. Each element of the list contains a list of performance metric functions.
23 | }
24 | \description{
25 | Given a \code{\link[=SummarizedBenchmark-class]{SummarizedBenchmark}} object,
26 | returns a list of lists of performance metrics that have been defined for
27 | each assay. Optionally, if \code{assay =} is specified, performance metrics
28 | for only the specified subset of specified assays are returned.
29 | }
30 | \examples{
31 | data(sb)
32 | performanceMetrics(sb)
33 | performanceMetrics(sb, assay = "qvalue")
34 |
35 | }
36 | \seealso{
37 | \code{\link{addPerformanceMetric}}, \code{\link{estimatePerformanceMetrics}}
38 | }
39 | \author{
40 | Alejandro Reyes
41 | }
42 |
--------------------------------------------------------------------------------
/man/BenchDesign-class.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/AllClasses.R
3 | \docType{class}
4 | \name{BenchDesign-class}
5 | \alias{BenchDesign-class}
6 | \title{BenchDesign class}
7 | \description{
8 | Along with the SummarizedBenchmark class, one of the two main
9 | classses of the SummarizedBenchmark package. The BenchDesign class serves as
10 | a container for both the set of methods to be benchmarked and optionally the
11 | data to be used for benchmarking.
12 |
13 | Methods are organized as BDMethod objects and stored in as a list using the
14 | BDMethodList class. The BDData class is used to store benchmarking data, or
15 | in some cases, just the MD5 hash of the original data set. Any list object,
16 | including data.frame objects, can be specified for data. More details on the
17 | component classes are provided in the corresponding class documentation.
18 |
19 | For details on how to create new BenchDesign objects, see the
20 | documentation for the \code{\link{BenchDesign}} constructor.
21 | }
22 | \section{Slots}{
23 |
24 | \describe{
25 | \item{\code{data}}{a list containing the data to be used in the benchmark.}
26 |
27 | \item{\code{methods}}{a \code{BDMethodList} list of \code{BDMethod} objects to be
28 | compared in the benchmark.}
29 | }}
30 |
31 | \seealso{
32 | \code{\link{BenchDesign}}, \code{\link{BDMethod-class}}, \code{\link{BDMethodList-class}}, \code{\link{BDData-class}}
33 | }
34 | \author{
35 | Patrick Kimes
36 | }
37 |
--------------------------------------------------------------------------------
/R/printMethod.R:
--------------------------------------------------------------------------------
1 | #' Pretty print methods in a BenchDesign object
2 | #'
3 | #' Print out details about a method included in
4 | #' the BenchDesign. The `printMethods` function is just a wrapper
5 | #' to call `printMethod` on all methods in the BenchDesign.
6 | #'
7 | #' @param bd BenchDesign object.
8 | #' @param n name of a method in the BenchDesign to show.
9 | #'
10 | #' @return
11 | #' Brief description is returned to console.
12 | #'
13 | #' @examples
14 | #' ## create empty BenchDesign
15 | #' bench <- BenchDesign()
16 | #'
17 | #' ## currently no methods
18 | #' printMethods(bench)
19 | #'
20 | #' ## add method
21 | #' bench <- addMethod(bench, label = "method_a", p.adjust)
22 | #' bench <- addMethod(bench, label = "method_b", qvalue::qvalue)
23 | #'
24 | #' ## show a single method
25 | #' printMethod(bench, "method_a")
26 | #'
27 | #' ## show all methods
28 | #' printMethods(bench)
29 | #'
30 | #' @seealso \code{\link{BDMethod-class}}, \code{\link{BenchDesign-class}}
31 | #' @md
32 | #' @importFrom stringr str_pad
33 | #' @export
34 | #' @author Patrick Kimes
35 | printMethod <- function(bd, n = NULL) {
36 | if (is.null(n))
37 | n <- names(bd@methods)[1]
38 | stopifnot(n %in% names(bd@methods))
39 |
40 | cat(stringr::str_pad(paste0(n, " "), 60, "right", pad = "-"), "\n")
41 | show(bd@methods[[n]])
42 | }
43 |
44 |
45 | #' @rdname printMethod
46 | #' @export
47 | printMethods <- function(bd) {
48 | for (n in names(bd@methods)) {
49 | printMethod(bd, n)
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/inst/NEWS.Rd:
--------------------------------------------------------------------------------
1 | \name{sbnews}
2 | \title{SummarizedBenchmark News}
3 | \encoding{UTF-8}
4 |
5 | \section{Changes in version 2.3.7 (2019-09-18)}{
6 | \itemize{
7 | \item Bug fix: update call on `tidyr::gather` in `tidyUpMetrics`
8 | to work after bump in `tidyr` version to 1.0.0 on CRAN
9 | }
10 | }
11 |
12 | \section{Changes in version 2.3.6 (2019-09-06)}{
13 | \itemize{
14 | \item Replace `sc_example_counts` dataset from `scater` with call to
15 | `scater::mockSCE`
16 | \item Fix error thrown by `show.BDData` when dataset is a list
17 | }
18 | }
19 |
20 | \section{Changes in version 2.3.5 (2019-06-22)}{
21 | \itemize{
22 | \item Fix index title for "Feature: Error Handling" vignette
23 | \item Replace Rd references to `rlang::quos` with `rlang:quotation`
24 | topic page since aliasing appears to be causing warnings on
25 | Windows build
26 | \item Update pkgdown site with latest devel docs
27 | }
28 | }
29 |
30 | \section{Changes in version 2.3.4 (2019-06-18)}{
31 | \itemize{
32 | \item Fix scRNAseq simulation case study vignette to work with
33 | changes in `scRNAseq` package
34 | \item Add code examples and import statements to pass BiocCheck
35 | \item Update pkgdown site with latest devel docs
36 | }
37 | }
38 |
39 | \section{Changes in version 2.3.3 (2019-06-14)}{
40 | \itemize{
41 | \item Added NEWS file to track changes
42 | \item Incorporated major updates to package documentation and vignettes
43 | \item Added pkgdown site
44 | }
45 | }
46 |
47 |
--------------------------------------------------------------------------------
/R/dropMethod.R:
--------------------------------------------------------------------------------
1 | #' Remove method from BenchDesign object
2 | #'
3 | #' @description
4 | #' Takes a \code{\link[=BenchDesign-class]{BenchDesign}} object and the name of an
5 | #' existing method
6 | #' and returns a reduced \code{\link[=BenchDesign-class]{BenchDesign}} object with the
7 | #' method removed.
8 | #'
9 | #' @param bd \code{\link[=BenchDesign-class]{BenchDesign}} object.
10 | #' @param label Character name of method.
11 | #'
12 | #' @return
13 | #' Modified \code{\link[=BenchDesign-class]{BenchDesign}} object with
14 | #' specified method dropped.
15 | #'
16 | #' @examples
17 | #' ## empty BenchDesign
18 | #' bench <- BenchDesign()
19 | #'
20 | #' ## add methods
21 | #' bench <- addMethod(bench, label = "bonf", func = p.adjust,
22 | #' params = rlang::quos(p = pval, method = "bonferroni"))
23 | #' bench <- addMethod(bench, label = "BH", func = p.adjust,
24 | #' params = rlang::quos(p = pval, method = "BH"))
25 | #' BDMethodList(bench)
26 | #'
27 | #' ## remove methods
28 | #' bench <- dropMethod(bench, label = "bonf")
29 | #' BDMethodList(bench)
30 | #'
31 | #' @seealso \code{\link{modifyMethod}}, \code{\link{expandMethod}}, \code{\link{addMethod}}
32 | #' @md
33 | #' @export
34 | #' @author Patrick Kimes
35 | dropMethod <- function(bd, label) {
36 | UseMethod("dropMethod")
37 | }
38 |
39 | #' @export
40 | dropMethod.BenchDesign <- function(bd, label) {
41 | ## verify that method definition already exists
42 | if(!(label %in% names(bd@methods))) {
43 | stop("Specified method is not defined in BenchDesign.")
44 | }
45 |
46 | bd@methods[[label]] <- NULL
47 | return(bd)
48 | }
49 |
50 |
--------------------------------------------------------------------------------
/tests/testthat/test_addPerformanceFunction.R:
--------------------------------------------------------------------------------
1 | context("performanceFunctions")
2 | test_that("test='addPerformanceMetrics' returns correct error messages", {
3 | data(sb)
4 | fun <- function(query, truth, alpha=0.1){
5 | goodHits <- sum( (query < alpha) & truth == 1 )
6 | goodHits / sum(truth == 1)
7 | }
8 | expect_error( addPerformanceMetric(
9 | object=1:10,
10 | assay="qvalue",
11 | evalMetric="TPR",
12 | evalFunction=fun) )
13 | expect_error( addPerformanceMetric(
14 | sb,
15 | assay="notexisting",
16 | evalMetric="TPR",
17 | evalFunction=fun) )
18 | expect_error( addPerformanceMetric(
19 | sb,
20 | assay="notexisting",
21 | evalMetric=NULL,
22 | evalFunction=fun) )
23 | expect_error( addPerformanceMetric(
24 | sb,
25 | assay=NULL,
26 | evalMetric="TPR",
27 | evalFunction=fun) )
28 | expect_error( addPerformanceMetric(
29 | sb,
30 | assay="notexisting",
31 | evalMetric=c("TPR", "FDR"),
32 | evalFunction=fun) )
33 | expect_error( addPerformanceMetric(
34 | sb,
35 | assay="qvalue",
36 | evalFunction=fun) )
37 | fun <- function(query, truth2, alpha=0.1){
38 | goodHits <- sum( (query < alpha) & truth == 1 )
39 | goodHits / sum(truth == 1)
40 | }
41 | expect_error( addPerformanceMetric(
42 | sb,
43 | assay="qvalue",
44 | evalMetric="TPR",
45 | evalFunction=fun ) )
46 | fun <- function(query, truth, alpha){
47 | goodHits <- sum( (query < alpha) & truth == 1 )
48 | goodHits / sum(truth == 1)
49 | }
50 | expect_error( addPerformanceMetric(
51 | sb,
52 | assay="qvalue",
53 | evalMetric="TPR",
54 | evalFunction=fun ) )
55 | } )
56 |
--------------------------------------------------------------------------------
/man/BDMethod-setter.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/AllGenerics.R, R/BDMethodList-accessors.R,
3 | % R/BenchDesign-accessors.R
4 | \docType{methods}
5 | \name{BDMethod<-}
6 | \alias{BDMethod<-}
7 | \alias{BDMethod<-,BDMethodList,character,BDMethod-method}
8 | \alias{BDMethod<-,BDMethodList,character,NULL-method}
9 | \alias{BDMethod<-,BenchDesign,character,BDMethod-method}
10 | \alias{BDMethod<-,BenchDesign,character,NULL-method}
11 | \title{Set method in list or BenchDesign object}
12 | \usage{
13 | BDMethod(x, i) <- value
14 |
15 | \S4method{BDMethod}{BDMethodList,character,BDMethod}(x, i) <- value
16 |
17 | \S4method{BDMethod}{BDMethodList,character,`NULL`}(x, i) <- value
18 |
19 | \S4method{BDMethod}{BenchDesign,character,BDMethod}(x, i) <- value
20 |
21 | \S4method{BDMethod}{BenchDesign,character,`NULL`}(x, i) <- value
22 | }
23 | \arguments{
24 | \item{x}{\code{\link[=BenchDesign-class]{BenchDesign}} or
25 | \code{\link[=BDMethodList-class]{BDMethodList}} object.}
26 |
27 | \item{i}{character name of method.}
28 |
29 | \item{value}{\code{\link[=BDMethod-class]{BDMethod}} or \code{NULL}.}
30 | }
31 | \value{
32 | modified BenchDesign object
33 | }
34 | \description{
35 | Adds, replaces or removes a named \code{\link[=BDMethod-class]{BDMethod}} method
36 | in a \code{\link[=BDMethodList-class]{BDMethodList}} or
37 | \code{\link[=BenchDesign-class]{BenchDesign}} object with a specified
38 | \code{\link[=BDMethod-class]{BDMethod}} object.
39 |
40 | An existing method can be removed by setting the value to \code{NULL}.
41 | }
42 | \examples{
43 | bd <- BenchDesign()
44 | BDMethod(bd, "avg") <- BDMethod(x = base::mean)
45 | bd
46 |
47 | }
48 | \seealso{
49 | \code{\link{BDMethod}}
50 | }
51 | \author{
52 | Patrick Kimes
53 | }
54 |
--------------------------------------------------------------------------------
/R/BenchDesign-accessors.R:
--------------------------------------------------------------------------------
1 | #' @rdname BDData-setter
2 | #' @exportMethod "BDData<-"
3 | setReplaceMethod("BDData",
4 | signature(x = "BenchDesign", value = "BDDataOrNULL"),
5 | function (x, value) {
6 | x@data <- value
7 | x
8 | })
9 |
10 |
11 | #' @rdname BDMethod-setter
12 | #' @exportMethod "BDMethod<-"
13 | setReplaceMethod("BDMethod",
14 | signature(x = "BenchDesign", i = "character", value = "BDMethod"),
15 | function (x, i, value) {
16 | x@methods[[i]] <- value
17 | x
18 | })
19 |
20 | #' @rdname BDMethod-setter
21 | #' @exportMethod "BDMethod<-"
22 | setReplaceMethod("BDMethod",
23 | signature(x = "BenchDesign", i = "character", value = "NULL"),
24 | function (x, i, value) {
25 | x@methods[[i]] <- value
26 | x
27 | })
28 |
29 |
30 | #' @rdname BDMethodList-setter
31 | #' @exportMethod "BDMethodList<-"
32 | setReplaceMethod("BDMethodList",
33 | signature(x = "BenchDesign", value = "BDMethodList"),
34 | function (x, value) {
35 | x@methods <- value
36 | x
37 | })
38 |
39 |
40 | #' @rdname BDMethod
41 | #' @exportMethod "BDMethod"
42 | setMethod("BDMethod",
43 | signature(x = "BenchDesign"),
44 | function(x, i = 1) {
45 | BDMethod(x@methods, i = i)
46 | })
47 |
48 | #' @rdname BDMethodList
49 | #' @exportMethod "BDMethodList"
50 | setMethod("BDMethodList",
51 | signature(x = "BenchDesign"),
52 | function(..., x) {
53 | x@methods
54 | })
55 |
--------------------------------------------------------------------------------
/man/addPerformanceMetric.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/PerformanceMetrics.R
3 | \name{addPerformanceMetric}
4 | \alias{addPerformanceMetric}
5 | \title{Add performance metric to SummarizedBenchmark object}
6 | \usage{
7 | addPerformanceMetric(object, evalMetric, assay, evalFunction = NULL)
8 | }
9 | \arguments{
10 | \item{object}{A \code{\link[=SummarizedBenchmark-class]{SummarizedBenchmark}} object.}
11 |
12 | \item{evalMetric}{A string with the name of the evaluation metric.}
13 |
14 | \item{assay}{A string with an assay name. Indicates the assay that should be
15 | given as input to this performance metric.}
16 |
17 | \item{evalFunction}{A function that calculates a performance metric. It should
18 | contain at least two arguments, query and truth, where query is the output vector
19 | of a method and truth is the vector of true values. If additional parameters
20 | are specified, they must contain default values. If NULL, the 'evalMetric' string must
21 | be the name of a predefined metric available through 'availableMetrics()$function'.}
22 | }
23 | \value{
24 | A \code{\link[=SummarizedBenchmark-class]{SummarizedBenchmark}} object.
25 | }
26 | \description{
27 | This is a function to define performance metrics for benchmarking methods.
28 | The function is saved into the \code{performanceMetrics} slot.
29 | }
30 | \examples{
31 | data( sb )
32 | sb <- addPerformanceMetric(
33 | object=sb,
34 | assay="qvalue",
35 | evalMetric="TPR",
36 | evalFunction = function( query, truth, alpha=0.1 ){
37 | goodHits <- sum( (query < alpha) & truth == 1 )
38 | goodHits / sum(truth == 1)
39 | }
40 | )
41 |
42 | }
43 | \seealso{
44 | \code{\link{availableMetrics}}, \code{\link{performanceMetrics}}
45 | }
46 | \author{
47 | Alejandro Reyes
48 | }
49 |
--------------------------------------------------------------------------------
/man/SummarizedBenchmark-class.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/AllClasses.R
3 | \docType{class}
4 | \name{SummarizedBenchmark-class}
5 | \alias{SummarizedBenchmark-class}
6 | \title{SummarizedBenchmark class}
7 | \description{
8 | Extension of the \code{\link{RangedSummarizedExperiment}} to
9 | store the output of different methods intended for the same purpose
10 | in a given dataset. For example, a differential expression analysis could be
11 | done using \pkg{limma}-voom, \pkg{edgeR} and \pkg{DESeq2}. The
12 | SummarizedBenchmark class provides a framework that is useful to store, benckmark and
13 | compare results.
14 | }
15 | \section{Slots}{
16 |
17 | \describe{
18 | \item{\code{performanceMetrics}}{A \code{\link{SimpleList}} of the same length
19 | as the number of \code{\link{assays}} containing performance
20 | functions to be compared with the ground truths.}
21 |
22 | \item{\code{BenchDesign}}{A \code{\link{BenchDesign}} originally used to generate the
23 | results in the object.}
24 | }}
25 |
26 | \examples{
27 | ## loading the example data from iCOBRA
28 | library(iCOBRA)
29 | data(cobradata_example)
30 |
31 | ## a bit of data wrangling and reformatting
32 | assays <- list(
33 | qvalue=cobradata_example@padj,
34 | logFC=cobradata_example@score )
35 | assays[["qvalue"]]$DESeq2 <- p.adjust(cobradata_example@pval$DESeq2, method="BH")
36 | groundTruth <- DataFrame( cobradata_example@truth[,c("status", "logFC")] )
37 | colnames(groundTruth) <- names( assays )
38 | colData <- DataFrame( method=colnames(assays[[1]]) )
39 | groundTruth <- groundTruth[rownames(assays[[1]]),]
40 |
41 | ## constructing a SummarizedBenchmark object
42 | sb <- SummarizedBenchmark(
43 | assays=assays, colData=colData,
44 | groundTruth=groundTruth )
45 |
46 | }
47 | \author{
48 | Alejandro Reyes
49 | }
50 |
--------------------------------------------------------------------------------
/tests/testthat/test_metricsRerun.R:
--------------------------------------------------------------------------------
1 | context("estimatePeformanceMetrics")
2 | test_that("test='estimatePerformanceMetrics' with rerun=FALSE works appropiatetly", {
3 | df <- data.frame(pval = rnorm(100))
4 | bench <- BenchDesign(data = df)
5 | ## add methods
6 | bench <- addMethod(bench, label = "bonf", func = p.adjust,
7 | params = rlang::quos(p = pval, method = "bonferroni"))
8 | bench <- addMethod(bench, label = "BH", func = p.adjust,
9 | params = rlang::quos(p = pval, method = "BH"))
10 | ## evaluate benchmark experiment
11 | sb <- buildBench(bench)
12 | ## evaluate benchmark experiment w/ data sepecified
13 | sb <- buildBench(bench, data = df)
14 | sb <- addPerformanceMetric( sb, assay="default", evalMetric="rejections" )
15 |
16 | ## calling it twice throws an error saying it is up to date ##
17 | expect_error( estimatePerformanceMetrics(
18 | estimatePerformanceMetrics(sb, addColData=TRUE, rerun=FALSE ),
19 | addColData=TRUE, rerun=FALSE ) )
20 |
21 | ## results are identical between rerun=TRUE and rerun=FALSE ##
22 | sb <- estimatePerformanceMetrics(sb, addColData=TRUE)
23 | bench <- addMethod( bench, label="BH2", func=p.adjust,
24 | params = rlang::quos(p = pval, method = "BH") )
25 | sb2 <- updateBench( sb, bd=bench, dryrun=FALSE )
26 | res1 <- colData( estimatePerformanceMetrics( sb2, rerun=FALSE, addColData=TRUE ) )
27 | sb2 <- estimatePerformanceMetrics( sb2, rerun=TRUE, addColData=TRUE )
28 | res2 <- colData( sb2 )
29 | expect_identical( res2[,colnames( res1 )], res1 )
30 |
31 | ## Also works when modifying a method ##
32 | bench <- modifyMethod( bench,
33 | label="BH",
34 | param=rlang::quos(p=pval, method="hommel"))
35 | sb2 <- updateBench( sb2, bd=bench, dryrun=FALSE )
36 | expect_s4_class( estimatePerformanceMetrics( sb2, rerun=FALSE ), "DataFrame")
37 | })
38 |
--------------------------------------------------------------------------------
/man/tidyBDMethod.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/AllGenerics.R, R/BDMethod-tidy.R
3 | \docType{methods}
4 | \name{tidyBDMethod}
5 | \alias{tidyBDMethod}
6 | \alias{tidyBDMethod,BDMethod-method}
7 | \alias{tidyBDMethod,list-method}
8 | \alias{tidyBDMethod,SimpleList-method}
9 | \alias{tidyBDMethod,BenchDesign-method}
10 | \title{Tidy BDMethod Data}
11 | \usage{
12 | tidyBDMethod(obj, dat = NULL, eval = FALSE, label = FALSE)
13 |
14 | \S4method{tidyBDMethod}{BDMethod}(obj, dat, eval)
15 |
16 | \S4method{tidyBDMethod}{list}(obj, dat = NULL, eval = FALSE,
17 | label = FALSE)
18 |
19 | \S4method{tidyBDMethod}{SimpleList}(obj, dat = NULL, eval = FALSE,
20 | label = FALSE)
21 |
22 | \S4method{tidyBDMethod}{BenchDesign}(obj, dat = NULL, eval = FALSE,
23 | label = FALSE)
24 | }
25 | \arguments{
26 | \item{obj}{BDMethod object, list/List of BDMethod objects (e.g. a
27 | BDMethodList), or a BenchDesign object}
28 |
29 | \item{dat}{optional data object to use when evaluating any
30 | unevaluated expressionsin \code{bdm} meta data.
31 | (default = NULL)}
32 |
33 | \item{eval}{logical whether to evaluate any quosures in the meta slot
34 | of the BDMethod objects. (default = FALSE)}
35 |
36 | \item{label}{logical whether to add a "label" column to the resulting
37 | table containing the names of the methods if \code{obj} was
38 | specified as a named list. (default = FALSE)}
39 | }
40 | \value{
41 | A named vector of meta data if only a single BDMethod object specified, else
42 | a tibble of meta data for the specified list of methods.
43 | }
44 | \description{
45 | A helper function to extract information for a single
46 | or multiple BDMethod object or a list of BDMethod objects.
47 | }
48 | \details{
49 | If any quosures are specified to the "meta" slot of a BDMethod object,
50 | the quosure is converted to a text string using \code{rlang::quo_text}.
51 | }
52 | \author{
53 | Patrick Kimes
54 | }
55 |
--------------------------------------------------------------------------------
/R/BenchDesign-show.R:
--------------------------------------------------------------------------------
1 | .show.BenchDesign <- function(object) {
2 | cat(stringr::str_pad("BenchDesign ", 60, "right", "-"), "\n")
3 | cat(" benchmark data:\n")
4 | if (!is.null(object@data)) {
5 | dtype <- object@data@type
6 | cat(" type:", object@data@type, "\n")
7 | if (dtype == "data")
8 | cat(" names:", paste(names(object@data@data), collapse=", "), "\n")
9 | if (dtype == "md5hash")
10 | cat(" MD5 hash:", stringr::str_trunc(object@data@data, 50), "\n")
11 | } else {
12 | cat(" NULL\n")
13 | }
14 | cat(" benchmark methods:\n")
15 | if (length(object@methods) < 1) {
16 | cat(" none\n")
17 | } else {
18 | max_c <- 20
19 | m1 <- max(nchar(names(utils::head(object@methods))))
20 | m1 <- min(m1, max_c)
21 | m2 <- max(nchar(sapply(utils::head(object@methods), function(x) { rlang::quo_text(x@fc) })))
22 | m2 <- min(m2, max_c)
23 | for (n in names(utils::head(object@methods, 5))) {
24 | p1 <- stringr::str_pad(stringr::str_trunc(n, max_c), m1 + 1, "left", " ")
25 | p2 <- stringr::str_pad(stringr::str_trunc(gsub("\n", ";", rlang::quo_text(object@methods[[n]]@fc)), max_c),
26 | m2 + 1, "right", " ")
27 | cat(" method: ", p1, "; func: ", p2, "\n", sep="")
28 | }
29 | if (length(object@methods) > 5 ) {
30 | cat(" ... and", length(object@methods) - 5, "more methods.\n")
31 | }
32 | }
33 | }
34 |
35 | #' Show BenchDesign object
36 | #'
37 | #' @param object BenchDesign object to show
38 | #'
39 | #' @return
40 | #' Print description of BenchDesign object to console
41 | #'
42 | #' @importFrom stringr str_pad str_trunc
43 | #' @importFrom rlang quo_text
44 | #' @importFrom utils head
45 | #' @rdname BenchDesign-show
46 | setMethod("show", signature(object = "BenchDesign"), .show.BenchDesign)
47 |
--------------------------------------------------------------------------------
/R/BDMethod-show.R:
--------------------------------------------------------------------------------
1 | .show.BDMethod <- function(object) {
2 | cat(stringr::str_pad("BenchDesign Method (BDMethod) ", 60, "right", pad = "-"), "\n")
3 | cat(" method: ")
4 | func_q <- rlang::quo_text(object@fc, nlines = 3)
5 | if (!grepl("^function\\(", func_q)) {
6 | cat(stringr::str_trunc(func_q, 50))
7 | func_q <- rlang::quo_text(object@f, nlines = 3)
8 | }
9 | func_q <- gsub("\\s*\n\\s*", " ", func_q)
10 | cat("\n ", stringr::str_trunc(func_q, 56), "\n")
11 | cat(" parameters:\n")
12 | if (length(object@params) > 0) {
13 | param_n <- names(object@params)
14 | param_q <- sapply(object@params, quo_text)
15 | for (i in seq(param_n))
16 | cat(stringr::str_trunc(paste(" ", param_n[i], ":", param_q[i]), 60), "\n")
17 | } else {
18 | cat(" none\n")
19 | }
20 | cat(" post:\n")
21 | if (!is.null(object@post)) {
22 | post_n <- names(object@post)
23 | post_q <- lapply(object@post, rlang::quo_text, nlines = 3)
24 | post_q <- gsub("\\s*\n\\s*", " ", post_q)
25 | for (i in seq(post_n))
26 | cat(stringr::str_trunc(paste(" ", post_n[i], ":", post_q[i]), 60), "\n")
27 | } else {
28 | cat(" none\n")
29 | }
30 | cat(" meta:\n")
31 | if (!is.null(object@meta)) {
32 | meta_n <- names(object@meta)
33 | meta_q <- sapply(object@meta, quo_text)
34 | for (i in seq(meta_n))
35 | cat(stringr::str_trunc(paste(" ", meta_n[i], ":", meta_q[i]), 60), "\n")
36 | } else {
37 | cat(" none\n")
38 | }
39 | }
40 |
41 | #' Show BDMethod object
42 | #'
43 | #' @param object BDMethod object to show
44 | #'
45 | #' @return
46 | #' Print description of BDMethod object to console
47 | #'
48 | #' @importFrom stringr str_pad str_trunc
49 | #' @importFrom rlang quo_text
50 | #' @rdname BDMethod-show
51 | setMethod("show", signature(object = "BDMethod"), .show.BDMethod)
52 |
--------------------------------------------------------------------------------
/man/BDData.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/AllGenerics.R, R/BDData-constructor.R
3 | \docType{methods}
4 | \name{BDData}
5 | \alias{BDData}
6 | \alias{BDData,ANY-method}
7 | \alias{BDData,BenchDesign-method}
8 | \alias{BDData,SummarizedBenchmark-method}
9 | \alias{BDData,BDData-method}
10 | \title{Create a new BDData object}
11 | \usage{
12 | BDData(data)
13 |
14 | \S4method{BDData}{ANY}(data)
15 |
16 | \S4method{BDData}{BenchDesign}(data)
17 |
18 | \S4method{BDData}{SummarizedBenchmark}(data)
19 |
20 | \S4method{BDData}{BDData}(data)
21 | }
22 | \arguments{
23 | \item{data}{a list object of data or MD5 hash string}
24 | }
25 | \value{
26 | BDData object
27 | }
28 | \description{
29 | Initializes a new BDData object of benchmarking data.
30 |
31 | Data sets are stored as BDData objects within BenchDesign
32 | objects as well as SummarizedBenchmark objects. However, because
33 | data is directly specified to the BenchDesign constructor, there
34 | is usually no need to call the BDData constructor to create completely
35 | new data objects.
36 |
37 | The BDData constructor is most useful for extracting the data sets
38 | contained in BenchDesign objects as well as SummarizedBenchmark objects.
39 | By default, the BDData object stored in SummarizedBenchmark objects will
40 | be MD5 hashes rather than the complete original data set.
41 | \code{\link{compareBDData}} can be used to compare various forms of
42 | BDData, as shown in the examples below.
43 | }
44 | \examples{
45 | ## construct from data.frame
46 | datadf <- data.frame(x = 1:5, y = runif(5))
47 | bdd_df <- BDData(datadf)
48 | bdd_df
49 |
50 | ## construct from MD5 hash of data.frame
51 | bdd_md5 <- BDData(digest::digest(datadf))
52 | bdd_md5
53 |
54 | ## compare two BDData objects
55 | compareBDData(bdd_df, bdd_md5)
56 |
57 | ## note that the data is the same, i.e. the MD5 hashes match, but the
58 | ## data types ("data" vs. "md5has") are different
59 |
60 | }
61 | \seealso{
62 | \code{\link{BDData-class}}, \code{\link{BenchDesign}}
63 | }
64 | \author{
65 | Patrick Kimes
66 | }
67 |
--------------------------------------------------------------------------------
/DESCRIPTION:
--------------------------------------------------------------------------------
1 | Package: SummarizedBenchmark
2 | Type: Package
3 | Title: Classes and methods for performing benchmark comparisons
4 | Version: 2.11.1
5 | Authors@R: c(person("Alejandro", "Reyes", role = "aut",
6 | email = "alejandro.reyes.ds@gmail.com",
7 | comment = c(ORCID = "0000-0001-8717-6612")),
8 | person("Patrick", "Kimes", role = c("aut", "cre"),
9 | email = "patrick.kimes@gmail.com",
10 | comment = c(ORCID = "0000-0001-6819-9077")))
11 | BugReports: https://github.com/areyesq89/SummarizedBenchmark/issues
12 | URL: https://github.com/areyesq89/SummarizedBenchmark, http://bioconductor.org/packages/SummarizedBenchmark/
13 | Description: This package defines the BenchDesign and SummarizedBenchmark classes for building,
14 | executing, and evaluating benchmark experiments of computational methods. The SummarizedBenchmark
15 | class extends the RangedSummarizedExperiment object, and is designed to provide infrastructure
16 | to store and compare the results of applying different methods to a shared data set.
17 | This class provides an integrated interface to store metadata such as method parameters and software
18 | versions as well as ground truths (when these are available) and evaluation metrics.
19 | biocViews: Software, Infrastructure
20 | Depends: R (>= 3.6),
21 | tidyr,
22 | SummarizedExperiment,
23 | S4Vectors,
24 | BiocGenerics,
25 | methods,
26 | UpSetR,
27 | rlang,
28 | stringr,
29 | utils,
30 | BiocParallel,
31 | ggplot2,
32 | mclust,
33 | dplyr,
34 | digest,
35 | sessioninfo,
36 | crayon,
37 | tibble
38 | Suggests: iCOBRA,
39 | BiocStyle,
40 | rmarkdown,
41 | knitr,
42 | magrittr,
43 | IHW,
44 | qvalue,
45 | testthat,
46 | DESeq2,
47 | edgeR,
48 | limma,
49 | tximport,
50 | readr,
51 | scRNAseq,
52 | splatter,
53 | scater,
54 | rnaseqcomp,
55 | biomaRt
56 | License: GPL (>= 3)
57 | Encoding: UTF-8
58 | LazyData: true
59 | VignetteBuilder: knitr
60 | RoxygenNote: 6.1.1
61 | Config/testthat/edition: 3
62 |
--------------------------------------------------------------------------------
/docs/docsearch.js:
--------------------------------------------------------------------------------
1 | $(function() {
2 |
3 | // register a handler to move the focus to the search bar
4 | // upon pressing shift + "/" (i.e. "?")
5 | $(document).on('keydown', function(e) {
6 | if (e.shiftKey && e.keyCode == 191) {
7 | e.preventDefault();
8 | $("#search-input").focus();
9 | }
10 | });
11 |
12 | $(document).ready(function() {
13 | // do keyword highlighting
14 | /* modified from https://jsfiddle.net/julmot/bL6bb5oo/ */
15 | var mark = function() {
16 |
17 | var referrer = document.URL ;
18 | var paramKey = "q" ;
19 |
20 | if (referrer.indexOf("?") !== -1) {
21 | var qs = referrer.substr(referrer.indexOf('?') + 1);
22 | var qs_noanchor = qs.split('#')[0];
23 | var qsa = qs_noanchor.split('&');
24 | var keyword = "";
25 |
26 | for (var i = 0; i < qsa.length; i++) {
27 | var currentParam = qsa[i].split('=');
28 |
29 | if (currentParam.length !== 2) {
30 | continue;
31 | }
32 |
33 | if (currentParam[0] == paramKey) {
34 | keyword = decodeURIComponent(currentParam[1].replace(/\+/g, "%20"));
35 | }
36 | }
37 |
38 | if (keyword !== "") {
39 | $(".contents").unmark({
40 | done: function() {
41 | $(".contents").mark(keyword);
42 | }
43 | });
44 | }
45 | }
46 | };
47 |
48 | mark();
49 | });
50 | });
51 |
52 | /* Search term highlighting ------------------------------*/
53 |
54 | function matchedWords(hit) {
55 | var words = [];
56 |
57 | var hierarchy = hit._highlightResult.hierarchy;
58 | // loop to fetch from lvl0, lvl1, etc.
59 | for (var idx in hierarchy) {
60 | words = words.concat(hierarchy[idx].matchedWords);
61 | }
62 |
63 | var content = hit._highlightResult.content;
64 | if (content) {
65 | words = words.concat(content.matchedWords);
66 | }
67 |
68 | // return unique words
69 | var words_uniq = [...new Set(words)];
70 | return words_uniq;
71 | }
72 |
73 | function updateHitURL(hit) {
74 |
75 | var words = matchedWords(hit);
76 | var url = "";
77 |
78 | if (hit.anchor) {
79 | url = hit.url_without_anchor + '?q=' + escape(words.join(" ")) + '#' + hit.anchor;
80 | } else {
81 | url = hit.url + '?q=' + escape(words.join(" "));
82 | }
83 |
84 | return url;
85 | }
86 |
--------------------------------------------------------------------------------
/man/BDMethodList.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/AllGenerics.R, R/BDMethodList-constructor.R,
3 | % R/BenchDesign-accessors.R, R/SummarizedBenckmark-accessors.R
4 | \docType{methods}
5 | \name{BDMethodList}
6 | \alias{BDMethodList}
7 | \alias{BDMethodList,ANY-method}
8 | \alias{coerce}
9 | \alias{BDMethodList,BenchDesign-method}
10 | \alias{BDMethodList,SummarizedBenchmark-method}
11 | \title{Create a new BDMethodList object}
12 | \usage{
13 | BDMethodList(..., x = NULL)
14 |
15 | \S4method{BDMethodList}{ANY}(..., x = NULL)
16 |
17 | \S4method{BDMethodList}{BenchDesign}(..., x = NULL)
18 |
19 | \S4method{BDMethodList}{SummarizedBenchmark}(..., x = NULL)
20 | }
21 | \arguments{
22 | \item{...}{a named list of \code{\link[=BDMethod-class]{BDMethod}} objects}
23 |
24 | \item{x}{a \code{\link[=BenchDesign-class]{BenchDesign}} or
25 | \code{\link[=SummarizedBenchmark-class]{SummarizedBenchmark}} object to extract
26 | the list of methods from. (default = NULL)}
27 | }
28 | \value{
29 | BDMethodList object
30 | }
31 | \description{
32 | Initializes a new SimpleList of BenchDesign method (\code{\link[=BDMethod-class]{BDMethod}}) objects.
33 |
34 | Similar to \code{\link[=BDMethod-class]{BDMethod}} objects, \code{\link[=BDMethodList-class]{BDMethodList}}
35 | typically do not need to be
36 | directly constructed. Because the list of methods is only useful as art of a
37 | \code{\link[=BenchDesign-class]{BenchDesign}} object, it is more common to simply manipulate the
38 | list of methods through calls to the corresponding \code{\link[=BenchDesign-class]{BenchDesign}}, e.g.
39 | \code{\link{addMethod}} to add a new method to the list.
40 |
41 | The constructor can also be used to access the \code{\link[=BDMethodList-class]{BDMethodList}} list
42 | of methods in a \code{\link[=BenchDesign-class]{BenchDesign}} object.
43 | }
44 | \examples{
45 | ## construct an empty list
46 | bdml <- BDMethodList()
47 |
48 | ## construct a list with BDMethod objects
49 | bdml <- BDMethodList(m_method = BDMethod(base::mean),
50 | s_method = BDMethod(function(x) { x^2 }))
51 | bdml
52 |
53 | ## construct a BenchDesign with a BDMethodList
54 | bd <- BenchDesign(methods = bdml)
55 |
56 | ## access the BDMethodList in the BenchDesign
57 | BDMethodList(bd)
58 |
59 | }
60 | \seealso{
61 | \code{\link{BDMethodList-class}}, \code{\link{BenchDesign}}, \code{\link{BDMethod}}
62 | }
63 | \author{
64 | Patrick Kimes
65 | }
66 |
--------------------------------------------------------------------------------
/man/modifyMethod.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/modifyMethod.R
3 | \name{modifyMethod}
4 | \alias{modifyMethod}
5 | \title{Modify method in BenchDesign object}
6 | \usage{
7 | modifyMethod(bd, label, params, .overwrite = FALSE)
8 | }
9 | \arguments{
10 | \item{bd}{\code{\link[=BenchDesign-class]{BenchDesign}} object.}
11 |
12 | \item{label}{Character name of method to be modified.}
13 |
14 | \item{params}{Named quosure list created using \code{\link[rlang:quotation]{quos}} of
15 | \code{parameter = value} paiars to replace in the method definition.
16 | The \code{post}, and \code{meta} parameters of the method can be
17 | modified using the special keywords, \code{bd.post}, and \code{bd.meta}
18 | (the prefix denoting that these values should modify \code{\link[=BenchDesign-class]{BenchDesign}}
19 | parameters). All other named parameters will be added to the list of
20 | parameters to be passed to \code{func}.}
21 |
22 | \item{.overwrite}{Logical whether to overwrite the complete existing list of
23 | parameters to be passed to \code{func} (\code{TRUE}), or to simply add
24 | the new parameters to the existing list and only replace overlapping
25 | parameters (\code{FALSE}). (default = \code{FALSE})}
26 | }
27 | \value{
28 | Modified \code{\link[=BenchDesign-class]{BenchDesign}} object with single method
29 | parameters modified.
30 | }
31 | \description{
32 | Takes a \code{\link[=BenchDesign-class]{BenchDesign}} object, the name of an
33 | existing method, and new parameter specifications,
34 | and returns a modified \code{\link[=BenchDesign-class]{BenchDesign}} object with
35 | the specified changes.
36 | }
37 | \examples{
38 | ## empty BenchDesign
39 | bench <- BenchDesign()
40 |
41 | ## add method
42 | bench <- addMethod(bench, label = "qv",
43 | func = qvalue::qvalue,
44 | post = function(x) { x$qvalue },
45 | meta = list(note = "storey's q-value"),
46 | params = rlang::quos(p = pval))
47 |
48 | ## modify method 'meta' property of 'qv' method
49 | bench <- modifyMethod(bench, label = "qv",
50 | params = rlang::quos(bd.meta =
51 | list(note = "Storey's q-value")))
52 |
53 | ## verify that method has been updated
54 | printMethod(bench, "qv")
55 |
56 | }
57 | \seealso{
58 | \code{\link{addMethod}}, \code{\link{expandMethod}}, \code{\link{dropMethod}}
59 | }
60 | \author{
61 | Patrick Kimes
62 | }
63 |
--------------------------------------------------------------------------------
/man/BenchDesign.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/AllGenerics.R, R/BenchDesign-constructor.R,
3 | % R/SummarizedBenckmark-accessors.R
4 | \docType{methods}
5 | \name{BenchDesign}
6 | \alias{BenchDesign}
7 | \alias{BenchDesign,ANY-method}
8 | \alias{BenchDesign,SummarizedBenchmark-method}
9 | \title{Create a new BenchDesign object}
10 | \usage{
11 | BenchDesign(..., methods = NULL, data = NULL)
12 |
13 | \S4method{BenchDesign}{ANY}(..., methods = NULL, data = NULL)
14 |
15 | \S4method{BenchDesign}{SummarizedBenchmark}(methods, data)
16 | }
17 | \arguments{
18 | \item{...}{named set of \code{BDMethod} objects and/or unnamed
19 | \code{BenchDesign} objects. Only the methods of any \code{BenchDesign}
20 | object will be used, and the data slot of the objects will be
21 | ignored.}
22 |
23 | \item{methods}{named set of \code{BDMethod} objects and/or unnamed
24 | \code{BenchDesign} objects as a list. (default = NULL)}
25 |
26 | \item{data}{optional data.frame or other list object to be
27 | used in the benchmark. (default = NULL)}
28 | }
29 | \value{
30 | \code{BenchDesign} object.
31 | }
32 | \description{
33 | Initializes a new BenchDesign object of benchmarking methods and data.
34 |
35 | The BenchDesign class serves as the core container
36 | for methods and data used for benchmarking in the SummarizedBenchmark package. The object
37 | can be initialized with a list of methods ot be benchmarked, a default benchmarking data set,
38 | both or neither. Methods must be passed to the constructor as \code{BDMethod} or \code{BDMethodList}
39 | objects.
40 |
41 | The constructor can also be used to access the BenchDesign stored in a SummarizedBenchmark
42 | object.
43 | }
44 | \examples{
45 | ## with no input
46 | bd <- BenchDesign()
47 |
48 | ## with data - data must be a named argument
49 | datadf <- data.frame(pval = runif(20), x1 = rnorm(20))
50 | bd <- BenchDesign(data = datadf)
51 |
52 | ## with two methods and data
53 | method_bh <- BDMethod(stats::p.adjust, params = rlang::quos(p = pval, method = "BH"))
54 | method_bf <- BDMethod(stats::p.adjust, params = rlang::quos(p = pval, method = "bonferroni"))
55 | bd <- BenchDesign(bh = method_bh, bonf = method_bf,
56 | data = datadf)
57 |
58 | ## with BDMethodList and data
59 | bdml <- BDMethodList(bh = method_bh, bonf = method_bf)
60 | bd <- BenchDesign(methods = bdml, data = datadf)
61 |
62 | }
63 | \seealso{
64 | \code{\link{BenchDesign-class}}, \code{\link{BDMethod}}, \code{\link{BDMethodList}}
65 | }
66 | \author{
67 | Patrick Kimes
68 | }
69 |
--------------------------------------------------------------------------------
/man/compareBenchDesigns.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/AllGenerics.R, R/compareBenchDesigns.R
3 | \docType{methods}
4 | \name{compareBenchDesigns}
5 | \alias{compareBenchDesigns}
6 | \alias{compareBenchDesigns,SummarizedBenchmark,missing-method}
7 | \alias{compareBenchDesigns,SummarizedBenchmark,SummarizedBenchmark-method}
8 | \alias{compareBenchDesigns,SummarizedBenchmark,BenchDesign-method}
9 | \alias{compareBenchDesigns,BenchDesign,SummarizedBenchmark-method}
10 | \alias{compareBenchDesigns,BenchDesign,BenchDesign-method}
11 | \title{Compare BenchDesign objects}
12 | \usage{
13 | compareBenchDesigns(x, y = NULL, ...)
14 |
15 | \S4method{compareBenchDesigns}{SummarizedBenchmark,missing}(x, y = NULL,
16 | ...)
17 |
18 | \S4method{compareBenchDesigns}{SummarizedBenchmark,SummarizedBenchmark}(x,
19 | y = NULL, ...)
20 |
21 | \S4method{compareBenchDesigns}{SummarizedBenchmark,BenchDesign}(x,
22 | y = NULL, ...)
23 |
24 | \S4method{compareBenchDesigns}{BenchDesign,SummarizedBenchmark}(x,
25 | y = NULL, ...)
26 |
27 | \S4method{compareBenchDesigns}{BenchDesign,BenchDesign}(x, y = NULL, ...)
28 | }
29 | \arguments{
30 | \item{x}{a SummarizedBenchmark or BenchDesign object}
31 |
32 | \item{y}{an optional second SummarizedBenchmark or BenchDesign object
33 | (default = NULL)}
34 |
35 | \item{...}{other parameters}
36 | }
37 | \value{
38 | list of comparison results
39 | }
40 | \description{
41 | Comparison of BenchDesign objects and BenchDesign method information
42 | stored in SummarizedBenchmark objects. Inputs can be either BenchDesign
43 | or SummarizedBenchmark objects. If SummarizedBenchmark objects are
44 | specified, the method metadata stored in the \code{colData} will be
45 | used for the comparison. If only a single SummarizedBenchmark object is
46 | specified, the \code{colData} information will be compared with the
47 | BenchDesign object in the \code{BenchDesign} slot of the object.
48 | To compare the \code{BenchDesign} slots of SummarizedBenchmark objects,
49 | the BenchDesigns should be extracted with \code{BenchDesign(sb)} and
50 | passed as inputs (see Examples).
51 | }
52 | \examples{
53 | bd1 <-
54 | BenchDesign(norm_sd = BDMethod(stats::rnorm,
55 | params = rlang::quos(n = n),
56 | post = sd),
57 | t_sd = BDMethod(stats::rt,
58 | params = rlang::quos(n = n, df = 1),
59 | post = sd))
60 | bd2 <- addMethod(bd1, "chi_sd",
61 | func = stats::rchisq,
62 | params = rlang::quos(n = n, df = 1),
63 | post = sd)
64 |
65 | compareBenchDesigns(bd1, bd2)
66 |
67 | }
68 | \seealso{
69 | \code{\link{compareBDMethod}}, \code{\link{compareBDData}}
70 | }
71 | \author{
72 | Patrick Kimes
73 | }
74 |
--------------------------------------------------------------------------------
/R/BenchDesign-constructor.R:
--------------------------------------------------------------------------------
1 | #' Create a new BenchDesign object
2 | #'
3 | #' @description
4 | #' Initializes a new BenchDesign object of benchmarking methods and data.
5 | #'
6 | #' The BenchDesign class serves as the core container
7 | #' for methods and data used for benchmarking in the SummarizedBenchmark package. The object
8 | #' can be initialized with a list of methods ot be benchmarked, a default benchmarking data set,
9 | #' both or neither. Methods must be passed to the constructor as \code{BDMethod} or \code{BDMethodList}
10 | #' objects.
11 | #'
12 | #' The constructor can also be used to access the BenchDesign stored in a SummarizedBenchmark
13 | #' object.
14 | #'
15 | #' @param ... named set of \code{BDMethod} objects and/or unnamed
16 | #' \code{BenchDesign} objects. Only the methods of any \code{BenchDesign}
17 | #' object will be used, and the data slot of the objects will be
18 | #' ignored.
19 | #' @param methods named set of \code{BDMethod} objects and/or unnamed
20 | #' \code{BenchDesign} objects as a list. (default = NULL)
21 | #' @param data optional data.frame or other list object to be
22 | #' used in the benchmark. (default = NULL)
23 | #'
24 | #' @return
25 | #' \code{BenchDesign} object.
26 | #'
27 | #' @examples
28 | #' ## with no input
29 | #' bd <- BenchDesign()
30 | #'
31 | #' ## with data - data must be a named argument
32 | #' datadf <- data.frame(pval = runif(20), x1 = rnorm(20))
33 | #' bd <- BenchDesign(data = datadf)
34 | #'
35 | #' ## with two methods and data
36 | #' method_bh <- BDMethod(stats::p.adjust, params = rlang::quos(p = pval, method = "BH"))
37 | #' method_bf <- BDMethod(stats::p.adjust, params = rlang::quos(p = pval, method = "bonferroni"))
38 | #' bd <- BenchDesign(bh = method_bh, bonf = method_bf,
39 | #' data = datadf)
40 | #'
41 | #' ## with BDMethodList and data
42 | #' bdml <- BDMethodList(bh = method_bh, bonf = method_bf)
43 | #' bd <- BenchDesign(methods = bdml, data = datadf)
44 | #'
45 | #' @seealso \code{\link{BenchDesign-class}}, \code{\link{BDMethod}}, \code{\link{BDMethodList}}
46 | #' @name BenchDesign
47 | #' @importFrom methods .valueClassTest
48 | #' @export
49 | #' @author Patrick Kimes
50 | NULL
51 |
52 | .BenchDesign <- function(..., methods, data) {
53 | ## add shortcut for just a single SummarizedBenchmark object (want to return w/ data)
54 | ml <- list(...)
55 | if (length(ml) == 1 && is.null(methods) && is.null(data) && is(ml[[1]], "SummarizedBenchmark"))
56 | return(BenchDesign(methods = ml[[1]]))
57 |
58 | bdml <- BDMethodList(..., x = methods)
59 | if (!is.null(data) && !is(data, "BDData")) {
60 | data <- new("BDData", data = data,
61 | type = ifelse(is(data, "character"), "md5hash", "data"))
62 | }
63 | new("BenchDesign", methods = bdml, data = data)
64 | }
65 |
66 | #' @rdname BenchDesign
67 | #' @exportMethod "BenchDesign"
68 | setMethod("BenchDesign", signature(methods = "ANY", data = "ANY"), .BenchDesign)
69 |
--------------------------------------------------------------------------------
/R/DefaultMetrics.R:
--------------------------------------------------------------------------------
1 | #' @title List pre-defined metrics for SummarizedBenchmark objects
2 | #' @aliases availableMetrics
3 | #' @description
4 | #' This function returns a data frame summarizing the default performance metrics provided in this package.
5 | #' The data.frame contains three columns, `functions` is the name of the performance metric, `description`
6 | #' is longer description of the performance metric and `requiredTruth` is logical depending on whether the
7 | #' performance metrics require ground truths.
8 | #' @examples
9 | #' availableMetrics()
10 | #'
11 | #' @return A data.frame summarizing the default performance metrics provided in this package.
12 | #' @md
13 | #' @export
14 | #' @author Alejandro Reyes
15 | availableMetrics <- function(){
16 | data.frame(
17 | functions=c( "rejections", "TPR", "TNR", "FDR", "FNR",
18 | "correlation", "sdad", "hamming", "LPnorm",
19 | "adjustedRandIndex" ),
20 | description=c("Number of rejections", "True Positive Rate", "True Negative Rate",
21 | "False Discovery Rate (estimated)", "False Negative Rate", "Pearson correlation",
22 | "Standard Deviation of the Absolute Difference", "Hamming distance",
23 | "L_{p} norm", "Adjusted Rand Index"),
24 | requiresTruth=rep( c(FALSE, TRUE), c( 1, 9 ) ) )
25 | }
26 |
27 | sb.TPR <- function( query, truth, alpha=0.1 ){
28 | sum( query <= alpha & truth == 1, na.rm = TRUE ) / sum( truth == 1, na.rm = TRUE )
29 | }
30 |
31 | sb.TNR <- function( query, truth, alpha=0.1 ){
32 | sum( ( !query <= alpha ) & truth == 0, na.rm = TRUE ) / sum( truth == 0, na.rm = TRUE )
33 | }
34 |
35 | sb.FDR <- function( query, truth, alpha=0.1 ){
36 | sum( query <= alpha & truth == 0, na.rm = TRUE ) / sum( query <= alpha, na.rm = TRUE )
37 | }
38 |
39 | sb.FNR <- function( query, truth, alpha=0.1 ){
40 | sum( !(query <= alpha) & truth == 1, na.rm = TRUE ) / sum( !( query <= alpha ), na.rm = TRUE )
41 | }
42 |
43 | sb.rejections <- function( query, truth, alpha=0.1 ){
44 | sum( query <= alpha, na.rm = TRUE )
45 | }
46 |
47 | #' @importFrom S4Vectors cor
48 | sb.correlation <- function( query, truth, method="pearson" ){
49 | cor( query, truth, method=method )
50 | }
51 |
52 | #' @importFrom BiocGenerics sd
53 | sb.sdad <- function( query, truth ){
54 | sd( abs( query - truth ) )
55 | }
56 |
57 | sb.hamming <- function( query, truth ){
58 | sum( !query == truth, na.rm = TRUE )
59 | }
60 |
61 | sb.Lpnorm <- function( query, truth, p=2 ){
62 | sum( abs(query - truth) ^ p, na.rm = TRUE ) ^ (1/p)
63 | }
64 |
65 | #' @importFrom mclust adjustedRandIndex
66 | sb.adjustedRandIndex <- function( query, truth ){
67 | adjustedRandIndex( query, truth )
68 | }
69 |
70 | assayHasTruths <- function( object, assay ){
71 | if( is.null( rowData(object)[[assay]] ) ){
72 | return(FALSE)
73 | }
74 | if( all( is.na( rowData( object )[[assay]] ) ) ){
75 | return(FALSE)
76 | }else{
77 | return(TRUE)
78 | }
79 | }
80 |
81 |
--------------------------------------------------------------------------------
/vignettes/library.bib:
--------------------------------------------------------------------------------
1 | @article{Stephens_2017,
2 | author = {Stephens, Matthew},
3 | doi = {10.1093/biostatistics/kxw041},
4 | journal = {Biostatistics},
5 | number = {2},
6 | pages = {275--294},
7 | title = {{False discovery rates: a new deal}},
8 | volume = {18},
9 | year = {2017}
10 | }
11 | @article{Soneson_2016,
12 | title={{iCOBRA}: open, reproducible, standardized and live method benchmarking},
13 | volume={13},
14 | ISSN={1548-7105},
15 | url={http://dx.doi.org/10.1038/nmeth.3805},
16 | DOI={10.1038/nmeth.3805},
17 | number={4},
18 | journal={Nature Methods},
19 | author={Soneson, Charlotte and Robinson, Mark D},
20 | year={2016},
21 | month={Mar},
22 | pages={283–283}
23 | }
24 | @article{Li_2017,
25 | title={A Comprehensive Mouse Transcriptomic BodyMap across 17 Tissues by RNA-seq},
26 | volume={7},
27 | ISSN={2045-2322},
28 | url={http://dx.doi.org/10.1038/s41598-017-04520-z},
29 | DOI={10.1038/s41598-017-04520-z},
30 | number={1},
31 | journal={Scientific Reports},
32 | author={Li, Bin and Qing, Tao and Zhu, Jinhang and Wen, Zhuo and Yu, Ying and Fukumura, Ryutaro and Zheng, Yuanting and Gondo, Yoichi and Shi, Leming},
33 | year={2017}
34 | }
35 | @article{Teng_2016,
36 | title={A benchmark for RNA-seq quantification pipelines},
37 | volume={17},
38 | ISSN={1474-760X},
39 | url={http://dx.doi.org/10.1186/s13059-016-0940-1},
40 | DOI={10.1186/s13059-016-0940-1},
41 | number={1},
42 | journal={Genome Biology},
43 | author={Teng, Mingxiang and Love, Michael I. and Davis, Carrie A. and Djebali, Sarah and Dobin, Alexander and Graveley, Brenton R. and Li, Sheng and Mason, Christopher E. and Olson, Sara and Pervouchine, Dmitri and et al.},
44 | year={2016}
45 | }
46 | @article{Zappia_2017,
47 | author = {Luke Zappia and Belinda Phipson and Alicia Oshlack},
48 | title = {Splatter: simulation of single-cell RNA sequencing data},
49 | journal = {Genome Biology},
50 | year = {2017},
51 | url = {http://dx.doi.org/10.1186/s13059-017-1305-0},
52 | doi = {10.1186/s13059-017-1305-0}
53 | }
54 | @article{Dunn_1961,
55 | title = {Multiple Comparisons Among Means},
56 | author = {Dunn, Olive Jean},
57 | journal = {Journal of the American Statistical Association},
58 | volume = {56},
59 | number = {293},
60 | pages = {52--64},
61 | year = {1961}
62 | }
63 | @article{Benjamini_1995,
64 | title={Controlling the false discovery rate: a practical and powerful approach to multiple testing},
65 | author = {Benjamini, Yoav and Hochberg, Yosef},
66 | journal = {Journal of the Royal Statistical Society. Series B (Methodological)},
67 | pages = {289--300},
68 | year = {1995}
69 | }
70 | @article{Storey_2002,
71 | title = {A direct approach to false discovery rates},
72 | author = {Storey, John D},
73 | journal = {Journal of the Royal Statistical Society: Series B (Statistical Methodology)},
74 | volume = {64},
75 | number = {3},
76 | pages = {479--498},
77 | year = {2002}
78 | }
79 |
--------------------------------------------------------------------------------
/tests/testthat/test_estimatePerformanceMetrics.R:
--------------------------------------------------------------------------------
1 | context("estimatePeformanceMetrics")
2 | test_that("test='estimatePerformanceMetrics' returns informative messages", {
3 | data( sb )
4 | expect_error( estimatePerformanceMetrics( 1:10 ) )
5 | expect_error( estimatePerformanceMetrics( sb ) )
6 | sb <- addPerformanceMetric( sb, evalMetric=c("rejections", "TPR", "TNR", "FDR", "FNR"), assay="qvalue" )
7 | expect_s4_class( estimatePerformanceMetrics( sb ), "DataFrame" )
8 | tidyRes1 <- estimatePerformanceMetrics( sb, tidy=TRUE )
9 | expect_s3_class( tidyRes1, "data.frame" )
10 | sb <- estimatePerformanceMetrics( sb, addColData=TRUE )
11 | tidyRes2 <- tidyUpMetrics( sb )
12 | expect_identical( tidyRes1, tidyRes2 )
13 | expect_message( estimatePerformanceMetrics(sb) )
14 | } )
15 |
16 | test_that("test='estimatePerformanceMetrics' works with non scalar outputs", {
17 | data( sb )
18 | sb2 <- sb
19 | sb2 <- addPerformanceMetric(
20 | object=sb2,
21 | assay="qvalue",
22 | evalMetric="TPR",
23 | evalFunction = function( query, truth, alpha=0.1 ){
24 | goodHits <- sum( (query < alpha) & truth == 1 )
25 | goodHits / sum(truth == 1)
26 | c(goodHits, goodHits)
27 | }
28 | )
29 | expect_s4_class( estimatePerformanceMetrics(sb2, alpha=0.1 ), "DataFrame" )
30 |
31 | data( sb )
32 | sb2 <- sb
33 | sb2 <- addPerformanceMetric(
34 | object=sb2,
35 | assay="qvalue",
36 | evalMetric="TPR",
37 | evalFunction = function( query, truth, alpha=0.1 ){
38 | goodHits <- sum( (query < alpha) & truth == 1 )
39 | goodHits / sum(truth == 1)
40 | c(goodHits, goodHits)
41 | }
42 | )
43 | expect_s4_class( estimatePerformanceMetrics(sb2, alpha=c(0.1, 0.2) ), "DataFrame" )
44 |
45 | data( sb )
46 | sb2 <- sb
47 | sb2 <- addPerformanceMetric(
48 | object=sb2,
49 | assay="qvalue",
50 | evalMetric="TPR",
51 | evalFunction = function( query, truth ){
52 | goodHits <- sum(truth == 1)
53 | c(goodHits, goodHits, goodHits)
54 | }
55 | )
56 | expect_s4_class( estimatePerformanceMetrics(sb2, alpha=c(0.1, 0.2)), "DataFrame" )
57 |
58 | data( sb )
59 | sb2 <- sb
60 | sb2 <- addPerformanceMetric(
61 | object=sb2,
62 | assay="qvalue",
63 | evalMetric="TPR",
64 | evalFunction = function( query, truth, alpha=0.1 ){
65 | goodHits <- sum( (query < alpha) & truth == 1 )
66 | goodHits / sum(truth == 1)
67 | }
68 | )
69 | expect_s4_class( estimatePerformanceMetrics(sb2, alpha=c(0.1, 0.2)), "DataFrame" )
70 |
71 | data( sb )
72 | sb2 <- sb
73 | sb2 <- addPerformanceMetric(
74 | object=sb2,
75 | assay="qvalue",
76 | evalMetric="TPR",
77 | evalFunction = function( query, truth, alpha=0.1 ){
78 | goodHits <- sum( (query < alpha) & truth == 1 )
79 | goodHits / sum(truth == 1)
80 | c(SummarizedExperiment(), SummarizedExperiment())
81 | }
82 | )
83 | expect_s4_class( estimatePerformanceMetrics(sb2, alpha=c(0.1, 0.2)), "DataFrame" )
84 | } )
85 |
--------------------------------------------------------------------------------
/man/SummarizedBenchmark.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/SummarizedBenckmark-constructor.R
3 | \name{SummarizedBenchmark}
4 | \alias{SummarizedBenchmark}
5 | \title{Create a new SummarizedBenchmark object}
6 | \usage{
7 | SummarizedBenchmark(assays, colData, ftData = NULL, groundTruth = NULL,
8 | performanceMetrics = NULL, BenchDesign = NULL, ...)
9 | }
10 | \arguments{
11 | \item{assays}{A list containing outputs of the methods to be
12 | benchmark. Each element of the list must contain a matrix or
13 | data.frame of n x m, n being the number of features tested
14 | (e.g. genes) and m being the number of methods in the benchmark.
15 | Each element of the list must contain a single assay
16 | (the outputs of the methods). For example,
17 | for a benchmark of differential expression methods, one assay could contain
18 | the q-values from the different methods and another assay could be the
19 | estimated log fold changes.}
20 |
21 | \item{colData}{A \code{\link{DataFrame}} describing the annotation of the
22 | methods. These could include version of the software or the parameters
23 | used to run them.}
24 |
25 | \item{ftData}{A \code{\link{DataFrame}} object describing the rows. This parameter
26 | is equivalent to the parameter rowData of a SummarizedExperiment.}
27 |
28 | \item{groundTruth}{If present, a \code{\link{DataFrame}} containing the ground truths.
29 | If provided, the number of columns must be the same as the number of assays
30 | (NA's are accepted).
31 | The names of the columns should have the same names as the assays.}
32 |
33 | \item{performanceMetrics}{A \code{\link{SimpleList}} of the same
34 | length as the number of assays. Each element of the list must be a list
35 | of functions. Each function must contain the parameters 'query' and
36 | 'truth'.}
37 |
38 | \item{BenchDesign}{A \code{\link{BenchDesign}} containing the code used
39 | to construct the object. (default = NULL)}
40 |
41 | \item{...}{Additional parameters passed to \code{\link{SummarizedExperiment}}.}
42 | }
43 | \value{
44 | A \code{\link{SummarizedBenchmark}} object.
45 | }
46 | \description{
47 | Function to construct \code{SummarizedBenchmark} objects.
48 | }
49 | \examples{
50 |
51 | ## loading the example data from iCOBRA
52 | library(iCOBRA)
53 | data(cobradata_example)
54 |
55 | ## a bit of data wrangling and reformatting
56 | assays <- list(
57 | qvalue=cobradata_example@padj,
58 | logFC=cobradata_example@score )
59 | assays[["qvalue"]]$DESeq2 <- p.adjust(cobradata_example@pval$DESeq2, method="BH")
60 | groundTruth <- DataFrame( cobradata_example@truth[,c("status", "logFC")] )
61 | colnames(groundTruth) <- names( assays )
62 | colData <- DataFrame( method=colnames(assays[[1]]) )
63 | groundTruth <- groundTruth[rownames(assays[[1]]),]
64 |
65 | ## constructing a SummarizedBenchmark object
66 | sb <- SummarizedBenchmark(
67 | assays=assays, colData=colData,
68 | groundTruth=groundTruth )
69 | colData(sb)$label <- rownames(colData(sb))
70 |
71 | }
72 | \author{
73 | Alejandro Reyes
74 | }
75 |
--------------------------------------------------------------------------------
/man/expandMethod.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/expandMethod.R
3 | \name{expandMethod}
4 | \alias{expandMethod}
5 | \title{Expand method in BenchDesign object}
6 | \usage{
7 | expandMethod(bd, label, params, onlyone = NULL, .replace = FALSE,
8 | .overwrite = FALSE)
9 | }
10 | \arguments{
11 | \item{bd}{\code{\link[=BenchDesign-class]{BenchDesign}} object.}
12 |
13 | \item{label}{Character name of method to be expanded.}
14 |
15 | \item{params}{Named list of quosure lists specifying the label of the
16 | new methods to be added to the \code{\link[=BenchDesign-class]{BenchDesign}},
17 | and the set of
18 | parameters to overwrite in the original method definition for
19 | each new method. Alternatively, if \code{onlyone} is non-\code{NULL}, a single quosure
20 | list with \code{name = value} pairs specifying the label of the new methods and
21 | the values to use for overwriting the parameter specified in \code{onlyone}.}
22 |
23 | \item{onlyone}{Character name of a parameter to be modified. Only specify
24 | if just a single parameter should be replaced in the original
25 | method definition. Ignored if \code{NULL}. (default = \code{NULL})}
26 |
27 | \item{.replace}{Logical whether original \code{label} method should be removed.
28 | (default = \code{FALSE})}
29 |
30 | \item{.overwrite}{Logical whether to overwrite the existing list of
31 | parameters (\code{TRUE}) or to simply add the new parameters to the existing
32 | list (\code{FALSE}). (default = \code{FALSE})}
33 | }
34 | \value{
35 | Modified \code{\link[=BenchDesign-class]{BenchDesign}} object with new methods with
36 | specified parameters added.
37 | }
38 | \description{
39 | Takes a \code{\link[=BenchDesign-class]{BenchDesign}} object, the name of an
40 | existing method, and new parameter specifications,
41 | and returns a modified \code{\link[=BenchDesign-class]{BenchDesign}}
42 | object with new methods added. The named method is "expanded" to mutliple methods
43 | according to the specified set of parameters.
44 | }
45 | \examples{
46 | ## empty BenchDesign
47 | bench <- BenchDesign()
48 |
49 | ## add basic 'padjust' method
50 | bench <- addMethod(bench, label = "padjust",
51 | func = p.adjust,
52 | params = rlang::quos(p = pval, method = "none"))
53 |
54 | ## modify multiple parameters - params is a list of quosure lists
55 | newparams <- list(bonf = rlang::quos(p = round(pval, 5), method = "bonferonni"),
56 | bh = rlang::quos(p = round(pval, 3), method = "BH"))
57 | bench_exp <- expandMethod(bench, label = "padjust", params = newparams)
58 | BDMethodList(bench_exp)
59 |
60 | ## only modify a single parameter - params is a quosure list
61 | newparams <- rlang::quos(bonf = "bonferonni", BH = "BH")
62 | bench_exp <- expandMethod(bench, label = "padjust", onlyone = "method", params = newparams)
63 | BDMethodList(bench_exp)
64 |
65 | }
66 | \seealso{
67 | \code{\link{modifyMethod}}, \code{\link{addMethod}}, \code{\link{dropMethod}}
68 | }
69 | \author{
70 | Patrick Kimes
71 | }
72 |
--------------------------------------------------------------------------------
/man/BDMethod.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/AllGenerics.R, R/BDMethod-constructor.R,
3 | % R/BDMethodList-accessors.R, R/BenchDesign-accessors.R
4 | \docType{methods}
5 | \name{BDMethod}
6 | \alias{BDMethod}
7 | \alias{BDMethod,quosure-method}
8 | \alias{BDMethod,function-method}
9 | \alias{BDMethod,BDMethodList-method}
10 | \alias{BDMethod,BenchDesign-method}
11 | \title{Create a new BDMethod object}
12 | \usage{
13 | BDMethod(x, params = rlang::quos(), post = NULL, meta = NULL, ...)
14 |
15 | \S4method{BDMethod}{quosure}(x, params = rlang::quos(), post = NULL,
16 | meta = NULL, ...)
17 |
18 | \S4method{BDMethod}{`function`}(x, params = rlang::quos(), post = NULL,
19 | meta = NULL, ...)
20 |
21 | \S4method{BDMethod}{BDMethodList}(x, i = 1)
22 |
23 | \S4method{BDMethod}{BenchDesign}(x, i = 1)
24 | }
25 | \arguments{
26 | \item{x}{main method function or function quosure. Alternative, may be a
27 | \code{\link[=BDMethodList-class]{BDMethodList}} or
28 | \code{\link[=BenchDesign-class]{BenchDesign}} object from which
29 | the \code{\link[=BDMethod-class]{BDMethod}} should be
30 | extracted.}
31 |
32 | \item{params}{list of quosures specifying function parameters.
33 | (default = \code{rlang::quos()})}
34 |
35 | \item{post}{list of functions to be applied to the output of \code{x}.
36 | (default = NULL)}
37 |
38 | \item{meta}{list of metadata. (default = NULL)}
39 |
40 | \item{...}{other parameters.}
41 |
42 | \item{i}{integer index or character name of \code{\link[=BDMethod-class]{BDMethod}} in
43 | \code{\link[=BDMethodList-class]{BDMethodList}} or
44 | \code{\link[=BenchDesign-class]{BenchDesign}} object.}
45 | }
46 | \value{
47 | BDMethod object
48 | }
49 | \description{
50 | Initializes a new BenchDesign method object for benchmarking.
51 |
52 | New \code{\link[=BDMethod-class]{BDMethod}} objects are typically not directly constructed as they
53 | have limited use outside of \code{\link[=BenchDesign-class]{BenchDesign}} objects. Instead,
54 | methods in a \code{\link[=BenchDesign-class]{BenchDesign}} object are more commonly created, modified or
55 | removed using
56 | function calls on the \code{\link[=BenchDesign-class]{BenchDesign}}, e.g. using \code{\link{addMethod}} to
57 | add a new method object.
58 |
59 | The constructor can also be used to access \code{\link[=BDMethod-class]{BDMethod}} objects stored in
60 | \code{\link[=BDMethodList-class]{BDMethodList}} and \code{\link[=BenchDesign-class]{BenchDesign}} objects.
61 | }
62 | \examples{
63 | ## create a simple BDMethod
64 | bdm1 <- BDMethod(x = base::mean)
65 |
66 | ## create a more complex BDMethod
67 | bdm2 <- BDMethod(x = function(x) { x^2 }, post = base::sqrt,
68 | meta = list(note = "simple example"))
69 |
70 | ## construct a BenchDesign with the BDMethod objects
71 | bd <- BenchDesign(method1 = bdm1, method2 = bdm2)
72 |
73 | ## access a BDMethod in the BenchDesign
74 | BDMethod(bd, "method1")
75 |
76 | }
77 | \seealso{
78 | \code{\link{BDMethod-class}}, \code{\link{BenchDesign}}, \code{\link{BDMethodList}}
79 | }
80 | \author{
81 | Patrick Kimes
82 | }
83 |
--------------------------------------------------------------------------------
/man/updateBench.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/updateBench.R
3 | \name{updateBench}
4 | \alias{updateBench}
5 | \title{Check/Update SummarizedBenchmark}
6 | \usage{
7 | updateBench(sb, bd = NULL, dryrun = TRUE, version = FALSE,
8 | keepAll = TRUE, reuseParams = TRUE, ...)
9 | }
10 | \arguments{
11 | \item{sb}{a \code{\link[=SummarizedBenchmark-class]{SummarizedBenchmark}} object}
12 |
13 | \item{bd}{a \code{\link[=BenchDesign-class]{BenchDesign}} object}
14 |
15 | \item{dryrun}{logical whether to just print description of what would
16 | be updated rather than actually running any methods. (default = TRUE)}
17 |
18 | \item{version}{logical whether to re-run methods with only package
19 | version differences. (default = FALSE)}
20 |
21 | \item{keepAll}{logical whether to keep methods run in original \code{\link[=SummarizedBenchmark-class]{SummarizedBenchmark}}
22 | but not in new \code{\link[=BenchDesign-class]{BenchDesign}}. Only used if \code{bd} is not NULL. (default = TRUE)}
23 |
24 | \item{reuseParams}{logical whether to reuse parameters from \code{buildBench} call
25 | used to create \code{\link[=SummarizedBenchmark-class]{SummarizedBenchmark}} object (if available). Directly
26 | specified \code{\link{buildBench}} parameters still take precedence. (default = TRUE)}
27 |
28 | \item{...}{optional parameters to pass to \code{\link{buildBench}}.}
29 | }
30 | \value{
31 | SumamrizedBenchmark object.
32 | }
33 | \description{
34 | Function to update or check status of \code{\link[=SummarizedBenchmark-class]{SummarizedBenchmark}}
35 | results.
36 |
37 | If only a \code{\link[=SummarizedBenchmark-class]{SummarizedBenchmark}} object is specified,
38 | the function will check whether `func`, `param`, `meta`, `post` or the `pkg_vers` of the
39 | methods in the \code{\link[=BenchDesign-class]{BenchDesign}} stored with the
40 | \code{\link[=SummarizedBenchmark-class]{SummarizedBenchmark}} do not match values stored in the
41 | \code{colData}. By default, no methods will be executed to update results. To actually execute updates,
42 | set \code{dryrun = FALSE}.
43 |
44 | If a \code{\link[=BenchDesign-class]{BenchDesign}} object is specified in addition to a
45 | \code{\link[=SummarizedBenchmark-class]{SummarizedBenchmark}} object, the function will check which
46 | methods in the new \code{\link[=BenchDesign-class]{BenchDesign}} need to be executed to update the
47 | \code{\link[=SummarizedBenchmark-class]{SummarizedBenchmark}} results. Again, by default, no methods
48 | will be executed unless \code{dryrun = FLASE} is specified.
49 |
50 | Unless \code{reuseParams = FALSE} is specified, the parameters of the last execution session stored
51 | in the the \code{colData} of the \code{\link[=SummarizedBenchmark-class]{SummarizedBenchmark}} object
52 | will be used.
53 | }
54 | \examples{
55 | ## load example SummarizedBenchmark object
56 | data(allSB)
57 | sb <- allSB[[1]]
58 |
59 | ## check if results are out of date
60 | updateBench(sb)
61 |
62 | ## modify BenchDesign
63 | bd <- BenchDesign(sb)
64 | bd <- dropMethod(bd, "kallisto-default")
65 |
66 | ## check if results need to be updated with new BenchDesign
67 | updateBench(sb, bd)
68 |
69 | }
70 | \seealso{
71 | \code{\link{buildBench}}
72 | }
73 | \author{
74 | Patrick Kimes
75 | }
76 |
--------------------------------------------------------------------------------
/man/estimateMetrics.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/PerformanceMetrics.R
3 | \name{estimateMetricsForAssay}
4 | \alias{estimateMetricsForAssay}
5 | \alias{estimatePerformanceMetrics}
6 | \title{Estimate performance metrics in SummarizedBenchmark object}
7 | \usage{
8 | estimateMetricsForAssay(object, assay, evalMetric = NULL,
9 | addColData = FALSE, evalFunction = NULL, tidy = FALSE, ...)
10 |
11 | estimatePerformanceMetrics(object, addColData = FALSE, tidy = FALSE,
12 | rerun = TRUE, ...)
13 | }
14 | \arguments{
15 | \item{object}{A \code{\link[=SummarizedBenchmark-class]{SummarizedBenchmark}} object.}
16 |
17 | \item{assay}{A string with an assay name. Indicates the assay that should be
18 | given as input to this performance metric.}
19 |
20 | \item{evalMetric}{A string with the name of the evaluation metric.}
21 |
22 | \item{addColData}{Logical (default: FALSE). If TRUE, the results are added to the
23 | \code{\link{colData}} slot of the \code{\link{SummarizedExperiment}} object and
24 | the object is returned. If FALSE, only a \code{\link{DataFrame}} with the results
25 | is returned.}
26 |
27 | \item{evalFunction}{A function that calculates a performance metric. It should
28 | contain at least two arguments, query and truth, where query is the output vector
29 | of a method and truth is the vector of ground true values. If additional parameters
30 | are specified, they must contain default values. If this parameter is passed,
31 | the metrics in the object are ignored and only this evaluation metric
32 | is estimated.}
33 |
34 | \item{tidy}{Logical (default: FALSE). If TRUE, a long formated \code{\link{data.frame}}
35 | is returned.}
36 |
37 | \item{...}{Additional parameters passed to the performance functions.}
38 |
39 | \item{rerun}{Logical (default: TRUE). By default, all performance metrics are recalculated
40 | everytime that \code{\link{estimatePerformanceMetrics}} is called. If FALSE, performance metrics
41 | will only be calculated for newly added methods or modified methods.}
42 | }
43 | \value{
44 | Either a \code{\link{SummarizedBenchmark}} object, a \code{\link{DataFrame}} or
45 | a \code{\link{data.frame}}.
46 | }
47 | \description{
48 | These functions estimate the performance metrics, either passed as arguments or
49 | added previously with the \code{\link{addPerformanceMetric}} function. The function
50 | will estimate the performance metric for each method.
51 | }
52 | \section{Functions}{
53 | \itemize{
54 | \item \code{estimateMetricsForAssay}: Estimate performance metrics for a given assay
55 |
56 | \item \code{estimatePerformanceMetrics}: Estimate performance metrics for all assays
57 | }}
58 |
59 | \examples{
60 |
61 | data( sb )
62 | sb <- addPerformanceMetric(
63 | object=sb,
64 | assay="qvalue",
65 | evalMetric="TPR",
66 | evalFunction = function( query, truth, alpha=0.1 ){
67 | goodHits <- sum( (query < alpha) & truth == 1 )
68 | goodHits / sum(truth == 1)
69 | }
70 | )
71 |
72 | qvalueMetrics <- estimateMetricsForAssay( sb, assay="qvalue" )
73 | allMetrics <- estimatePerformanceMetrics( sb )
74 | allMetricsTidy <- estimatePerformanceMetrics( sb, tidy=TRUE )
75 |
76 | }
77 | \seealso{
78 | \code{\link{availableMetrics}}, \code{\link{performanceMetrics}}
79 | }
80 | \author{
81 | Alejandro Reyes
82 | }
83 |
--------------------------------------------------------------------------------
/R/PlottingFunctions.R:
--------------------------------------------------------------------------------
1 | #' @title Plot UpSetR for SummarizedBenchmark object
2 | #' @aliases plotMethodsOverlap
3 | #' @description
4 | #' This function looks for an assay, called by default 'qvalue', and given an alpha threshold,
5 | #' it binarizes the assay matrix depending on whether its values are below the alpha
6 | #' threshold. Then it uses the function \code{\link{upset}} to plot the overlaps.
7 | #' The plot is only generated if at least 2 methods have observations that pass
8 | #' the alpha threshold.
9 | #'
10 | #' @param object A \code{\link{SummarizedBenchmark}} object.
11 | #' @param assay The name of an assay.
12 | #' @param alpha An alpha value.
13 | #' @param ... Further arguments passed to \code{\link{upset}}
14 | #'
15 | #' @examples
16 | #' data(sb)
17 | #' \dontrun{
18 | #' plotMethodsOverlap(sb)
19 | #' }
20 | #'
21 | #' @return An upseR plot.
22 | #'
23 | #' @seealso \code{\link{plotROC}}, \code{\link{estimatePerformanceMetrics}}
24 | #' @author Alejandro Reyes
25 | #' @export
26 | #' @importFrom UpSetR upset
27 | #'
28 | plotMethodsOverlap <- function( object, assay="qvalue", alpha=0.1, ... ){
29 | stopifnot( is( object, "SummarizedExperiment" ) )
30 | stopifnot( is( alpha, "numeric") )
31 | stopifnot( alpha >=0 & alpha <= 1 )
32 | if( !( assay %in% assayNames( object ) ) ){
33 | stop(sprintf("Assay name '%s' not found", assay) )
34 | }
35 | uobj <- as.data.frame( 1*( assays( object )[[assay]] < alpha) )
36 | uobj[is.na( uobj )] <- 0
37 | if ( sum(colSums(uobj) > 0) < 2 ){
38 | stop("To plot overlaps, at least 2 methods must have observations that pass the alpha threshold.")
39 | }
40 | upset(uobj , ... )
41 | }
42 |
43 | #' @title Plot ROC curve for SummarizedBenchmark object
44 | #' @aliases plotROC
45 | #' @description
46 | #' This function inputs a \code{\link{SummarizedBenchmark}} object, looks
47 | #' for an assay called 'qvalue' and plots receiver operating characteristic curves
48 | #' for each of the methods to benchmark.
49 | #'
50 | #' @param object A \code{\link{SummarizedBenchmark}} object.
51 | #' @param assay An assay name.
52 | #'
53 | #' @examples
54 | #' data(sb)
55 | #' \dontrun{
56 | #' plotROC(sb)
57 | #' }
58 | #'
59 | #' @return A ggplot object.
60 | #'
61 | #' @seealso \code{\link{plotMethodsOverlap}}, \code{\link{estimatePerformanceMetrics}}
62 | #' @author Alejandro Reyes
63 | #' @export
64 | #' @importFrom ggplot2 ggplot geom_line aes geom_abline xlim ylim
65 | #'
66 | plotROC <- function( object, assay="qvalue" ){
67 | stopifnot( is( object, "SummarizedBenchmark" ))
68 | if( !any( assayNames( object ) %in% assay ) ){
69 | stop(sprintf("Assay '%s' not found.\n", assay) )
70 | }
71 | if( !assayHasTruths( object, assay ) ){
72 | stop(sprintf("Ground truths not found for assay '%s'", assay))
73 | }
74 | metricsDf <- do.call( rbind, lapply( colnames(object), function(method){
75 | or <- order( assays(object)[[assay]][,method] )
76 | TPR <- cumsum( groundTruths( object )[[assay]][or] ) / sum( groundTruths(object)[[assay]] )
77 | FDR <- cumsum( abs(groundTruths( object )[[assay]][or] - 1) ) / seq_along(or)
78 | data.frame( method=method, TPR=TPR, FDR=FDR )
79 | } ) )
80 | pl <- ggplot( metricsDf, aes(FDR, TPR, col=method) ) +
81 | geom_line(size=1.2, alpha=.6) + xlim(0, 1) + ylim(0, 1) + geom_abline(linetype="dashed")
82 | pl
83 | }
84 |
--------------------------------------------------------------------------------
/R/BDMethod-constructor.R:
--------------------------------------------------------------------------------
1 | #' Create a new BDMethod object
2 | #'
3 | #' @description
4 | #' Initializes a new BenchDesign method object for benchmarking.
5 | #'
6 | #' New \code{\link[=BDMethod-class]{BDMethod}} objects are typically not directly constructed as they
7 | #' have limited use outside of \code{\link[=BenchDesign-class]{BenchDesign}} objects. Instead,
8 | #' methods in a \code{\link[=BenchDesign-class]{BenchDesign}} object are more commonly created, modified or
9 | #' removed using
10 | #' function calls on the \code{\link[=BenchDesign-class]{BenchDesign}}, e.g. using \code{\link{addMethod}} to
11 | #' add a new method object.
12 | #'
13 | #' The constructor can also be used to access \code{\link[=BDMethod-class]{BDMethod}} objects stored in
14 | #' \code{\link[=BDMethodList-class]{BDMethodList}} and \code{\link[=BenchDesign-class]{BenchDesign}} objects.
15 | #'
16 | #' @param x main method function or function quosure. Alternative, may be a
17 | #' \code{\link[=BDMethodList-class]{BDMethodList}} or
18 | #' \code{\link[=BenchDesign-class]{BenchDesign}} object from which
19 | #' the \code{\link[=BDMethod-class]{BDMethod}} should be
20 | #' extracted.
21 | #' @param params list of quosures specifying function parameters.
22 | #' (default = \code{rlang::quos()})
23 | #' @param post list of functions to be applied to the output of \code{x}.
24 | #' (default = NULL)
25 | #' @param meta list of metadata. (default = NULL)
26 | #' @param i integer index or character name of \code{\link[=BDMethod-class]{BDMethod}} in
27 | #' \code{\link[=BDMethodList-class]{BDMethodList}} or
28 | #' \code{\link[=BenchDesign-class]{BenchDesign}} object.
29 | #' @param ... other parameters.
30 | #'
31 | #' @return
32 | #' BDMethod object
33 | #'
34 | #' @examples
35 | #' ## create a simple BDMethod
36 | #' bdm1 <- BDMethod(x = base::mean)
37 | #'
38 | #' ## create a more complex BDMethod
39 | #' bdm2 <- BDMethod(x = function(x) { x^2 }, post = base::sqrt,
40 | #' meta = list(note = "simple example"))
41 | #'
42 | #' ## construct a BenchDesign with the BDMethod objects
43 | #' bd <- BenchDesign(method1 = bdm1, method2 = bdm2)
44 | #'
45 | #' ## access a BDMethod in the BenchDesign
46 | #' BDMethod(bd, "method1")
47 | #'
48 | #' @seealso \code{\link{BDMethod-class}}, \code{\link{BenchDesign}}, \code{\link{BDMethodList}}
49 | #' @name BDMethod
50 | #' @importFrom rlang get_expr eval_tidy quos !! !!!
51 | #' @importFrom methods .valueClassTest
52 | #' @export
53 | #' @author Patrick Kimes
54 | NULL
55 |
56 | .BDMethod.quo <- function(x, params, post, meta, ...) {
57 | fc <- rlang::get_expr(x)
58 | f <- rlang::eval_tidy(x)
59 | if (is(post, "function")) {
60 | post <- list("default" = post)
61 | }
62 | new("BDMethod", f = f, fc = fc, params = params, post = post, meta = meta)
63 | }
64 |
65 | .BDMethod.fun <- function(x, params, post, meta, ...) {
66 | fc <- substitute(x)
67 | if (is(post, "function")) {
68 | post <- list("default" = post)
69 | }
70 | new("BDMethod", f = x, fc = fc, params = params, post = post, meta = meta)
71 | }
72 |
73 |
74 | #' @rdname BDMethod
75 | #' @export
76 | setMethod("BDMethod", signature(x = "quosure"), .BDMethod.quo)
77 |
78 | #' @rdname BDMethod
79 | #' @export
80 | setMethod("BDMethod", signature(x = "function"), .BDMethod.fun)
81 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | # SummarizedBenchmark
3 |
4 | [](http://bioconductor.org/checkResults/devel/bioc-LATEST/SummarizedBenchmark/)
6 | [](http://bioconductor.org/packages/devel/SummarizedBenchmark/)
8 | [](http://bioconductor.org/packages/devel/SummarizedBenchmark/)
11 | [](http://bioconductor.org/checkResults/devel/bioc-LATEST/SummarizedBenchmark/)
14 |
15 | SummarizedBenchmark defines a flexible framework for benchmarking
16 | computational methods in R. Classes and functions are provided for
17 | defining, executing and evaluating benchmark experiments. The package
18 | builds on the
19 | [SummarizedExperiment](http://bioconductor.org/packages/SummarizedExperiment/)
20 | class to keep results organized, with outputs tied directly with
21 | important method metadata. This site is for the development version of
22 | the package. Documentation and examples for the current Bioconductor
23 | release version of the package can be found at the official [release
24 | page](http://bioconductor.org/packages/SummarizedBenchmark/).
25 |
26 | If you have any suggestions on how we can improve the package, [let us
27 | know](https://github.com/areyesq89/SummarizedBenchmark/issues)\!
28 |
29 | ## Installation
30 |
31 | ``` r
32 | # Install development version from Bioconductor
33 | BiocManager::install("SummarizedBenchmark", version = "devel")
34 |
35 | # Install release version from Bioconductor
36 | BiocManager::install("SummarizedBenchmark")
37 | ```
38 |
39 | ## Usage
40 |
41 | SummarizedBenchmark can be used to apply several computational methods
42 | in R on a data set and to store and compare the subsequent results. This
43 | can include just a single method with different parameter settings, or
44 | methods written outside of R, but called using a system call from an R
45 | session. Generally, the package should be useful if you are trying to
46 | decide between several competing methods and would like to compare how
47 | they perform on one or more data sets.
48 |
49 | ## Related Work
50 |
51 | While we hope users find SummarizedBenchmark useful, it might not be
52 | suitable for all problems or data sets. Other frameworks for
53 | benchmarking methods include
54 | [iCOBRA](http://bioconductor.org/packages/iCOBRA/) (a package for
55 | comparing results of “binary classification and ranking methods” with a
56 | Shiny web application for interactive analyses),
57 | [rnaseqcomp](http://bioconductor.org/packages/rnaseqcomp) (a package for
58 | comparing results of RNA-seq quantification pipelines), and
59 | [dsc](https://github.com/stephenslab/dsc) (a framework for “managing
60 | computational benchmarking experiments that compare several competing
61 | methods” written in Python but capable of running methods implemented in
62 | both Python and R).
63 |
--------------------------------------------------------------------------------
/README.Rmd:
--------------------------------------------------------------------------------
1 | ---
2 | output: github_document
3 | ---
4 |
5 | # SummarizedBenchmark
6 |
7 | [](http://bioconductor.org/checkResults/devel/bioc-LATEST/SummarizedBenchmark/)
8 | [](http://bioconductor.org/packages/devel/SummarizedBenchmark/)
9 | [](http://bioconductor.org/packages/devel/SummarizedBenchmark/)
10 | [](http://bioconductor.org/checkResults/devel/bioc-LATEST/SummarizedBenchmark/)
11 |
12 | SummarizedBenchmark defines a flexible framework for benchmarking computational methods in R.
13 | Classes and functions are provided for defining, executing and evaluating
14 | benchmark experiments. The package builds on the [SummarizedExperiment](http://bioconductor.org/packages/SummarizedExperiment/)
15 | class to keep results organized, with outputs tied directly with important method metadata.
16 | This site is for the development version of the package.
17 | Documentation and examples for the current Bioconductor release version of the package
18 | can be found at the official [release page](http://bioconductor.org/packages/SummarizedBenchmark/).
19 |
20 | If you have any suggestions on how we can improve the package,
21 | [let us know](https://github.com/areyesq89/SummarizedBenchmark/issues)!
22 |
23 | ## Installation
24 |
25 | ```{r installation, eval = FALSE}
26 | # Install development version from Bioconductor
27 | BiocManager::install("SummarizedBenchmark", version = "devel")
28 |
29 | # Install release version from Bioconductor
30 | BiocManager::install("SummarizedBenchmark")
31 | ```
32 |
33 | ## Usage
34 |
35 | SummarizedBenchmark can be used to apply several computational methods
36 | in R on a data set and to store and compare the subsequent results. This
37 | can include just a single method with different parameter settings, or
38 | methods written outside of R, but called using a system call from an
39 | R session. Generally, the package should be useful if you are trying to
40 | decide between several competing methods and would like to compare how
41 | they perform on one or more data sets.
42 |
43 | ## Related Work
44 |
45 | While we hope users find SummarizedBenchmark useful, it might not be
46 | suitable for all problems or data sets. Other frameworks for benchmarking
47 | methods include [iCOBRA](http://bioconductor.org/packages/iCOBRA/)
48 | (a package for comparing results of "binary classification and ranking methods"
49 | with a Shiny web application for interactive analyses),
50 | [rnaseqcomp](http://bioconductor.org/packages/rnaseqcomp) (a package for
51 | comparing results of RNA-seq quantification pipelines), and
52 | [dsc](https://github.com/stephenslab/dsc) (a framework for "managing
53 | computational benchmarking experiments that compare several competing methods"
54 | written in Python but capable of running methods implemented in both Python and R).
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/tests/testthat/test-updateBench.R:
--------------------------------------------------------------------------------
1 | library(SummarizedBenchmark)
2 | context("updateBench")
3 |
4 | ## sample t-test data set
5 | data(tdat)
6 |
7 | test_that("basic updateBench call works", {
8 | ## basic BenchDesign
9 | bd <- BenchDesign(data = tdat)
10 | BDMethod(bd, "bonf") <- BDMethod(x = p.adjust,
11 | params = rlang::quos(p = pval, method = "bonferroni"),
12 | meta = list(purpose = "for testing"))
13 | BDMethod(bd, "bh") <- BDMethod(x = p.adjust,
14 | params = rlang::quos(p = pval, method = "BH"),
15 | meta = list(purpose = "for comparing"))
16 | sb <- buildBench(bd)
17 |
18 | ## basic call w/ just SummarizedBenchmark
19 | bdcomp <- compareBenchDesigns(sb)
20 | expect_output(bdupdate <- updateBench(sb), "Update SummarizedBenchmark \\(dryrun\\)")
21 | expect_equal(bdcomp$methods$res, bdupdate$methods$res)
22 | expect_equal(dplyr::select(bdcomp$methods[[2]], -post, -f),
23 | dplyr::select(bdupdate$methods[[2]], -post, -f))
24 | expect_equal(dplyr::select(bdcomp$methods[[3]], -post, -f),
25 | dplyr::select(bdupdate$methods[[3]], -post, -f))
26 | expect_equal(bdcomp$data, bdupdate$data)
27 | expect_equal(bdcomp$methods$res$overlap, rep("Both", 2))
28 | expect_true(all(unlist(dplyr::select_if(bdcomp$methods$res, is.logical))))
29 |
30 | expect_error(sb2 <- updateBench(sb, dryrun = FALSE), "MD5 hash")
31 | expect_silent(sb2 <- updateBench(sb, dryrun = FALSE, data = tdat))
32 | expect_identical(sb, sb2)
33 |
34 | ## basic call w/ new BenchDesign
35 | bd2 <- bd
36 | BDMethod(bd2, "holm") <- BDMethod(x = p.adjust, params = rlang::quos(p = pval, method = "holm"))
37 | BDMethod(bd2, "bh") <- NULL
38 |
39 | expect_silent(bdcomp <- compareBenchDesigns(sb, bd2))
40 | expect_output(bdupdate <- updateBench(sb, bd2), "Update SummarizedBenchmark \\(dryrun\\)")
41 | expect_output(updateBench(sb, bd2, keepAll = FALSE), "Drop")
42 | expect_equal(bdcomp$methods$res, bdupdate$methods$res)
43 | expect_equal(dplyr::filter(bdupdate$methods$res, label == "holm")$overlap, "yOnly")
44 | expect_equal(dplyr::filter(bdupdate$methods$res, label == "bh")$overlap, "xOnly")
45 | expect_equal(dplyr::filter(bdupdate$methods$res, label == "bonf")$overlap, "Both")
46 | expect_true(all(is.na(unlist(dplyr::select_if(dplyr::filter(bdcomp$methods$res, label == "holm"), is.logical)))))
47 |
48 | expect_silent(sb2 <- updateBench(sb, bd2, dryrun = FALSE, data = tdat))
49 | expect_silent(sb2drop <- updateBench(sb, bd2, dryrun = FALSE, keepAll = FALSE, data = tdat))
50 |
51 | expect_equal(ncol(sb2), 3L)
52 | expect_equal(ncol(sb2drop), 2L)
53 | expect_equal(sort(colnames(sb2)), c("bh", "bonf", "holm"))
54 | expect_equal(sort(colnames(sb2drop)), c("bonf", "holm"))
55 |
56 | expect_length(BDMethodList(sb2), 3L)
57 | expect_length(BDMethodList(sb2drop), 2L)
58 |
59 | expect_equal(length(metadata(sb2)$sessions), 2L)
60 | expect_equal(length(metadata(sb2drop)$sessions), 2L)
61 |
62 | expect_equal(sort(metadata(sb2)$sessions[[1]]$methods), c("bh", "bonf"))
63 | expect_equal(metadata(sb2)$sessions[[2]]$methods, "holm")
64 |
65 | expect_equal(metadata(sb2drop)$sessions[[1]]$methods, "bonf")
66 | expect_equal(metadata(sb2drop)$sessions[[2]]$methods, "holm")
67 | expect_equal(names(metadata(sb2drop)$sessions[[1]]$results), "bonf")
68 | expect_equal(names(metadata(sb2drop)$sessions[[2]]$results), "holm")
69 | })
70 |
--------------------------------------------------------------------------------
/R/BDData-constructor.R:
--------------------------------------------------------------------------------
1 | #' Create a new BDData object
2 | #'
3 | #' @description
4 | #' Initializes a new BDData object of benchmarking data.
5 | #'
6 | #' Data sets are stored as BDData objects within BenchDesign
7 | #' objects as well as SummarizedBenchmark objects. However, because
8 | #' data is directly specified to the BenchDesign constructor, there
9 | #' is usually no need to call the BDData constructor to create completely
10 | #' new data objects.
11 | #'
12 | #' The BDData constructor is most useful for extracting the data sets
13 | #' contained in BenchDesign objects as well as SummarizedBenchmark objects.
14 | #' By default, the BDData object stored in SummarizedBenchmark objects will
15 | #' be MD5 hashes rather than the complete original data set.
16 | #' \code{\link{compareBDData}} can be used to compare various forms of
17 | #' BDData, as shown in the examples below.
18 | #'
19 | #' @param data a list object of data or MD5 hash string
20 | #'
21 | #' @return
22 | #' BDData object
23 | #'
24 | #' @examples
25 | #' ## construct from data.frame
26 | #' datadf <- data.frame(x = 1:5, y = runif(5))
27 | #' bdd_df <- BDData(datadf)
28 | #' bdd_df
29 | #'
30 | #' ## construct from MD5 hash of data.frame
31 | #' bdd_md5 <- BDData(digest::digest(datadf))
32 | #' bdd_md5
33 | #'
34 | #' ## compare two BDData objects
35 | #' compareBDData(bdd_df, bdd_md5)
36 | #'
37 | #' ## note that the data is the same, i.e. the MD5 hashes match, but the
38 | #' ## data types ("data" vs. "md5has") are different
39 | #'
40 | #' @seealso \code{\link{BDData-class}}, \code{\link{BenchDesign}}
41 | #' @name BDData
42 | #' @importFrom methods .valueClassTest
43 | #' @export
44 | #' @author Patrick Kimes
45 | NULL
46 |
47 | .BDData.default <- function(data) {
48 | if (is(data, "character")) {
49 | new("BDData", data = data, type = "md5hash")
50 | } else {
51 | new("BDData", data = data, type = "data")
52 | }
53 | }
54 |
55 | .BDData.bd <- function(data) {
56 | data@data
57 | }
58 |
59 | .BDData.sb <- function(data) {
60 | BDData(BenchDesign(data))
61 | }
62 |
63 | #' @rdname BDData
64 | setMethod("BDData", signature(data = "ANY"), .BDData.default)
65 |
66 | #' @rdname BDData
67 | setMethod("BDData", signature(data = "BenchDesign"), .BDData.bd)
68 |
69 | #' @rdname BDData
70 | setMethod("BDData", signature(data = "SummarizedBenchmark"), .BDData.sb)
71 |
72 | #' @rdname BDData
73 | setMethod("BDData", signature(data = "BDData"), function(data) { data })
74 |
75 |
76 | #' Hash data in BDData object
77 | #'
78 | #' @description
79 | #' Repliaces data stored in a \code{\link[=BDData-class]{BDData}} object
80 | #' with the MD5 hash of the data. If the data was already a MD5 hash, the
81 | #' original object is returned unchanged. The method can be called directly
82 | #' on \code{\link[=BenchDesign-class]{BenchDesign}} objects to hash the
83 | #' underlying data as well.
84 | #'
85 | #' @param object a \code{BDData} or \code{BenchDesign} object
86 | #'
87 | #' @return
88 | #' an object of the same class as \code{object} with data
89 | #' converted to a MD5 hash.
90 | #'
91 | #' @name hashBDData
92 | #' @importFrom digest digest
93 | #' @export
94 | #' @author Patrick Kimes
95 | NULL
96 |
97 | .hashBDData <- function(object) {
98 | if (object@type == "md5hash")
99 | return(object)
100 | BDData(digest::digest(object@data, algo = "md5"))
101 | }
102 |
103 | .hashBDData.bd <- function(object) {
104 | BDData(object) <- hashBDData(BDData(object))
105 | object
106 | }
107 |
108 | #' @rdname hashBDData
109 | setMethod("hashBDData", signature(object = "BDData"), .hashBDData)
110 |
111 | #' @rdname hashBDData
112 | setMethod("hashBDData", signature(object = "BenchDesign"), .hashBDData.bd)
113 |
114 |
115 |
--------------------------------------------------------------------------------
/NAMESPACE:
--------------------------------------------------------------------------------
1 | # Generated by roxygen2: do not edit by hand
2 |
3 | S3method(addMethod,BenchDesign)
4 | S3method(dropMethod,BenchDesign)
5 | S3method(expandMethod,BenchDesign)
6 | S3method(modifyMethod,BenchDesign)
7 | export("BDData<-")
8 | export("BDMethod<-")
9 | export("BDMethodList<-")
10 | export("groundTruths<-")
11 | export("performanceMetrics<-")
12 | export(BDData)
13 | export(BDMethod)
14 | export(BDMethodList)
15 | export(BenchDesign)
16 | export(SummarizedBenchmark)
17 | export(addMethod)
18 | export(addPerformanceMetric)
19 | export(availableMetrics)
20 | export(buildBench)
21 | export(compareBDData)
22 | export(compareBDMethod)
23 | export(compareBenchDesigns)
24 | export(dropMethod)
25 | export(estimateMetricsForAssay)
26 | export(estimatePerformanceMetrics)
27 | export(expandMethod)
28 | export(groundTruths)
29 | export(hashBDData)
30 | export(modifyMethod)
31 | export(performanceMetrics)
32 | export(plotMethodsOverlap)
33 | export(plotROC)
34 | export(printMethod)
35 | export(printMethods)
36 | export(tidyBDMethod)
37 | export(tidyUpMetrics)
38 | export(updateBench)
39 | exportClasses(BDData)
40 | exportClasses(BDMethod)
41 | exportClasses(BDMethodList)
42 | exportClasses(BenchDesign)
43 | exportClasses(SummarizedBenchmark)
44 | exportMethods("BDData<-")
45 | exportMethods("BDMethod")
46 | exportMethods("BDMethod<-")
47 | exportMethods("BDMethodList")
48 | exportMethods("BDMethodList<-")
49 | exportMethods("BenchDesign")
50 | exportMethods("assayNames<-")
51 | exportMethods("groundTruths")
52 | exportMethods("groundTruths<-")
53 | exportMethods("mcols<-")
54 | exportMethods("performanceMetrics")
55 | exportMethods("performanceMetrics<-")
56 | exportMethods(BDMethod)
57 | exportMethods(compareBenchDesigns)
58 | exportMethods(tidyBDMethod)
59 | import(BiocParallel)
60 | import(SummarizedExperiment)
61 | import(dplyr)
62 | importClassesFrom(S4Vectors,SimpleList)
63 | importFrom(BiocGenerics,sd)
64 | importFrom(S4Vectors,DataFrame)
65 | importFrom(S4Vectors,SimpleList)
66 | importFrom(S4Vectors,cor)
67 | importFrom(S4Vectors,elementMetadata)
68 | importFrom(S4Vectors,metadata)
69 | importFrom(S4Vectors,params)
70 | importFrom(SummarizedExperiment,cbind)
71 | importFrom(UpSetR,upset)
72 | importFrom(crayon,bold)
73 | importFrom(crayon,green)
74 | importFrom(crayon,red)
75 | importFrom(crayon,yellow)
76 | importFrom(digest,digest)
77 | importFrom(dplyr,as_tibble)
78 | importFrom(dplyr,left_join)
79 | importFrom(ggplot2,aes)
80 | importFrom(ggplot2,geom_abline)
81 | importFrom(ggplot2,geom_line)
82 | importFrom(ggplot2,ggplot)
83 | importFrom(ggplot2,xlim)
84 | importFrom(ggplot2,ylim)
85 | importFrom(mclust,adjustedRandIndex)
86 | importFrom(methods,.valueClassTest)
87 | importFrom(methods,as)
88 | importFrom(methods,formalArgs)
89 | importFrom(methods,is)
90 | importFrom(methods,new)
91 | importFrom(methods,slot)
92 | importFrom(methods,validObject)
93 | importFrom(rlang,"!!!")
94 | importFrom(rlang,"!!")
95 | importFrom(rlang,":=")
96 | importFrom(rlang,enquo)
97 | importFrom(rlang,eval_tidy)
98 | importFrom(rlang,flatten)
99 | importFrom(rlang,get_expr)
100 | importFrom(rlang,is_quosure)
101 | importFrom(rlang,is_quosures)
102 | importFrom(rlang,quo)
103 | importFrom(rlang,quo_text)
104 | importFrom(rlang,quos)
105 | importFrom(sessioninfo,session_info)
106 | importFrom(stringr,str_pad)
107 | importFrom(stringr,str_trunc)
108 | importFrom(tibble,is_tibble)
109 | importFrom(tidyr,gather)
110 | importFrom(tidyr,spread)
111 | importFrom(tidyr,unnest)
112 | importFrom(utils,head)
113 | importFrom(utils,packageName)
114 | importFrom(utils,packageVersion)
115 | importMethodsFrom(S4Vectors,"elementMetadata<-")
116 | importMethodsFrom(S4Vectors,"mcols<-")
117 | importMethodsFrom(S4Vectors,elementMetadata)
118 | importMethodsFrom(S4Vectors,mcols)
119 | importMethodsFrom(SummarizedExperiment,"assayNames<-")
120 | importMethodsFrom(SummarizedExperiment,assayNames)
121 |
--------------------------------------------------------------------------------
/docs/pkgdown.js:
--------------------------------------------------------------------------------
1 | /* http://gregfranko.com/blog/jquery-best-practices/ */
2 | (function($) {
3 | $(function() {
4 |
5 | $("#sidebar")
6 | .stick_in_parent({offset_top: 40})
7 | .on('sticky_kit:bottom', function(e) {
8 | $(this).parent().css('position', 'static');
9 | })
10 | .on('sticky_kit:unbottom', function(e) {
11 | $(this).parent().css('position', 'relative');
12 | });
13 |
14 | $('body').scrollspy({
15 | target: '#sidebar',
16 | offset: 60
17 | });
18 |
19 | $('[data-toggle="tooltip"]').tooltip();
20 |
21 | var cur_path = paths(location.pathname);
22 | var links = $("#navbar ul li a");
23 | var max_length = -1;
24 | var pos = -1;
25 | for (var i = 0; i < links.length; i++) {
26 | if (links[i].getAttribute("href") === "#")
27 | continue;
28 | // Ignore external links
29 | if (links[i].host !== location.host)
30 | continue;
31 |
32 | var nav_path = paths(links[i].pathname);
33 |
34 | var length = prefix_length(nav_path, cur_path);
35 | if (length > max_length) {
36 | max_length = length;
37 | pos = i;
38 | }
39 | }
40 |
41 | // Add class to parent
Method to set BDData slot in objects.
132 | 133 || x | 141 |BenchDesign object. |
142 |
|---|---|
| i | 145 |character name or integer index of a BDMethod object. 146 | Must be a character name for replacement operations.) |
147 |
| value | 150 |replacement object, either BDData, BDMethod, BDMethodList 151 | or NULL object. |
152 |
| ... | 155 |Futher arguments, 156 | perhaps used by methods |
157 |
modified BenchDesign object
163 | 164 | 165 |