diff --git a/.gitignore b/.gitignore index 3cfccf1..f2180c6 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,6 @@ *-Ex.R /*.Rcheck/ .Rproj.user/ -vignettes/*.html .httr-oauth /*_cache/ /cache/ @@ -28,4 +27,7 @@ revdep vignettes/*.html vignettes/*.R vignettes/*.log + !vignettes/precompiled_vignettes.R +!inst/exampleObj.RDS +!inst/miniObj.RDS diff --git a/DESCRIPTION b/DESCRIPTION index 2802f21..a0e126b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: DGEobj Type: Package Title: Differential Gene Expression (DGE) Analysis Results Data Object -Version: 1.1.1 +Version: 1.1.2 Description: Provides a flexible container to manage and annotate Differential Gene Expression (DGE) analysis results (Smythe et. al (2015) ). @@ -29,15 +29,15 @@ Imports: stringr, utils Suggests: + biomaRt, conflicted, dplyr, + edgeR, + GenomicRanges, glue, knitr, rmarkdown, - testthat, - biomaRt, - edgeR, - GenomicRanges + testthat biocViews: RoxygenNote: 7.1.2 VignetteBuilder: knitr diff --git a/NEWS.md b/NEWS.md index 7c5ce8c..b35e500 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,12 @@ --- +### v1.1.2 +* Made all Bioconductor packages optional (suggested) +* Added a new, minimal "mini" example object that has no internal Bioconductor-based features (ie normalization, analysis) to allow +for clean, simple examples that do not depend on suggested packages +* Testing updated so that when Bioconductor suggested packages are unavailable the tests will not be run + ### v1.1.1 * Updated tests and examples so that when suggested packages are unavailable the examples and/or tests dependent on them are not run diff --git a/R/addItem.R b/R/addItem.R index 1daa167..9ba672d 100644 --- a/R/addItem.R +++ b/R/addItem.R @@ -16,10 +16,10 @@ #' \dontrun{ #' myFunArgs <- match.call() # Capture calling function and arguments #' -#' myDGEobj <- addItem(myDGEobj, item = MyCounts, +#' myDGEobj <- addItem(myDGEobj, item = MyCounts, #' itemName = "counts", #' itemType = "counts", -#' funArgs = myFunArgs) +#' funArgs = myFunArgs) #' } #' #' @importFrom assertthat assert_that @@ -168,7 +168,9 @@ addItem <- function(dgeObj, #' #' @examples #' \dontrun{ -#' # Add normalize counts (DGEList) and log2CPM as additional "assay" items in the DGEobj +#' # NOTE: Requires the edgeR package +#' +#' # Add normalized counts and log2CPM as additional "assay" items in the DGEobj #' dgeObj <- readRDS(system.file("exampleObj.RDS", package = "DGEobj")) #' dgeList <- edgeR::calcNormFactors(edgeR::DGEList(dgeObj$counts), method="TMM") #' log2cpm <- edgeR::cpm(dgeList, log = TRUE) diff --git a/R/annotate.R b/R/annotate.R index 537f9a0..d55c69d 100644 --- a/R/annotate.R +++ b/R/annotate.R @@ -16,19 +16,21 @@ #' @return A DGEobj #' #' @examples -#' MyDgeObj <- system.file("exampleObj.RDS", package = "DGEobj") +#' MyDgeObj <- system.file("miniObj.RDS", package = "DGEobj") #' #' \dontrun{ #' #using a text file file of key=value pairs #' annotationFile <- "/location/to/myAnnotations.txt" #' MyDgeObj <- annotateDGEobj(MyDgeObj, annotationFile) -#'} +#' } +#' #' #using a named list of key/values #' annotations <- list(Title = "Rat Liver Slices from Bile Duct Ligation animals", #' Organism = "Rat", #' GeneModel = "Ensembl.R89") #' MyDgeObj <- annotateDGEobj(MyDgeObj, annotations) #' +#' #' @import magrittr #' @importFrom stringr str_remove_all str_locate #' @importFrom utils read.delim diff --git a/R/attributes.R b/R/attributes.R index 5081fde..037fd60 100644 --- a/R/attributes.R +++ b/R/attributes.R @@ -10,12 +10,10 @@ #' "dimnames", "rownames", "colnames", "listData", "objDef") #' #' @examples -#' \dontrun{ #' # example DGEobj -#' exObj <- readRDS(system.file("exampleObj.RDS", package = "DGEobj")) +#' exObj <- readRDS(system.file("miniObj.RDS", package = "DGEobj")) #' #' showAttributes(exObj) -#'} #' #' @export showAttributes <- function(dgeObj, skipList = c("dim", "dimnames", "rownames", "colnames", "listData", "objDef")) { @@ -57,7 +55,7 @@ showAttributes <- function(dgeObj, skipList = c("dim", "dimnames", "rownames", " #' #' @examples #' # example DGEobj -#' exObj <- readRDS(system.file("exampleObj.RDS", package = "DGEobj")) +#' exObj <- readRDS(system.file("miniObj.RDS", package = "DGEobj")) #' #' # Assign attributes to a DGEobj #' MyAttributes <- list(Platform = "RNA-Seq", @@ -107,7 +105,7 @@ setAttributes <- function(dgeObj, attribs){ #' #' @examples #' # example DGEobj -#' exObj <- readRDS(system.file("exampleObj.RDS", package = "DGEobj")) +#' exObj <- readRDS(system.file("miniObj.RDS", package = "DGEobj")) #' #' getAttributes(exObj) #' @@ -132,7 +130,7 @@ getAttributes <- function(dgeObj, #' #' @examples #' # example DGEobj -#' exObj <- readRDS(system.file("exampleObj.RDS", package = "DGEobj")) +#' exObj <- readRDS(system.file("miniObj.RDS", package = "DGEobj")) #' #' showMeta(exObj) #' diff --git a/R/get.R b/R/get.R index eb3b9c1..27fd468 100644 --- a/R/get.R +++ b/R/get.R @@ -7,7 +7,7 @@ #' #' @examples #' # example DGEobj -#' exObj <- readRDS(system.file("exampleObj.RDS", package = "DGEobj")) +#' exObj <- readRDS(system.file("miniObj.RDS", package = "DGEobj")) #' #' myList <- getItems(exObj, list("counts", "geneData")) #' names(myList) @@ -17,7 +17,6 @@ #' #' @export getItems <- function(dgeObj, itemNames){ - assertthat::assert_that(!missing(dgeObj), !missing(itemNames), msg = "Specify both a DGEobj and at least one itemName to retrieve.") @@ -52,7 +51,7 @@ getItems <- function(dgeObj, itemNames){ #' #' @examples #' # example DGEobj -#' exObj <- readRDS(system.file("exampleObj.RDS", package = "DGEobj")) +#' exObj <- readRDS(system.file("miniObj.RDS", package = "DGEobj")) #' #' MyCounts <- getItem(exObj, "counts") #' @@ -85,7 +84,7 @@ getItem <- function(dgeObj, itemName){ #' #' @examples #' # example DGEobj -#' exObj <- readRDS(system.file("exampleObj.RDS", package = "DGEobj")) +#' exObj <- readRDS(system.file("miniObj.RDS", package = "DGEobj")) #' #' MyRawData <- getType(exObj, type = list("counts", "design", "geneData")) #' @@ -119,7 +118,7 @@ getType <- function(dgeObj, type, parent){ #' #' @examples #' # example DGEobj -#' exObj <- readRDS(system.file("exampleObj.RDS", package = "DGEobj")) +#' exObj <- readRDS(system.file("miniObj.RDS", package = "DGEobj")) #' #' Assays <- getBaseType(exObj, baseType = "assay") #' AssaysAndMeta <- getBaseType(exObj, c("assay", "meta")) diff --git a/R/init.R b/R/init.R index 3249af3..84b100d 100644 --- a/R/init.R +++ b/R/init.R @@ -20,18 +20,17 @@ #' @return A DGEobj #' #' @examples -#' -#' dgeObj <- readRDS(system.file("exampleObj.RDS", package = "DGEobj")) +#' dgeObj <- readRDS(system.file("miniObj.RDS", package = "DGEobj")) #' MyCounts <- dgeObj$counts #' geneinfo <- dgeObj$geneData #' sampinfo <- dgeObj$design #' #' myDgeObj <- initDGEobj(primaryAssayData = MyCounts, -#' rowData = geneinfo, -#' colData = sampinfo, -#' level = "gene", -#' customAttr = list (Genome = "Rat.B6.0", -#' GeneModel = "Ensembl.R89")) +#' rowData = geneinfo, +#' colData = sampinfo, +#' level = "gene", +#' customAttr = list (Genome = "Rat.B6.0", +#' GeneModel = "Ensembl.R89")) #' #' @import magrittr #' @importFrom assertthat assert_that diff --git a/R/reset.R b/R/reset.R index 08776b6..e5de576 100644 --- a/R/reset.R +++ b/R/reset.R @@ -11,16 +11,14 @@ #' @return A DGEobj #' #' @examples -#' \dontrun{ #' #example object -#' exObj <- readRDS(system.file("exampleObj.RDS", package = "DGEobj")) +#' exObj <- readRDS(system.file("miniObj.RDS", package = "DGEobj")) #' #' # subset to first 10 rows to show reset functionality #' exObj <- exObj[c(1:10), ] #' #' exObj <- resetDGEobj(exObj) #' dim(exObj) -#'} #' #' @importFrom assertthat assert_that #' diff --git a/R/rmItem.R b/R/rmItem.R index 06b79e0..43e1bed 100644 --- a/R/rmItem.R +++ b/R/rmItem.R @@ -7,7 +7,7 @@ #' #' @examples #' # example DGEobj -#' exObj <- readRDS(system.file("exampleObj.RDS", package = "DGEobj")) +#' exObj <- readRDS(system.file("miniObj.RDS", package = "DGEobj")) #' #' exObj <- rmItem(exObj, "design") #' diff --git a/R/subset.R b/R/subset.R index 4861db8..3fc4b4f 100644 --- a/R/subset.R +++ b/R/subset.R @@ -11,12 +11,10 @@ #' @return A DGEobj #' #' @examples -#' \dontrun{ #' # example DGEobj -#' exObj <- readRDS(system.file("exampleObj.RDS", package = "DGEobj")) +#' exObj <- readRDS(system.file("miniObj.RDS", package = "DGEobj")) #' #' exObj <- subset(exObj, 1:10, 5:50) -#'} #' #' @importFrom assertthat assert_that #' @importFrom stringr str_c diff --git a/R/types.R b/R/types.R index 5ef7182..3d15a9b 100644 --- a/R/types.R +++ b/R/types.R @@ -7,7 +7,7 @@ #' #' @examples #' # example DGEobj -#' exObj <- readRDS(system.file("exampleObj.RDS", package = "DGEobj")) +#' exObj <- readRDS(system.file("miniObj.RDS", package = "DGEobj")) #' #' baseType(exObj, type = "DGEList") #' @@ -43,7 +43,7 @@ baseType <- function(dgeObj, type){ #' baseTypes() #' #' # example DGEobj -#' exObj <- readRDS(system.file("exampleObj.RDS", package = "DGEobj")) +#' exObj <- readRDS(system.file("miniObj.RDS", package = "DGEobj")) #' #' # Basetypes from a specific DGEobj #' baseTypes(exObj) @@ -65,7 +65,7 @@ baseTypes <- function(dgeObj){ #' #' @examples #' # example DGEobj -#' exObj <- readRDS(system.file("exampleObj.RDS", package = "DGEobj")) +#' exObj <- readRDS(system.file("miniObj.RDS", package = "DGEobj")) #' #' showTypes(exObj) #' @@ -98,7 +98,7 @@ showTypes <- function(dgeObj){ #' #' @examples #' # example DGEobj -#' exObj <- readRDS(system.file("exampleObj.RDS", package = "DGEobj")) +#' exObj <- readRDS(system.file("miniObj.RDS", package = "DGEobj")) #' #' exObj <- newType(exObj, #' itemType = "AffyRMA", diff --git a/R/utils.R b/R/utils.R index 11e503f..cbd42ad 100644 --- a/R/utils.R +++ b/R/utils.R @@ -44,12 +44,10 @@ dimnames.DGEobj <- function(x){ #' @return NULL #' #' @examples -#' \dontrun{ #' # example DGEobj -#' exObj <- readRDS(system.file("exampleObj.RDS", package = "DGEobj")) +#' exObj <- readRDS(system.file("miniObj.RDS", package = "DGEobj")) #' #' print(exObj) -#'} #' #' @export print.DGEobj <- function(x, ..., verbose = FALSE) { @@ -67,12 +65,10 @@ print.DGEobj <- function(x, ..., verbose = FALSE) { #' @return A data.frame summarizing the data contained in the DGEobj #' #' @examples -#' \dontrun{ #' # example DGEobj -#' exObj <- readRDS(system.file("exampleObj.RDS", package = "DGEobj")) +#' exObj <- readRDS(system.file("miniObj.RDS", package = "DGEobj")) #' #' inventory(exObj) -#' } #' #' @export inventory <- function(dgeObj, verbose = FALSE) { @@ -122,7 +118,7 @@ inventory <- function(dgeObj, verbose = FALSE) { #' #' @examples #' # example DGEobj -#' exObj <- readRDS(system.file("exampleObj.RDS", package = "DGEobj")) +#' exObj <- readRDS(system.file("miniObj.RDS", package = "DGEobj")) #' #' mylist <- as.list(exObj) #' diff --git a/cran-comments.md b/cran-comments.md index a125b5d..afcaeb6 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,8 +1,16 @@ ## Comments from Maintainer -* Resolved CRAN check errors -* Skipping examples dependent on suggested packages -* Updated tests so that they do not fail if suggested packages are not available +* There is one outstanding note - we updated this package recently in an attempt to resolve the issues with noSuggests +however unfortunately it uncovered a different package dependency problem that wasn't caught on the 3 standard RHub platform +configurations. We have now combed over the entire package and extensively checked all RHub and local platforms to try to +ensure the suggested packages are just that, suggested! We also made sure we now have a very small example object to use +that was not made using any of the suggested packages as well. + +* We appreciate your consideration of this package update, here is what we have done for this release: + * Resolved CRAN check errors, including the noSuggests issues + * Added a new example object so that as many examples can be run as possible without suggested packages + * Bioconductor packages in suggests are required for testing, now we will not run tests if any are missing + * Also updated our process to check ALL available/usable RHub platforms prior to submission --- @@ -13,6 +21,7 @@ RStudio Server Pro (ubuntu 18.04.2) * R 3.6.3 * R 4.0.5 * R 4.1.3 +* R 4.2.0 CircleCI @@ -28,7 +37,9 @@ WinBuilder RHub * devtools::check_rhub(interactive = F, - env_vars = c("_R_CHECK_DEPENDS_ONLY_" = "true")) + platforms = c(rhub::platforms()$name), + env_vars = c("_R_CHECK_DEPENDS_ONLY_" = "true", + "_R_CHECK_FORCE_SUGGESTS_" = "false")) --- diff --git a/inst/miniObj.RDS b/inst/miniObj.RDS new file mode 100644 index 0000000..9c6e386 Binary files /dev/null and b/inst/miniObj.RDS differ diff --git a/man/addItem.Rd b/man/addItem.Rd index 05e9040..11276b9 100644 --- a/man/addItem.Rd +++ b/man/addItem.Rd @@ -45,10 +45,10 @@ Add a data item \dontrun{ myFunArgs <- match.call() # Capture calling function and arguments - myDGEobj <- addItem(myDGEobj, item = MyCounts, + myDGEobj <- addItem(myDGEobj, item = MyCounts, itemName = "counts", itemType = "counts", - funArgs = myFunArgs) + funArgs = myFunArgs) } } diff --git a/man/addItems.Rd b/man/addItems.Rd index 96c99ed..45ee515 100644 --- a/man/addItems.Rd +++ b/man/addItems.Rd @@ -30,7 +30,9 @@ Add multiple data items } \examples{ \dontrun{ - # Add normalize counts (DGEList) and log2CPM as additional "assay" items in the DGEobj + # NOTE: Requires the edgeR package + + # Add normalized counts and log2CPM as additional "assay" items in the DGEobj dgeObj <- readRDS(system.file("exampleObj.RDS", package = "DGEobj")) dgeList <- edgeR::calcNormFactors(edgeR::DGEList(dgeObj$counts), method="TMM") log2cpm <- edgeR::cpm(dgeList, log = TRUE) diff --git a/man/annotateDGEobj.Rd b/man/annotateDGEobj.Rd index be736f1..829b358 100644 --- a/man/annotateDGEobj.Rd +++ b/man/annotateDGEobj.Rd @@ -33,11 +33,12 @@ specifies which keys we want to capture as attributes on the DGEobj. #using a text file file of key=value pairs annotationFile <- "/location/to/myAnnotations.txt" MyDgeObj <- annotateDGEobj(MyDgeObj, annotationFile) -} + #using a named list of key/values annotations <- list(Title = "Rat Liver Slices from Bile Duct Ligation animals", Organism = "Rat", GeneModel = "Ensembl.R89") MyDgeObj <- annotateDGEobj(MyDgeObj, annotations) +} } diff --git a/man/as.list.DGEobj.Rd b/man/as.list.DGEobj.Rd index 60dfdab..a4e4f7c 100644 --- a/man/as.list.DGEobj.Rd +++ b/man/as.list.DGEobj.Rd @@ -19,7 +19,7 @@ Cast as a simple list } \examples{ # example DGEobj - exObj <- readRDS(system.file("exampleObj.RDS", package = "DGEobj")) + exObj <- readRDS(system.file("miniObj.RDS", package = "DGEobj")) mylist <- as.list(exObj) diff --git a/man/baseType.Rd b/man/baseType.Rd index 6d07771..2d60ad2 100644 --- a/man/baseType.Rd +++ b/man/baseType.Rd @@ -19,7 +19,7 @@ Get the baseType of an internal data item } \examples{ # example DGEobj - exObj <- readRDS(system.file("exampleObj.RDS", package = "DGEobj")) + exObj <- readRDS(system.file("miniObj.RDS", package = "DGEobj")) baseType(exObj, type = "DGEList") diff --git a/man/baseTypes.Rd b/man/baseTypes.Rd index cbc95a6..c43bb35 100644 --- a/man/baseTypes.Rd +++ b/man/baseTypes.Rd @@ -20,7 +20,7 @@ Get a list of the available baseTypes baseTypes() # example DGEobj - exObj <- readRDS(system.file("exampleObj.RDS", package = "DGEobj")) + exObj <- readRDS(system.file("miniObj.RDS", package = "DGEobj")) # Basetypes from a specific DGEobj baseTypes(exObj) diff --git a/man/getAttributes.Rd b/man/getAttributes.Rd index 83d5f9f..40a20b1 100644 --- a/man/getAttributes.Rd +++ b/man/getAttributes.Rd @@ -23,7 +23,7 @@ excludeList argument. } \examples{ # example DGEobj - exObj <- readRDS(system.file("exampleObj.RDS", package = "DGEobj")) + exObj <- readRDS(system.file("miniObj.RDS", package = "DGEobj")) getAttributes(exObj) diff --git a/man/getBaseType.Rd b/man/getBaseType.Rd index 79d5b5b..a16e22f 100644 --- a/man/getBaseType.Rd +++ b/man/getBaseType.Rd @@ -19,7 +19,7 @@ Retrieve data items by baseType } \examples{ # example DGEobj - exObj <- readRDS(system.file("exampleObj.RDS", package = "DGEobj")) + exObj <- readRDS(system.file("miniObj.RDS", package = "DGEobj")) Assays <- getBaseType(exObj, baseType = "assay") AssaysAndMeta <- getBaseType(exObj, c("assay", "meta")) diff --git a/man/getItem.Rd b/man/getItem.Rd index 9852214..bdae976 100644 --- a/man/getItem.Rd +++ b/man/getItem.Rd @@ -19,7 +19,7 @@ Retrieve a data item by name } \examples{ # example DGEobj - exObj <- readRDS(system.file("exampleObj.RDS", package = "DGEobj")) + exObj <- readRDS(system.file("miniObj.RDS", package = "DGEobj")) MyCounts <- getItem(exObj, "counts") diff --git a/man/getItems.Rd b/man/getItems.Rd index 685aba7..cbf9bef 100644 --- a/man/getItems.Rd +++ b/man/getItems.Rd @@ -19,7 +19,7 @@ Retrieve multiple data items by name } \examples{ # example DGEobj - exObj <- readRDS(system.file("exampleObj.RDS", package = "DGEobj")) + exObj <- readRDS(system.file("miniObj.RDS", package = "DGEobj")) myList <- getItems(exObj, list("counts", "geneData")) names(myList) diff --git a/man/getType.Rd b/man/getType.Rd index c292868..3627a9f 100644 --- a/man/getType.Rd +++ b/man/getType.Rd @@ -22,7 +22,7 @@ Retrieve data items by type } \examples{ # example DGEobj - exObj <- readRDS(system.file("exampleObj.RDS", package = "DGEobj")) + exObj <- readRDS(system.file("miniObj.RDS", package = "DGEobj")) MyRawData <- getType(exObj, type = list("counts", "design", "geneData")) diff --git a/man/initDGEobj.Rd b/man/initDGEobj.Rd index 4533930..4261d3e 100644 --- a/man/initDGEobj.Rd +++ b/man/initDGEobj.Rd @@ -45,17 +45,16 @@ A DGEobj Initialize with base data (primaryAssayData, row annotations, col annotations) } \examples{ - - dgeObj <- readRDS(system.file("exampleObj.RDS", package = "DGEobj")) + dgeObj <- readRDS(system.file("miniObj.RDS", package = "DGEobj")) MyCounts <- dgeObj$counts geneinfo <- dgeObj$geneData sampinfo <- dgeObj$design myDgeObj <- initDGEobj(primaryAssayData = MyCounts, - rowData = geneinfo, - colData = sampinfo, - level = "gene", - customAttr = list (Genome = "Rat.B6.0", - GeneModel = "Ensembl.R89")) + rowData = geneinfo, + colData = sampinfo, + level = "gene", + customAttr = list (Genome = "Rat.B6.0", + GeneModel = "Ensembl.R89")) } diff --git a/man/inventory.Rd b/man/inventory.Rd index 5976647..7abd2e5 100644 --- a/man/inventory.Rd +++ b/man/inventory.Rd @@ -18,11 +18,9 @@ A data.frame summarizing the data contained in the DGEobj Retrieve the object inventory } \examples{ -\dontrun{ # example DGEobj - exObj <- readRDS(system.file("exampleObj.RDS", package = "DGEobj")) + exObj <- readRDS(system.file("miniObj.RDS", package = "DGEobj")) inventory(exObj) -} } diff --git a/man/newType.Rd b/man/newType.Rd index 02ed2f9..5ad3a35 100644 --- a/man/newType.Rd +++ b/man/newType.Rd @@ -23,7 +23,7 @@ Add a new type definition to a DGEobj } \examples{ # example DGEobj - exObj <- readRDS(system.file("exampleObj.RDS", package = "DGEobj")) + exObj <- readRDS(system.file("miniObj.RDS", package = "DGEobj")) exObj <- newType(exObj, itemType = "AffyRMA", diff --git a/man/print.DGEobj.Rd b/man/print.DGEobj.Rd index 118d24b..597fecd 100644 --- a/man/print.DGEobj.Rd +++ b/man/print.DGEobj.Rd @@ -17,11 +17,9 @@ Print the Inventory } \examples{ -\dontrun{ # example DGEobj - exObj <- readRDS(system.file("exampleObj.RDS", package = "DGEobj")) + exObj <- readRDS(system.file("miniObj.RDS", package = "DGEobj")) print(exObj) -} } diff --git a/man/resetDGEobj.Rd b/man/resetDGEobj.Rd index 55a1227..17208f0 100644 --- a/man/resetDGEobj.Rd +++ b/man/resetDGEobj.Rd @@ -20,15 +20,13 @@ but does revert changes made with addItem() and rmItem(). Reset requires that *_ in the DGEobj. } \examples{ -\dontrun{ #example object - exObj <- readRDS(system.file("exampleObj.RDS", package = "DGEobj")) + exObj <- readRDS(system.file("miniObj.RDS", package = "DGEobj")) # subset to first 10 rows to show reset functionality exObj <- exObj[c(1:10), ] exObj <- resetDGEobj(exObj) dim(exObj) -} } diff --git a/man/rmItem.Rd b/man/rmItem.Rd index 9100328..4ef5b75 100644 --- a/man/rmItem.Rd +++ b/man/rmItem.Rd @@ -19,7 +19,7 @@ Removes a named data item } \examples{ # example DGEobj - exObj <- readRDS(system.file("exampleObj.RDS", package = "DGEobj")) + exObj <- readRDS(system.file("miniObj.RDS", package = "DGEobj")) exObj <- rmItem(exObj, "design") diff --git a/man/setAttributes.Rd b/man/setAttributes.Rd index c8ffd7f..2d2e8d0 100644 --- a/man/setAttributes.Rd +++ b/man/setAttributes.Rd @@ -24,7 +24,7 @@ To remove an attribute from an object pass NULL as the attribute value. } \examples{ # example DGEobj - exObj <- readRDS(system.file("exampleObj.RDS", package = "DGEobj")) + exObj <- readRDS(system.file("miniObj.RDS", package = "DGEobj")) # Assign attributes to a DGEobj MyAttributes <- list(Platform = "RNA-Seq", diff --git a/man/showAttributes.Rd b/man/showAttributes.Rd index f7bc0cb..1a06e3a 100644 --- a/man/showAttributes.Rd +++ b/man/showAttributes.Rd @@ -23,11 +23,9 @@ This function prints all attributes regardless of the class of the attribute val *Note* Use showMeta() to only retrieve attributes that are key/value pairs. } \examples{ -\dontrun{ # example DGEobj - exObj <- readRDS(system.file("exampleObj.RDS", package = "DGEobj")) + exObj <- readRDS(system.file("miniObj.RDS", package = "DGEobj")) showAttributes(exObj) -} } diff --git a/man/showMeta.Rd b/man/showMeta.Rd index f380138..6956e80 100644 --- a/man/showMeta.Rd +++ b/man/showMeta.Rd @@ -17,7 +17,7 @@ Retrieve the Key/Value metadata attributes that have a character value and lengt } \examples{ # example DGEobj - exObj <- readRDS(system.file("exampleObj.RDS", package = "DGEobj")) + exObj <- readRDS(system.file("miniObj.RDS", package = "DGEobj")) showMeta(exObj) diff --git a/man/showTypes.Rd b/man/showTypes.Rd index 1b5f8f3..5750bbf 100644 --- a/man/showTypes.Rd +++ b/man/showTypes.Rd @@ -17,7 +17,7 @@ Returns and prints the list of all defined types } \examples{ # example DGEobj - exObj <- readRDS(system.file("exampleObj.RDS", package = "DGEobj")) + exObj <- readRDS(system.file("miniObj.RDS", package = "DGEobj")) showTypes(exObj) diff --git a/man/subset.DGEobj.Rd b/man/subset.DGEobj.Rd index 905a291..7a3e24d 100644 --- a/man/subset.DGEobj.Rd +++ b/man/subset.DGEobj.Rd @@ -26,11 +26,9 @@ A DGEobj Subset internal row or column data } \examples{ -\dontrun{ # example DGEobj - exObj <- readRDS(system.file("exampleObj.RDS", package = "DGEobj")) + exObj <- readRDS(system.file("miniObj.RDS", package = "DGEobj")) exObj <- subset(exObj, 1:10, 5:50) -} } diff --git a/misc/test_object_creation/create_objects.R b/misc/test_object_creation/create_objects.R index feac996..7eded3a 100644 --- a/misc/test_object_creation/create_objects.R +++ b/misc/test_object_creation/create_objects.R @@ -40,41 +40,40 @@ dge_creation_workflow <- function(counts, gene.data, design, qcdata, contrast_li # saveRDS(result, glue("simple{ifelse(is.null(limit_genes), '', limit_genes)}.RDS")) # Protein Coding Filtering - result <- result[result$geneData$gene_biotype == "protein_coding", ] - - # Normalize - if (requireNamespace("edgeR", quietly = TRUE)) { - result <- runEdgeRNorm(result, includePlot = FALSE) + result <- result[result$geneData$gene_biotype %in% ("protein_coding"), ] + + # Create using workflow functions IF IT MAKES SENSE + if (limit_genes > 500) { + # Normalize + result <- runEdgeRNorm(result, includePlot = FALSE) + + # Define Model + formula <- '~ 0 + ReplicateGroup' + designMatrixName <- "ReplicateGroupDesign" + + designMatrix <- model.matrix(as.formula(formula), + getItem(result, "design")) + attr(designMatrix, "formula") <- formula + colnames(designMatrix) <- make.names(colnames(designMatrix)) + + result <- addItem(result, + item = designMatrix, + itemName = designMatrixName, + itemType = "designMatrix", + parent = "design", + overwrite = TRUE) + + result <- runVoom(result, + designMatrixName = designMatrixName, + mvPlot = FALSE) + + result <- runContrasts(result, + designMatrixName = designMatrixName, + contrastList = contrast_list, + qValue = TRUE, + IHW = TRUE) } - # Define Model - formula <- '~ 0 + ReplicateGroup' - designMatrixName <- "ReplicateGroupDesign" - - designMatrix <- model.matrix(as.formula(formula), - getItem(result, "design")) - attr(designMatrix, "formula") <- formula - colnames(designMatrix) <- make.names(colnames(designMatrix)) - - result <- addItem(result, - item = designMatrix, - itemName = designMatrixName, - itemType = "designMatrix", - parent = "design", - overwrite = TRUE) - - # runVoom - result <- runVoom(result, - designMatrixName = designMatrixName, - mvPlot = FALSE) - - # runContrasts - result <- runContrasts(result, - designMatrixName = designMatrixName, - contrastList = contrast_list, - qValue = TRUE, - IHW = TRUE) - result } @@ -167,3 +166,6 @@ saveRDS(full.dge, "fullObj.RDS") sm.dge <- dge_creation_workflow(counts, gene.data, design, qcdata, contrast_list, annotatFile, limit_genes = 1000) saveRDS(sm.dge, 'exampleObj.RDS') + +mini.dge <- dge_creation_workflow(counts, gene.data, design, qcdata, contrast_list[c(1,4)], annotatFile, limit_genes = 250) +saveRDS(mini.dge, 'miniObj.RDS') diff --git a/tests/testthat/setup.R b/tests/testthat/setup.R index f913bd3..5fb5556 100644 --- a/tests/testthat/setup.R +++ b/tests/testthat/setup.R @@ -4,8 +4,14 @@ require(DGEobj) setup_failed <- TRUE -if (requireNamespace('GenomicRanges', quietly = TRUE)) { +# NOTE: if the bioconductor packages are missing from the platform we will NOT perform tests +if (requireNamespace('GenomicRanges', quietly = TRUE) && + requireNamespace('edgeR', quietly = TRUE) && + requireNamespace('biomaRt', quietly = TRUE)) { + require(GenomicRanges) + require(edgeR) + # require(biomaRt) - does not need to be imported into the environment # --- gene level example object t_obj <- readRDS(system.file("exampleObj.RDS", package = "DGEobj", mustWork = TRUE)) @@ -60,3 +66,7 @@ if (requireNamespace('GenomicRanges', quietly = TRUE)) { setup_failed <- FALSE } + +if (setup_failed) { + message('Test Setup Failed - likely due to missing suggested packages. Tests will be skipped.') +} diff --git a/tests/testthat/test_addItem.R b/tests/testthat/test_addItem.R index f57608b..e8150f0 100644 --- a/tests/testthat/test_addItem.R +++ b/tests/testthat/test_addItem.R @@ -1,6 +1,7 @@ context("addItem.R functions") skip_if(setup_failed) + test_that('addItem.R: addItem()', { #meta add <- addItem(t_obj, diff --git a/tests/testthat/test_annotate.R b/tests/testthat/test_annotate.R index 11b7b24..22447d3 100644 --- a/tests/testthat/test_annotate.R +++ b/tests/testthat/test_annotate.R @@ -1,6 +1,7 @@ context("DGEobj - tests for annotate.R functions") skip_if(setup_failed) + test_that('annotate.R: annotateDGEobj()', { ann.file <- tempfile("annotations_test", fileext = ".txt") writeLines(c("key1='value 1'", "key2=value 2"), con = ann.file) diff --git a/tests/testthat/test_attributes.R b/tests/testthat/test_attributes.R index 099eb14..eced548 100644 --- a/tests/testthat/test_attributes.R +++ b/tests/testthat/test_attributes.R @@ -1,6 +1,7 @@ context("attributes.R functions") skip_if(setup_failed) + test_that("attributes.R: showAttributes()", { output <- capture_output_lines(showAttributes(t_obj)) diff --git a/tests/testthat/test_get.R b/tests/testthat/test_get.R index 0f3b210..c0b6af9 100644 --- a/tests/testthat/test_get.R +++ b/tests/testthat/test_get.R @@ -1,6 +1,7 @@ context("get.R functions") skip_if(setup_failed) + test_that('get.R: getItem()', { getItem_DGEobj_test <- getItem(t_obj, 'design') diff --git a/tests/testthat/test_init.R b/tests/testthat/test_init.R index 21f445d..6050ef0 100644 --- a/tests/testthat/test_init.R +++ b/tests/testthat/test_init.R @@ -1,6 +1,7 @@ context("init.R functions") skip_if(setup_failed) + test_that('init.R: initDGEobj()', { # collect data from test object to initialize new DGEobj diff --git a/tests/testthat/test_reset.R b/tests/testthat/test_reset.R index a75786c..55cd2bd 100644 --- a/tests/testthat/test_reset.R +++ b/tests/testthat/test_reset.R @@ -1,7 +1,7 @@ context("reset.R functions") skip_if(setup_failed) -# test gene level data + test_that('reset.R: gene level data', { test_t_obj <- t_obj diff --git a/tests/testthat/test_rmItem.R b/tests/testthat/test_rmItem.R index 907edc7..ed2e2f6 100644 --- a/tests/testthat/test_rmItem.R +++ b/tests/testthat/test_rmItem.R @@ -1,6 +1,7 @@ context("rmItem.R functions") skip_if(setup_failed) + test_that('rmItem.R: rmItem()', { expect_length(t_obj, 18) rmItem_design_t_obj <- rmItem(t_obj, "design") diff --git a/tests/testthat/test_subset.R b/tests/testthat/test_subset.R index aad8544..187b4a5 100644 --- a/tests/testthat/test_subset.R +++ b/tests/testthat/test_subset.R @@ -1,6 +1,7 @@ context("subset.R functions") skip_if(setup_failed) + test_that('subset.R: subset()', { subsett_obj_1.0 <- subset(t_obj, row = c(1:5)) subsett_obj_1.1 <- t_obj[c(1:5), ] diff --git a/tests/testthat/test_types.R b/tests/testthat/test_types.R index 3b547a7..72641f2 100644 --- a/tests/testthat/test_types.R +++ b/tests/testthat/test_types.R @@ -1,6 +1,7 @@ context("types.R functions") skip_if(setup_failed) + test_that('types.R: baseType()', { expect_equal(baseType(t_obj, "counts"), "assay") expect_equal(baseType(t_obj, "design"), "col") diff --git a/tests/testthat/test_utils.R b/tests/testthat/test_utils.R index a2a0dde..cb71859 100644 --- a/tests/testthat/test_utils.R +++ b/tests/testthat/test_utils.R @@ -1,6 +1,7 @@ context("utils.R functions") skip_if(setup_failed) + test_that('utils.R: dim()/dimnames()', { expect_equal(dim(t_obj), t_dim) dimnames_t_obj <- dimnames(t_obj) diff --git a/vignettes/DGEobj_Overview.Rmd b/vignettes/DGEobj_Overview.Rmd index ded122c..b92a325 100644 --- a/vignettes/DGEobj_Overview.Rmd +++ b/vignettes/DGEobj_Overview.Rmd @@ -1,7 +1,7 @@ --- title: 'DGEobj: An S3 Object to Capture and Annotate DGE Workflows' author: "John R. Thompson" -date: "2022-03-24" +date: "2022-05-12" output: rmarkdown::html_vignette: fig_caption: yes @@ -332,14 +332,14 @@ kable(inventory(dgeObj)) |ItemName |ItemType |BaseType |Parent |Class |Row |Col |DateCreated | |:-------------|:-------------|:--------|:-------------|:----------|:-----|:---|:-------------------| -|counts_orig |counts_orig |meta | |matrix |32883 |48 |2022-03-24 11:47:54 | -|counts |counts |assay |counts_orig |matrix |32883 |48 |2022-03-24 11:47:54 | -|design_orig |design_orig |meta | |data.frame |48 |10 |2022-03-24 11:47:54 | -|design |design |col |design_orig |data.frame |48 |10 |2022-03-24 11:47:54 | -|geneData_orig |geneData_orig |meta | |data.frame |32883 |8 |2022-03-24 11:47:54 | -|geneData |geneData |row |geneData_orig |data.frame |32883 |8 |2022-03-24 11:47:54 | -|granges_orig |granges_orig |meta |geneData_orig |GRanges |32883 |NA |2022-03-24 11:47:55 | -|granges |granges |row |geneData |GRanges |32883 |NA |2022-03-24 11:47:55 | +|counts_orig |counts_orig |meta | |matrix |32883 |48 |2022-05-12 10:58:09 | +|counts |counts |assay |counts_orig |matrix |32883 |48 |2022-05-12 10:58:09 | +|design_orig |design_orig |meta | |data.frame |48 |10 |2022-05-12 10:58:09 | +|design |design |col |design_orig |data.frame |48 |10 |2022-05-12 10:58:09 | +|geneData_orig |geneData_orig |meta | |data.frame |32883 |8 |2022-05-12 10:58:09 | +|geneData |geneData |row |geneData_orig |data.frame |32883 |8 |2022-05-12 10:58:09 | +|granges_orig |granges_orig |meta |geneData_orig |GRanges |32883 |NA |2022-05-12 10:58:10 | +|granges |granges |row |geneData |GRanges |32883 |NA |2022-05-12 10:58:10 | ## Examine DGEobj Metadata @@ -488,14 +488,14 @@ kable(inventory(dgeObj)) |ItemName |ItemType |BaseType |Parent |Class |Row |Col |DateCreated | |:-------------|:-------------|:--------|:-------------|:----------|:-----|:---|:-------------------| -|counts_orig |counts_orig |meta | |matrix |32883 |48 |2022-03-24 11:47:54 | -|counts |counts |assay |counts_orig |matrix |32883 |48 |2022-03-24 11:47:54 | -|design_orig |design_orig |meta | |data.frame |48 |10 |2022-03-24 11:47:54 | -|design |design |col |design_orig |data.frame |48 |10 |2022-03-24 11:47:54 | -|geneData_orig |geneData_orig |meta | |data.frame |32883 |8 |2022-03-24 11:47:54 | -|geneData |geneData |row |geneData_orig |data.frame |32883 |8 |2022-03-24 11:47:54 | -|granges_orig |granges_orig |meta |geneData_orig |GRanges |32883 |NA |2022-03-24 11:47:55 | -|granges |granges |row |geneData |GRanges |32883 |NA |2022-03-24 11:47:55 | +|counts_orig |counts_orig |meta | |matrix |32883 |48 |2022-05-12 10:58:09 | +|counts |counts |assay |counts_orig |matrix |32883 |48 |2022-05-12 10:58:09 | +|design_orig |design_orig |meta | |data.frame |48 |10 |2022-05-12 10:58:09 | +|design |design |col |design_orig |data.frame |48 |10 |2022-05-12 10:58:09 | +|geneData_orig |geneData_orig |meta | |data.frame |32883 |8 |2022-05-12 10:58:09 | +|geneData |geneData |row |geneData_orig |data.frame |32883 |8 |2022-05-12 10:58:09 | +|granges_orig |granges_orig |meta |geneData_orig |GRanges |32883 |NA |2022-05-12 10:58:10 | +|granges |granges |row |geneData |GRanges |32883 |NA |2022-05-12 10:58:10 | If just the item names of data stored in the DGEobj are needed, use the base R `names` function. @@ -557,16 +557,16 @@ kable(inventory(newdgeObj)) |ItemName |ItemType |BaseType |Parent |Class |Row |Col |DateCreated | |:-------------|:-------------|:--------|:-------------|:----------|:-----|:---|:-------------------| -|counts_orig |counts_orig |meta | |matrix |32883 |48 |2022-03-24 11:47:54 | -|counts |counts |assay |counts_orig |matrix |32883 |48 |2022-03-24 11:47:54 | -|design_orig |design_orig |meta | |data.frame |48 |10 |2022-03-24 11:47:54 | -|design |design |col |design_orig |data.frame |48 |10 |2022-03-24 11:47:54 | -|geneData_orig |geneData_orig |meta | |data.frame |32883 |8 |2022-03-24 11:47:54 | -|geneData |geneData |row |geneData_orig |data.frame |32883 |8 |2022-03-24 11:47:54 | -|granges_orig |granges_orig |meta |geneData_orig |GRanges |32883 |NA |2022-03-24 11:47:55 | -|granges |granges |row |geneData |GRanges |32883 |NA |2022-03-24 11:47:55 | -|AlignmentQC |alignQC |col | |data.frame |48 |172 |2022-03-24 11:47:55 | -|normTMM |DGEList |assay |counts |DGEList |32883 |48 |2022-03-24 11:47:56 | +|counts_orig |counts_orig |meta | |matrix |32883 |48 |2022-05-12 10:58:09 | +|counts |counts |assay |counts_orig |matrix |32883 |48 |2022-05-12 10:58:09 | +|design_orig |design_orig |meta | |data.frame |48 |10 |2022-05-12 10:58:09 | +|design |design |col |design_orig |data.frame |48 |10 |2022-05-12 10:58:09 | +|geneData_orig |geneData_orig |meta | |data.frame |32883 |8 |2022-05-12 10:58:09 | +|geneData |geneData |row |geneData_orig |data.frame |32883 |8 |2022-05-12 10:58:09 | +|granges_orig |granges_orig |meta |geneData_orig |GRanges |32883 |NA |2022-05-12 10:58:10 | +|granges |granges |row |geneData |GRanges |32883 |NA |2022-05-12 10:58:10 | +|AlignmentQC |alignQC |col | |data.frame |48 |172 |2022-05-12 10:58:10 | +|normTMM |DGEList |assay |counts |DGEList |32883 |48 |2022-05-12 10:58:11 | **item** is the actual data object to add. @@ -1023,12 +1023,12 @@ kable(inventory(MetabolomicObj)) |ItemName |ItemType |BaseType |Parent |Class |Row |Col |DateCreated | |:-------------------|:-------------------|:--------|:-------------------|:----------|:-----|:---|:-------------------| -|intensity_orig |intensity_orig |meta | |matrix |32883 |48 |2022-03-24 11:47:58 | -|intensity |intensity |assay |intensity_orig |matrix |32883 |48 |2022-03-24 11:47:58 | -|design_orig |design_orig |meta | |data.frame |48 |10 |2022-03-24 11:47:58 | -|design |design |col |design_orig |data.frame |48 |10 |2022-03-24 11:47:58 | -|metaboliteData_orig |metaboliteData_orig |meta | |data.frame |32883 |8 |2022-03-24 11:47:58 | -|metaboliteData |metaboliteData |row |metaboliteData_orig |data.frame |32883 |8 |2022-03-24 11:47:58 | +|intensity_orig |intensity_orig |meta | |matrix |32883 |48 |2022-05-12 10:58:14 | +|intensity |intensity |assay |intensity_orig |matrix |32883 |48 |2022-05-12 10:58:14 | +|design_orig |design_orig |meta | |data.frame |48 |10 |2022-05-12 10:58:14 | +|design |design |col |design_orig |data.frame |48 |10 |2022-05-12 10:58:14 | +|metaboliteData_orig |metaboliteData_orig |meta | |data.frame |32883 |8 |2022-05-12 10:58:14 | +|metaboliteData |metaboliteData |row |metaboliteData_orig |data.frame |32883 |8 |2022-05-12 10:58:14 | There are simple dimension-based criteria to determine the basetype of a new datatype.