From de2265e35da1928873b2f0e7e6dc54f7f9c29566 Mon Sep 17 00:00:00 2001 From: Michal Stolarczyk Date: Fri, 25 Jan 2019 13:00:32 -0500 Subject: [PATCH 01/17] complete BiocProject concept redesign: - it is no longer a class - requires Annotated objects to be returned by the BiocProject function - implements additional methods for the Annotated class --- NAMESPACE | 10 +-- R/class.R | 24 ------ R/methods.R | 208 ++++++++++++++++++++++++---------------------------- R/utils.R | 2 +- 4 files changed, 100 insertions(+), 144 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index e4d4e69..413d238 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,9 +1,9 @@ # Generated by roxygen2: do not edit by hand export(BiocProject) -export(getData) -export(toProject) +export(insertPEP) exportClasses(BiocProject) -exportMethods(getData) -exportMethods(initialize) -exportMethods(toProject) +exportMethods(config) +exportMethods(getProject) +exportMethods(is.Project) +exportMethods(samples) diff --git a/R/class.R b/R/class.R index bd437ac..9c05168 100644 --- a/R/class.R +++ b/R/class.R @@ -79,27 +79,3 @@ setClass("BiocProject", #' @seealso \url{https://pepkit.github.io/} #' #' @export BiocProject -BiocProject <- - function(file = NULL, - subproject = NULL, - autoLoad = TRUE, - func = NULL, - funcArgs = NULL) { - if (!is.logical(autoLoad)) - stop("The autoLoad argument is not logical.") - if (!is.null(funcArgs)){ - if(!is.list(funcArgs)) - stop("The funcArgs has to be a named list") - if (length(funcArgs) > 0 && is.null(names(funcArgs))) - stop("The funcArgs has to be a named list") - } - - methods::new( - "BiocProject", - file = file, - subproject = subproject, - func = func, - funcArgs = funcArgs, - autoLoad = autoLoad - ) - } diff --git a/R/methods.R b/R/methods.R index c9bde5d..b05f8eb 100644 --- a/R/methods.R +++ b/R/methods.R @@ -1,15 +1,85 @@ +setGeneric("is.Project", function(.Object) + standardGeneric("is.Project")) +#' @export +setMethod("is.Project","Annotated",function(.Object){ + mData = metadata(.Object) + result = tryCatch(expr = { + mData[[1]] + }, error = function(e){ + FALSE + }) + is(result,"Project") +}) + +setGeneric("getProject", function(.Object) + standardGeneric("getProject")) +#' @export +setMethod("getProject","Annotated",function(.Object){ + if(is.Project(.Object)) { + metadata(.Object)[[1]] + } else { + stop("This object does not have PEP in the metadata slot.") + } +}) #' @export setMethod( - f = "initialize", - signature = "BiocProject", - definition = function(.Object, autoLoad, func, funcArgs, ...) { - .Object = do.call(selectMethod("initialize", signature="Project"), - list(.Object, ...)) - + f = "samples", + signature = "Annotated", + definition = function(object) { + samples(getProject(object)) + }) + + +#' @export +setMethod( + f = "config", + signature = "Annotated", + definition = function(object) { + config(getProject(object)) + }) + +setGeneric("insertPEP",function(.Object, p) + standardGeneric("insertPEP")) + +#' @export +insertPEP = function(object, p) { + if(is(object, "Annotated")){ + metadata(object) = list(PEP=p) + object + }else{ + warning("The 'object' argument has to be of class 'Annotated', got '", class(object),"'.") + } +} + +#' @export +# setMethod( +# f = "getSubsample", +# signature = signature( +# .Object = "Annotated", +# sampleName = "character", +# subsampleName = "character" +# ), +# definition = function(.Object, sampleName, subsampleName) { +# if (!is.null(.Object@metadata$PEP) & +# methods::is(object@metadata$PEP, "Project")) { +# ret = pepr::getSubsample( +# .Object = .Object@metadata$PEP, +# sampleName = sampleName, +# subsampleName = subsampleName +# ) +# return(ret) +# } else{ +# return() +# } +# } +# ) + +BiocProject = function(config, autoLoad = T, func = NULL, funcArgs = NULL, ...) { + p = pepr::Project(file = config, ...) # prevent PEP (Project object) input. This prevents BiocProject object # failing when the user provides the Project object if(is.null(funcArgs)){ @@ -21,14 +91,13 @@ setMethod( if (any(pepArgs)) funcArgs = funcArgs[-which(pepArgs)] } - args = append(list(.Object), funcArgs) + args = append(list(p), funcArgs) if (!is.null(func)) { # use the anonymous function if provided if (is.function(func)) { - readData = .callBiocFun(func, list(.Object)) - .Object[[length(.Object)+1]] = readData - return(.Object) + readData = .callBiocFun(func, list(p)) + return(insertPEP(readData, p)) } else{ stop("The anonymous function you provided is invalid.") } @@ -36,40 +105,38 @@ setMethod( # use config to find it if (autoLoad) { # check if the config consists of bioconductor section - if(is.null(pepr::config(.Object)$bioconductor)){ + if(is.null(pepr::config(p)$bioconductor)){ warning("The config YAML is missing the bioconductor section.") - message("No data was read. Creating an empty BiocProject object...") - return(.Object) + message("No data was read. Returning a Project object") + return(p) } - funcName = pepr::config(.Object)$bioconductor$read_fun_name + funcName = pepr::config(p)$bioconductor$read_fun_name # check if the function name was provided # and if it exists in the environment if (!is.null(funcName) && exists(funcName)) { # function from config.yaml in environment readData = .callBiocFun(funcName, args) - .Object[[length(.Object)+1]] = readData message("Used function ", funcName, " from the environment") - return(.Object) + return(insertPEP(readData, p)) } else{ if (!is.null(funcName) && length(grep("(\\:){2,3}", funcName)) != 0) { - # trying to access the function from the namespace that + # trying to access the function from the namespace that # was specified in the config.yaml read_fun_name splitted = strsplit(funcName, ":")[[1]] nonEmpty = splitted[which(splitted != "")] funcName = getFromNamespace(x=nonEmpty[2], ns=nonEmpty[1]) readData = .callBiocFun(funcName, args) - .Object[[length(.Object)+1]] = readData message("Used function ", funcName, " from the environment") - return(.Object) + return(insertPEP(readData, p)) } # function from config.yaml in read_fun_name not in environment, # trying to source the file specified in # the config.yaml read_fun_path funcPath = - pepr::.expandPath(pepr::config(.Object)$bioconductor$read_fun_path) + pepr::.expandPath(pepr::config(p)$bioconductor$read_fun_path) if (!is.null(funcPath)){ if (!file.exists(funcPath)) - funcPath = .makeAbsPath(funcPath,dirname(.Object@file)) + funcPath = .makeAbsPath(funcPath,dirname(p@file)) if(!file.exists(funcPath)) stop( "The function does not exist in the environment and file ", @@ -79,103 +146,16 @@ setMethod( readFun = source(funcPath)$value message("Function read from file: ", funcPath) readData = .callBiocFun(readFun, args) - .Object[[length(.Object)+1]] = readData - return(.Object) + return(insertPEP(readData, p)) }else{ warning("Can't find function in the environment and the value for read_fun_path key was not provided in the config YAML.") - message("No data was read. Creating an empty BiocProject object...") - return(.Object) + message("No data was read. Returning a Project object") + return(p) } } } else{ - message("No data was read. Creating an empty BiocProject object...") - return(.Object) + message("No data was read. Returning a Project object") + return(p) } } - } -) - -setMethod( - f = "show", - signature = "BiocProject", - definition = function(object) { - cat("data:\n") - cat("BiocProject object. Class: ", class(object), fill=T) - cat(" length: ", length(object), fill=T) - cat("\nmetadata:\n") - do.call(selectMethod("show", signature="Project"), - list(object)) - } -) - -#' Get \code{\link[pepr]{Project-class}} object -#' -#' This method coerces the \code{\link{BiocProject-class}} -#' to \code{\link{Project-class}} -#' -#' @param .Object an object of \code{\link{BiocProject-class}} -#' @param subproject a character with the name of the subproject -#' that should be activated during the converstion -#' to the \code{\link[pepr]{Project-class}} object (optional) -#' -#' @return an object of \code{\link[pepr]{Project-class}} object -#' -#' -#' @examples -#' ProjectConfig = system.file( -#' "extdata", -#' "example_peps-master", -#' "example_BiocProject", -#' "project_config.yaml", -#' package = "BiocProject" -#' ) -#' -#' bp = BiocProject(file=ProjectConfig) -#' toProject(bp) -#' -#' @export -setGeneric("toProject", function(.Object,subproject=NULL) - standardGeneric("toProject")) - -#' @export -setMethod( - f = "toProject", - signature = "BiocProject", - definition = function(.Object,subproject) { - pepr::Project(file=.Object@file,subproject=subproject) - } -) - - -#' Extract data from \code{\link{BiocProject-class}} objects -#' -#' This method extracts the data from \code{\link{BiocProject-class}} objects -#' -#' @param .Object an object of \code{\link{BiocProject-class}} -#' -#' @return a list with the data elements -#' -#' @examples -#' ProjectConfig = system.file( -#' "extdata", -#' "example_peps-master", -#' "example_BiocProject", -#' "project_config.yaml", -#' package = "BiocProject" -#' ) -#' -#' bp = BiocProject(file=ProjectConfig) -#' getData(bp) -#' -#' @export -setGeneric("getData", function(.Object) - standardGeneric("getData")) - -#' @export -setMethod( - f = "getData", - signature = "BiocProject", - definition = function(.Object) { - return(.Object@.Data) - } -) \ No newline at end of file +} \ No newline at end of file diff --git a/R/utils.R b/R/utils.R index f4a7be0..9017839 100644 --- a/R/utils.R +++ b/R/utils.R @@ -33,7 +33,7 @@ eHandler <- function(e){ # error handler .wrapFunMessages(e$message,"error") - message("No data was read. Creating an empty BiocProject object...") + message("No data was read.") message("The error message was saved in the .Data slot.") e$message } From 473f4f7b15b3311495d5f99f2cc6c0c95df8b420 Mon Sep 17 00:00:00 2001 From: Michal Stolarczyk Date: Fri, 25 Jan 2019 13:03:02 -0500 Subject: [PATCH 02/17] update changelog, delete files --- man/getData.Rd | 30 ------------------------------ man/toProject.Rd | 35 ----------------------------------- 2 files changed, 65 deletions(-) delete mode 100644 man/getData.Rd delete mode 100644 man/toProject.Rd diff --git a/man/getData.Rd b/man/getData.Rd deleted file mode 100644 index 4770dcf..0000000 --- a/man/getData.Rd +++ /dev/null @@ -1,30 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/methods.R -\name{getData} -\alias{getData} -\title{Extract data from \code{\link{BiocProject-class}} objects} -\usage{ -getData(.Object) -} -\arguments{ -\item{.Object}{an object of \code{\link{BiocProject-class}}} -} -\value{ -a list with the data elements -} -\description{ -This method extracts the data from \code{\link{BiocProject-class}} objects -} -\examples{ -ProjectConfig = system.file( -"extdata", -"example_peps-master", -"example_BiocProject", -"project_config.yaml", -package = "BiocProject" -) - -bp = BiocProject(file=ProjectConfig) -getData(bp) - -} diff --git a/man/toProject.Rd b/man/toProject.Rd deleted file mode 100644 index 753258b..0000000 --- a/man/toProject.Rd +++ /dev/null @@ -1,35 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/methods.R -\name{toProject} -\alias{toProject} -\title{Get \code{\link[pepr]{Project-class}} object} -\usage{ -toProject(.Object, subproject = NULL) -} -\arguments{ -\item{.Object}{an object of \code{\link{BiocProject-class}}} - -\item{subproject}{a character with the name of the subproject -that should be activated during the converstion -to the \code{\link[pepr]{Project-class}} object (optional)} -} -\value{ -an object of \code{\link[pepr]{Project-class}} object -} -\description{ -This method coerces the \code{\link{BiocProject-class}} - to \code{\link{Project-class}} -} -\examples{ -ProjectConfig = system.file( -"extdata", -"example_peps-master", -"example_BiocProject", -"project_config.yaml", -package = "BiocProject" -) - -bp = BiocProject(file=ProjectConfig) -toProject(bp) - -} From 99e07f140436a077d8e4f51a598aac7585f0c8a5 Mon Sep 17 00:00:00 2001 From: Michal Stolarczyk Date: Fri, 25 Jan 2019 13:05:45 -0500 Subject: [PATCH 03/17] update changelog --- NEWS.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/NEWS.md b/NEWS.md index b0c921b..116df2d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,15 @@ +# BiocProject 0.0.5 + +## Unreleased + +## Added + +* methods: `is.Project`, `samples`, `config` for signiture `Annotated` and functions: `insertPEP` and `BiocProject` (the workhorse of the package) + +## Changed + +* **complete concept redesign**: no `BiocProject` class. The objects returned by the custom data reading function have to be of class `Annotated` and the `PEP` is inserted as the first element of its `metadata()` list + # BiocProject 0.0.4 ## 2019-01-25 From d1af128f4bcec0fd4ae327be754e1808659229e6 Mon Sep 17 00:00:00 2001 From: Michal Stolarczyk Date: Fri, 25 Jan 2019 14:34:47 -0500 Subject: [PATCH 04/17] further work on redesign, change filenames --- NAMESPACE | 1 - R/class.R | 81 --------- R/methods.R | 161 ------------------ R/utils.R | 3 +- .../example_BiocProject/readBedFiles.R | 4 +- .../example_BiocProject/readBedFiles_resize.R | 4 +- .../readBedFilesExceptions.R | 3 +- man/BiocProject-class.Rd | 29 ---- man/BiocProject.Rd | 21 +-- 9 files changed, 19 insertions(+), 288 deletions(-) delete mode 100644 R/class.R delete mode 100644 R/methods.R delete mode 100644 man/BiocProject-class.Rd diff --git a/NAMESPACE b/NAMESPACE index 413d238..0aeca08 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -2,7 +2,6 @@ export(BiocProject) export(insertPEP) -exportClasses(BiocProject) exportMethods(config) exportMethods(getProject) exportMethods(is.Project) diff --git a/R/class.R b/R/class.R deleted file mode 100644 index 9c05168..0000000 --- a/R/class.R +++ /dev/null @@ -1,81 +0,0 @@ - - - - -#' Portable Encapsulated Project (PEP) class for biological applications -#' -#' This class provides a link between PEP and biological data structures. -#' -#' Thi class can be created with the constructor: \code{\link{BiocProject}} -#' -#' @slot .Data a list with the data. Can be extracted with \code{\link{getData}} -#' @slot file character vector path to config file on disk. -#' @slot samples a data table object holding the sample metadata. -#' Can be extracted with \code{\link[pepr]{samples}} -#' @slot config a list object holding contents of the config file. -#' Can be extracted with \code{\link[pepr]{config}} -#' -#' @seealso \url{https://pepkit.github.io/} -#' -#' @exportClass BiocProject -setClass("BiocProject", - contains = c("list", "Project")) - -#' Portable Encapsulated Project (PEP) class for biological applications -#' -#' This is a helper that creates the \code{\link{BiocProject-class}} object -#' -#' This \code{\link{BiocProject-class}} object constructor provides some level -#' of flexibility in your custom data processing function usage and -#' implementation. Consider the possibilities listed below: -#' \itemize{ -#' \item use a function loaded into the \code{R} environment and specified in -#' the config slot in \code{\link[pepr]{Project}} -#' (specifically: \code{config(project)$bioconductor$read_fun_name}). -#' \item use a function \emph{not} loaded into the \code{R} environment and specified in -#' the config slot in \code{\link[pepr]{Project}} -#' (specifically: \code{config(project)$bioconductor$read_fun_path}). -#' \item use a function from other \code{R} package not loaded into -#' the \code{R} environment and specified in the config slot -#' in \code{\link[pepr]{Project}} -#' (specifically: \code{config(project)$bioconductor$read_fun_name}), like: -#' \code{pkgName::functionName} -#' \item use a function implemented in the \code{\link{BiocProject}} -#' call (passed to the \code{func} argument - anonymous function). This option is given the top priority and overrides -#' other arguments if provided. -#' } -#' The custom data processing function must take -#' the \code{\link[pepr]{Project-class}} as an argument since this object will -#' be passed to the function by default. However, if the function requires -#' addtional arguments, ones can be provided with the \code{funcArgs} argument -#' in the \code{\link{BiocProject}} function call. -#' Besides, the \code{func} argument with the anonymous function may serve similar -#' possibility. -#' -#' If the \code{autoLoad} is set to \code{FALSE} the data will not be loaded -#' and empty \code{\link{BiocProject-class}} object will be returned. -#' -#' -#' @section Further reading: -#' Browse the -#' \href{http://code.databio.org/BiocProject/articles/index.html}{\code{BiocProject} package vignettes} -#' for more detailed explanation with examples. -#' -#' -#' @param file a character vector with a path to the config file -#' @param subproject a character vector with a name of the subproject -#' to be activated -#' @param func a anonymous function that reads and/or processess the data, it must take -#' the \code{\link[pepr]{Project-class}} as an argument. -#' See \code{Details} for more information -#' @param funcArgs a named list with arguments you want to pass to the \code{func}. -#' The PEP will be passed automatically, -#' but if provided regardless, the constructor will disregard it -#' @param autoLoad a logical indicating whether the data should be loaded -#' automatically. See \code{Details} for more information. -#' -#' @return an object of \code{\link{BiocProject-class}} -#' -#' @seealso \url{https://pepkit.github.io/} -#' -#' @export BiocProject diff --git a/R/methods.R b/R/methods.R deleted file mode 100644 index b05f8eb..0000000 --- a/R/methods.R +++ /dev/null @@ -1,161 +0,0 @@ - -setGeneric("is.Project", function(.Object) - standardGeneric("is.Project")) - -#' @export -setMethod("is.Project","Annotated",function(.Object){ - mData = metadata(.Object) - result = tryCatch(expr = { - mData[[1]] - }, error = function(e){ - FALSE - }) - is(result,"Project") -}) - -setGeneric("getProject", function(.Object) - standardGeneric("getProject")) - -#' @export -setMethod("getProject","Annotated",function(.Object){ - if(is.Project(.Object)) { - metadata(.Object)[[1]] - } else { - stop("This object does not have PEP in the metadata slot.") - } -}) - -#' @export -setMethod( - f = "samples", - signature = "Annotated", - definition = function(object) { - samples(getProject(object)) - }) - - -#' @export -setMethod( - f = "config", - signature = "Annotated", - definition = function(object) { - config(getProject(object)) - }) - -setGeneric("insertPEP",function(.Object, p) - standardGeneric("insertPEP")) - -#' @export -insertPEP = function(object, p) { - if(is(object, "Annotated")){ - metadata(object) = list(PEP=p) - object - }else{ - warning("The 'object' argument has to be of class 'Annotated', got '", class(object),"'.") - } -} - -#' @export -# setMethod( -# f = "getSubsample", -# signature = signature( -# .Object = "Annotated", -# sampleName = "character", -# subsampleName = "character" -# ), -# definition = function(.Object, sampleName, subsampleName) { -# if (!is.null(.Object@metadata$PEP) & -# methods::is(object@metadata$PEP, "Project")) { -# ret = pepr::getSubsample( -# .Object = .Object@metadata$PEP, -# sampleName = sampleName, -# subsampleName = subsampleName -# ) -# return(ret) -# } else{ -# return() -# } -# } -# ) - -BiocProject = function(config, autoLoad = T, func = NULL, funcArgs = NULL, ...) { - p = pepr::Project(file = config, ...) - # prevent PEP (Project object) input. This prevents BiocProject object - # failing when the user provides the Project object - if(is.null(funcArgs)){ - funcArgs = list() - }else{ - pepArgs = as.logical(lapply(funcArgs, function(x) { - is(x, "Project") - })) - if (any(pepArgs)) - funcArgs = funcArgs[-which(pepArgs)] - } - args = append(list(p), funcArgs) - - if (!is.null(func)) { - # use the anonymous function if provided - if (is.function(func)) { - readData = .callBiocFun(func, list(p)) - return(insertPEP(readData, p)) - } else{ - stop("The anonymous function you provided is invalid.") - } - } else{ - # use config to find it - if (autoLoad) { - # check if the config consists of bioconductor section - if(is.null(pepr::config(p)$bioconductor)){ - warning("The config YAML is missing the bioconductor section.") - message("No data was read. Returning a Project object") - return(p) - } - funcName = pepr::config(p)$bioconductor$read_fun_name - # check if the function name was provided - # and if it exists in the environment - if (!is.null(funcName) && exists(funcName)) { - # function from config.yaml in environment - readData = .callBiocFun(funcName, args) - message("Used function ", funcName, " from the environment") - return(insertPEP(readData, p)) - } else{ - if (!is.null(funcName) && length(grep("(\\:){2,3}", funcName)) != 0) { - # trying to access the function from the namespace that - # was specified in the config.yaml read_fun_name - splitted = strsplit(funcName, ":")[[1]] - nonEmpty = splitted[which(splitted != "")] - funcName = getFromNamespace(x=nonEmpty[2], ns=nonEmpty[1]) - readData = .callBiocFun(funcName, args) - message("Used function ", funcName, " from the environment") - return(insertPEP(readData, p)) - } - # function from config.yaml in read_fun_name not in environment, - # trying to source the file specified in - # the config.yaml read_fun_path - funcPath = - pepr::.expandPath(pepr::config(p)$bioconductor$read_fun_path) - if (!is.null(funcPath)){ - if (!file.exists(funcPath)) - funcPath = .makeAbsPath(funcPath,dirname(p@file)) - if(!file.exists(funcPath)) - stop( - "The function does not exist in the environment and file ", - funcPath, - " does not exist" - ) - readFun = source(funcPath)$value - message("Function read from file: ", funcPath) - readData = .callBiocFun(readFun, args) - return(insertPEP(readData, p)) - }else{ - warning("Can't find function in the environment and the value for read_fun_path key was not provided in the config YAML.") - message("No data was read. Returning a Project object") - return(p) - } - } - } else{ - message("No data was read. Returning a Project object") - return(p) - } - } -} \ No newline at end of file diff --git a/R/utils.R b/R/utils.R index 9017839..9c0792e 100644 --- a/R/utils.R +++ b/R/utils.R @@ -33,8 +33,7 @@ eHandler <- function(e){ # error handler .wrapFunMessages(e$message,"error") - message("No data was read.") - message("The error message was saved in the .Data slot.") + message("No data was read. The error message was returned instead.") e$message } res = withCallingHandlers(tryCatch(do.call(func, arguments), error = eHandler),warning = wHandler) diff --git a/inst/extdata/example_peps-master/example_BiocProject/readBedFiles.R b/inst/extdata/example_peps-master/example_BiocProject/readBedFiles.R index 5f83260..363c5c0 100644 --- a/inst/extdata/example_peps-master/example_BiocProject/readBedFiles.R +++ b/inst/extdata/example_peps-master/example_BiocProject/readBedFiles.R @@ -1,4 +1,5 @@ readBedFiles = function(project) { + cwd = getwd() paths = pepr::samples(project)$file_path sampleNames = pepr::samples(project)$sample_name setwd(dirname(project@file)) @@ -7,8 +8,9 @@ readBedFiles = function(project) { colnames(df) = c('chr', 'start', 'end') gr = GenomicRanges::GRanges(df) }) + setwd(cwd) names(result) = sampleNames - return(result) + return(GenomicRanges::GRangesList(result)) } diff --git a/inst/extdata/example_peps-master/example_BiocProject/readBedFiles_resize.R b/inst/extdata/example_peps-master/example_BiocProject/readBedFiles_resize.R index b77914d..12431be 100644 --- a/inst/extdata/example_peps-master/example_BiocProject/readBedFiles_resize.R +++ b/inst/extdata/example_peps-master/example_BiocProject/readBedFiles_resize.R @@ -1,4 +1,5 @@ readBedFiles_resize = function(project, resize.width) { + cwd = getwd() paths = pepr::samples(project)$file_path sampleNames = pepr::samples(project)$sample_name setwd(dirname(project@file)) @@ -7,6 +8,7 @@ readBedFiles_resize = function(project, resize.width) { colnames(df) = c('chr', 'start', 'end') gr = GenomicRanges::resize(GenomicRanges::GRanges(df), width=resize.width) }) + setwd(cwd) names(result) = sampleNames - return(result) + return(GenomicRanges::GRangesList(result)) } \ No newline at end of file diff --git a/inst/extdata/example_peps-master/example_BiocProject_exceptions/readBedFilesExceptions.R b/inst/extdata/example_peps-master/example_BiocProject_exceptions/readBedFilesExceptions.R index 9a6c1d6..8d36abe 100644 --- a/inst/extdata/example_peps-master/example_BiocProject_exceptions/readBedFilesExceptions.R +++ b/inst/extdata/example_peps-master/example_BiocProject_exceptions/readBedFilesExceptions.R @@ -11,8 +11,7 @@ readBedFilesExceptions = function(project) { gr = GenomicRanges::GRanges(df) }) names(result) = sampleNames - return(result) - + return(GenomicRanges::GRangesList(result)) } diff --git a/man/BiocProject-class.Rd b/man/BiocProject-class.Rd deleted file mode 100644 index 6a07545..0000000 --- a/man/BiocProject-class.Rd +++ /dev/null @@ -1,29 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/class.R -\docType{class} -\name{BiocProject-class} -\alias{BiocProject-class} -\title{Portable Encapsulated Project (PEP) class for biological applications} -\description{ -This class provides a link between PEP and biological data structures. -} -\details{ -Thi class can be created with the constructor: \code{\link{BiocProject}} -} -\section{Slots}{ - -\describe{ -\item{\code{.Data}}{a list with the data. Can be extracted with \code{\link{getData}}} - -\item{\code{file}}{character vector path to config file on disk.} - -\item{\code{samples}}{a data table object holding the sample metadata. -Can be extracted with \code{\link[pepr]{samples}}} - -\item{\code{config}}{a list object holding contents of the config file. -Can be extracted with \code{\link[pepr]{config}}} -}} - -\seealso{ -\url{https://pepkit.github.io/} -} diff --git a/man/BiocProject.Rd b/man/BiocProject.Rd index 281311a..aaede2c 100644 --- a/man/BiocProject.Rd +++ b/man/BiocProject.Rd @@ -1,14 +1,14 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/class.R +% Please edit documentation in R/methods.R \name{BiocProject} \alias{BiocProject} -\title{Portable Encapsulated Project (PEP) class for biological applications} +\title{Portable Encapsulated Project (PEP) for biological applications} \usage{ -BiocProject(file = NULL, subproject = NULL, autoLoad = TRUE, - func = NULL, funcArgs = NULL) +BiocProject(file, subproject = NULL, autoLoad = T, func = NULL, + funcArgs = NULL) } \arguments{ -\item{file}{a character vector with a path to the config file} +\item{file}{a character vector with a path to the PEP config file} \item{subproject}{a character vector with a name of the subproject to be activated} @@ -25,18 +25,19 @@ The PEP will be passed automatically, but if provided regardless, the constructor will disregard it} } \value{ -an object of \code{\link{BiocProject-class}} +an object of \code{\link[S4Vectors]{Annotated-class}} that is returned by the user provided function with the \code{\link[pepr]{Project-class}} object inserted into the first element of the list in its medatada slot } \description{ -This is a helper that creates the \code{\link{BiocProject-class}} object +This function creates a \code{\link[pepr]{Project-class}} object, and executes the user provided function with the created object as a first argument. +\emph{The custom data processing function has to return and object of \code{\link[S4Vectors]{Annotated-class}}, otherwise an error will be returned.} } \details{ -This \code{\link{BiocProject-class}} object constructor provides some level +This \code{\link{BiocProject}} function provides some degree of flexibility in your custom data processing function usage and implementation. Consider the possibilities listed below: \itemize{ \item use a function loaded into the \code{R} environment and specified in - the config slot in \code{\link[pepr]{Project}} + the config slot in \code{\link[pepr]{Project-class}} (specifically: \code{config(project)$bioconductor$read_fun_name}). \item use a function \emph{not} loaded into the \code{R} environment and specified in the config slot in \code{\link[pepr]{Project}} @@ -59,7 +60,7 @@ Besides, the \code{func} argument with the anonymous function may serve similar possibility. If the \code{autoLoad} is set to \code{FALSE} the data will not be loaded -and empty \code{\link{BiocProject-class}} object will be returned. +and empty \code{\link[pepr]{Project-class}} object will be returned. } \section{Further reading}{ From 14436612fcb384b7aa685733103c2d7508d9a4cf Mon Sep 17 00:00:00 2001 From: Michal Stolarczyk Date: Fri, 25 Jan 2019 14:35:55 -0500 Subject: [PATCH 05/17] add new R files --- R/functions.R | 202 ++++++++++++++++++++++++++++++++++++++++++ R/methods_Annotated.R | 42 +++++++++ 2 files changed, 244 insertions(+) create mode 100644 R/functions.R create mode 100644 R/methods_Annotated.R diff --git a/R/functions.R b/R/functions.R new file mode 100644 index 0000000..3e80d1b --- /dev/null +++ b/R/functions.R @@ -0,0 +1,202 @@ + +setGeneric("is.Project", function(.Object) + standardGeneric("is.Project")) + +#' @export +setMethod("is.Project","Annotated",function(.Object){ + mData = metadata(.Object) + result = tryCatch(expr = { + mData[[1]] + }, error = function(e){ + FALSE + }) + is(result,"Project") +}) + +setGeneric("getProject", function(.Object) + standardGeneric("getProject")) + +#' @export +setMethod("getProject","Annotated",function(.Object){ + if(is.Project(.Object)) { + metadata(.Object)[[1]] + } else { + stop("This object does not have PEP in the metadata slot.") + } +}) + +#' @export +setMethod( + f = "samples", + signature = "Annotated", + definition = function(object) { + samples(getProject(object)) + }) + + +#' @export +setMethod( + f = "config", + signature = "Annotated", + definition = function(object) { + config(getProject(object)) + }) + +#' @export +insertPEP = function(object, p) { + if(is(object, "Annotated")){ + metadata(object) = list(PEP=p) + object + }else{ + warning("The 'object' argument has to be of class 'Annotated', got '", class(object),"'.") + } +} + +#' Portable Encapsulated Project (PEP) for biological applications +#' +#' This function creates a \code{\link[pepr]{Project-class}} object, and executes the user provided function with the created object as a first argument. +#' \emph{The custom data processing function has to return and object of \code{\link[S4Vectors]{Annotated-class}}, otherwise an error will be returned.} +#' +#' This \code{\link{BiocProject}} function provides some degree +#' of flexibility in your custom data processing function usage and +#' implementation. Consider the possibilities listed below: +#' \itemize{ +#' \item use a function loaded into the \code{R} environment and specified in +#' the config slot in \code{\link[pepr]{Project-class}} +#' (specifically: \code{config(project)$bioconductor$read_fun_name}). +#' \item use a function \emph{not} loaded into the \code{R} environment and specified in +#' the config slot in \code{\link[pepr]{Project}} +#' (specifically: \code{config(project)$bioconductor$read_fun_path}). +#' \item use a function from other \code{R} package not loaded into +#' the \code{R} environment and specified in the config slot +#' in \code{\link[pepr]{Project}} +#' (specifically: \code{config(project)$bioconductor$read_fun_name}), like: +#' \code{pkgName::functionName} +#' \item use a function implemented in the \code{\link{BiocProject}} +#' call (passed to the \code{func} argument - anonymous function). This option is given the top priority and overrides +#' other arguments if provided. +#' } +#' The custom data processing function must take +#' the \code{\link[pepr]{Project-class}} as an argument since this object will +#' be passed to the function by default. However, if the function requires +#' addtional arguments, ones can be provided with the \code{funcArgs} argument +#' in the \code{\link{BiocProject}} function call. +#' Besides, the \code{func} argument with the anonymous function may serve similar +#' possibility. +#' +#' +#' If the \code{autoLoad} is set to \code{FALSE} the data will not be loaded +#' and empty \code{\link[pepr]{Project-class}} object will be returned. +#' +#' +#' @section Further reading: +#' Browse the +#' \href{http://code.databio.org/BiocProject/articles/index.html}{\code{BiocProject} package vignettes} +#' for more detailed explanation with examples. +#' +#' +#' @param file a character vector with a path to the PEP config file +#' @param subproject a character vector with a name of the subproject +#' to be activated +#' @param func a anonymous function that reads and/or processess the data, it must take +#' the \code{\link[pepr]{Project-class}} as an argument. +#' See \code{Details} for more information +#' @param funcArgs a named list with arguments you want to pass to the \code{func}. +#' The PEP will be passed automatically, +#' but if provided regardless, the constructor will disregard it +#' @param autoLoad a logical indicating whether the data should be loaded +#' automatically. See \code{Details} for more information. +#' +#' @return an object of \code{\link[S4Vectors]{Annotated-class}} that is returned by the user provided function with the \code{\link[pepr]{Project-class}} object inserted into the first element of the list in its medatada slot +#' +#' @seealso \url{https://pepkit.github.io/} +#' +#' @export BiocProject +BiocProject = function(file, subproject = NULL, autoLoad = T, func = NULL, funcArgs = NULL) { + p = tryCatch( + expr = { + pepr::Project(file = file, subproject = subproject) + },warning = function(w) { + message(w) + stop("There are warnings associated with the 'Project' object creation.") + } + ) + # prevent PEP (Project object) input. This prevents BiocProject object + # failing when the user provides the Project object + if(is.null(funcArgs)){ + funcArgs = list() + }else{ + pepArgs = as.logical(lapply(funcArgs, function(x) { + is(x, "Project") + })) + if (any(pepArgs)) + funcArgs = funcArgs[-which(pepArgs)] + } + args = append(list(p), funcArgs) + + if (!is.null(func)) { + # use the anonymous function if provided + if (is.function(func)) { + readData = .callBiocFun(func, list(p)) + return(insertPEP(readData, p)) + } else{ + stop("The anonymous function you provided is invalid.") + } + } else{ + # use config to find it + if (autoLoad) { + # check if the config consists of bioconductor section + if(is.null(pepr::config(p)$bioconductor)){ + warning("The config YAML is missing the bioconductor section.") + message("No data was read. Returning a Project object") + return(p) + } + funcName = pepr::config(p)$bioconductor$read_fun_name + # check if the function name was provided + # and if it exists in the environment + if (!is.null(funcName) && exists(funcName)) { + # function from config.yaml in environment + readData = .callBiocFun(funcName, args) + message("Used function ", funcName, " from the environment") + return(insertPEP(readData, p)) + } else{ + if (!is.null(funcName) && length(grep("(\\:){2,3}", funcName)) != 0) { + # trying to access the function from the namespace that + # was specified in the config.yaml read_fun_name + splitted = strsplit(funcName, ":")[[1]] + nonEmpty = splitted[which(splitted != "")] + funcName = getFromNamespace(x=nonEmpty[2], ns=nonEmpty[1]) + readData = .callBiocFun(funcName, args) + message("Used function ", funcName, " from the environment") + return(insertPEP(readData, p)) + } + # function from config.yaml in read_fun_name not in environment, + # trying to source the file specified in + # the config.yaml read_fun_path + funcPath = + pepr::.expandPath(pepr::config(p)$bioconductor$read_fun_path) + if (!is.null(funcPath)){ + if (!file.exists(funcPath)) + funcPath = .makeAbsPath(funcPath,dirname(p@file)) + if(!file.exists(funcPath)) + stop( + "The function does not exist in the environment and file ", + funcPath, + " does not exist" + ) + readFun = source(funcPath)$value + message("Function read from file: ", funcPath) + readData = .callBiocFun(readFun, args) + return(insertPEP(readData, p)) + }else{ + warning("Can't find function in the environment and the value for read_fun_path key was not provided in the config YAML.") + message("No data was read. Returning a Project object") + return(p) + } + } + } else{ + message("No data was read. Returning a Project object") + return(p) + } + } +} diff --git a/R/methods_Annotated.R b/R/methods_Annotated.R new file mode 100644 index 0000000..b9a24e8 --- /dev/null +++ b/R/methods_Annotated.R @@ -0,0 +1,42 @@ +setGeneric("is.Project", function(.Object) + standardGeneric("is.Project")) + +#' @export +setMethod("is.Project","Annotated",function(.Object){ + mData = metadata(.Object) + result = tryCatch(expr = { + mData[[1]] + }, error = function(e){ + FALSE + }) + is(result,"Project") +}) + +setGeneric("getProject", function(.Object) + standardGeneric("getProject")) + +#' @export +setMethod("getProject","Annotated",function(.Object){ + if(is.Project(.Object)) { + metadata(.Object)[[1]] + } else { + stop("This object does not have PEP in the metadata slot.") + } +}) + +#' @export +setMethod( + f = "samples", + signature = "Annotated", + definition = function(object) { + samples(getProject(object)) + }) + + +#' @export +setMethod( + f = "config", + signature = "Annotated", + definition = function(object) { + config(getProject(object)) + }) From 83cdc17080b58ea266c894fc0086e3223aa6d3ff Mon Sep 17 00:00:00 2001 From: Michal Stolarczyk Date: Fri, 25 Jan 2019 16:48:07 -0500 Subject: [PATCH 06/17] add is method for Annotated --- R/functions.R | 55 +------------------------------------------ R/methods_Annotated.R | 9 +++++++ 2 files changed, 10 insertions(+), 54 deletions(-) diff --git a/R/functions.R b/R/functions.R index 3e80d1b..97efd20 100644 --- a/R/functions.R +++ b/R/functions.R @@ -1,61 +1,8 @@ -setGeneric("is.Project", function(.Object) - standardGeneric("is.Project")) - -#' @export -setMethod("is.Project","Annotated",function(.Object){ - mData = metadata(.Object) - result = tryCatch(expr = { - mData[[1]] - }, error = function(e){ - FALSE - }) - is(result,"Project") -}) - -setGeneric("getProject", function(.Object) - standardGeneric("getProject")) - -#' @export -setMethod("getProject","Annotated",function(.Object){ - if(is.Project(.Object)) { - metadata(.Object)[[1]] - } else { - stop("This object does not have PEP in the metadata slot.") - } -}) - -#' @export -setMethod( - f = "samples", - signature = "Annotated", - definition = function(object) { - samples(getProject(object)) - }) - - -#' @export -setMethod( - f = "config", - signature = "Annotated", - definition = function(object) { - config(getProject(object)) - }) - -#' @export -insertPEP = function(object, p) { - if(is(object, "Annotated")){ - metadata(object) = list(PEP=p) - object - }else{ - warning("The 'object' argument has to be of class 'Annotated', got '", class(object),"'.") - } -} - #' Portable Encapsulated Project (PEP) for biological applications #' #' This function creates a \code{\link[pepr]{Project-class}} object, and executes the user provided function with the created object as a first argument. -#' \emph{The custom data processing function has to return and object of \code{\link[S4Vectors]{Annotated-class}}, otherwise an error will be returned.} +#' \cr\cr\emph{The custom data processing function has to return and object of \code{\link[S4Vectors]{Annotated-class}}, otherwise an error will be returned.} #' #' This \code{\link{BiocProject}} function provides some degree #' of flexibility in your custom data processing function usage and diff --git a/R/methods_Annotated.R b/R/methods_Annotated.R index b9a24e8..222c774 100644 --- a/R/methods_Annotated.R +++ b/R/methods_Annotated.R @@ -40,3 +40,12 @@ setMethod( definition = function(object) { config(getProject(object)) }) + +#' @export +setMethod("is", "Annotated", definition = function(object, class2){ + if(class2=="Project" & is.Project(object)){ + TRUE + } else { + extends(class(object), class2) + } +}) From e758a0ef21cf1435427fb38b13b1a24b61ab90c5 Mon Sep 17 00:00:00 2001 From: Michal Stolarczyk Date: Fri, 25 Jan 2019 17:23:16 -0500 Subject: [PATCH 07/17] change methods names, add .insertPEP fun --- NAMESPACE | 3 +-- R/functions.R | 18 ++++++++++++++---- R/methods_Annotated.R | 13 +++++++------ man/BiocProject.Rd | 4 ++-- vignettes/1getStarted.Rmd | 35 ++++++++++++++--------------------- 5 files changed, 38 insertions(+), 35 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 0aeca08..b2da0ad 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,8 +1,7 @@ # Generated by roxygen2: do not edit by hand export(BiocProject) -export(insertPEP) exportMethods(config) exportMethods(getProject) -exportMethods(is.Project) +exportMethods(is) exportMethods(samples) diff --git a/R/functions.R b/R/functions.R index 97efd20..7597d21 100644 --- a/R/functions.R +++ b/R/functions.R @@ -85,7 +85,7 @@ BiocProject = function(file, subproject = NULL, autoLoad = T, func = NULL, funcA # use the anonymous function if provided if (is.function(func)) { readData = .callBiocFun(func, list(p)) - return(insertPEP(readData, p)) + return(.insertPEP(readData, p)) } else{ stop("The anonymous function you provided is invalid.") } @@ -105,7 +105,7 @@ BiocProject = function(file, subproject = NULL, autoLoad = T, func = NULL, funcA # function from config.yaml in environment readData = .callBiocFun(funcName, args) message("Used function ", funcName, " from the environment") - return(insertPEP(readData, p)) + return(.insertPEP(readData, p)) } else{ if (!is.null(funcName) && length(grep("(\\:){2,3}", funcName)) != 0) { # trying to access the function from the namespace that @@ -115,7 +115,7 @@ BiocProject = function(file, subproject = NULL, autoLoad = T, func = NULL, funcA funcName = getFromNamespace(x=nonEmpty[2], ns=nonEmpty[1]) readData = .callBiocFun(funcName, args) message("Used function ", funcName, " from the environment") - return(insertPEP(readData, p)) + return(.insertPEP(readData, p)) } # function from config.yaml in read_fun_name not in environment, # trying to source the file specified in @@ -134,7 +134,7 @@ BiocProject = function(file, subproject = NULL, autoLoad = T, func = NULL, funcA readFun = source(funcPath)$value message("Function read from file: ", funcPath) readData = .callBiocFun(readFun, args) - return(insertPEP(readData, p)) + return(.insertPEP(readData, p)) }else{ warning("Can't find function in the environment and the value for read_fun_path key was not provided in the config YAML.") message("No data was read. Returning a Project object") @@ -147,3 +147,13 @@ BiocProject = function(file, subproject = NULL, autoLoad = T, func = NULL, funcA } } } + + +.insertPEP = function(object, pep) { + if(is(object, "Annotated") & is(pep, "Project")){ + metadata(object) = list(PEP=pep) + object + }else{ + stop("Type error: The 'object' argument has to be of class 'Annotated', got '", class(object),"'. And the pep argument has to be of class 'Project', got '", class(pep),"'") + } +} diff --git a/R/methods_Annotated.R b/R/methods_Annotated.R index 222c774..f262d37 100644 --- a/R/methods_Annotated.R +++ b/R/methods_Annotated.R @@ -1,8 +1,7 @@ -setGeneric("is.Project", function(.Object) - standardGeneric("is.Project")) +setGeneric(".is.project", function(.Object) + standardGeneric(".is.project")) -#' @export -setMethod("is.Project","Annotated",function(.Object){ +setMethod(".is.project","Annotated",function(.Object){ mData = metadata(.Object) result = tryCatch(expr = { mData[[1]] @@ -32,7 +31,6 @@ setMethod( samples(getProject(object)) }) - #' @export setMethod( f = "config", @@ -41,11 +39,14 @@ setMethod( config(getProject(object)) }) +setGeneric("is", package = "methods") + #' @export setMethod("is", "Annotated", definition = function(object, class2){ - if(class2=="Project" & is.Project(object)){ + if(class2=="Project" & .is.project(object)){ TRUE } else { extends(class(object), class2) } }) + diff --git a/man/BiocProject.Rd b/man/BiocProject.Rd index aaede2c..c687196 100644 --- a/man/BiocProject.Rd +++ b/man/BiocProject.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/methods.R +% Please edit documentation in R/functions.R \name{BiocProject} \alias{BiocProject} \title{Portable Encapsulated Project (PEP) for biological applications} @@ -29,7 +29,7 @@ an object of \code{\link[S4Vectors]{Annotated-class}} that is returned by the us } \description{ This function creates a \code{\link[pepr]{Project-class}} object, and executes the user provided function with the created object as a first argument. -\emph{The custom data processing function has to return and object of \code{\link[S4Vectors]{Annotated-class}}, otherwise an error will be returned.} +\cr\cr\emph{The custom data processing function has to return and object of \code{\link[S4Vectors]{Annotated-class}}, otherwise an error will be returned.} } \details{ This \code{\link{BiocProject}} function provides some degree diff --git a/vignettes/1getStarted.Rmd b/vignettes/1getStarted.Rmd index c8d752f..d47ac5c 100644 --- a/vignettes/1getStarted.Rmd +++ b/vignettes/1getStarted.Rmd @@ -18,11 +18,13 @@ knitr::opts_chunk$set( # Introduction -`BiocProject` is a (pending) [Bioconductor](https://www.bioconductor.org/) package that provides a class (also called `BiocProject`) that holds both metadata and data for set of biological samples. +`BiocProject` is a (pending) [Bioconductor](https://www.bioconductor.org/) package that provides a way to use Portable Encapsulated Projects (PEPs) within Bioconductor framework. -This vignette assumes you are already familiar with Portable Encapsulated Projects (PEPs). If not, see [pepkit.github.io](https://pepkit.github.io/) to learn more about PEP, and the [pepr documentation](http://code.databio.org/pepr/) to learn more about reading PEPs in `R`. +This vignette assumes you are already familiar with PEPs. If not, see [pepkit.github.io](https://pepkit.github.io/) to learn more about PEP, and the [pepr documentation](http://code.databio.org/pepr/) to learn more about reading PEPs in `R`. -`BiocProject` uses `pepr` to handle PEP metadata, and allows you to provide a data loading function so that you can load both project metadata and data for an entire project with a single line of R code. +`BiocProject` uses `pepr` to handle PEP metadata, and allows you to provide a data loading/processing function so that you can load both project metadata and data for an entire project with a single line of R code. + +The output of the `BiocProject` function is the object that your function returns, but enriched with the PEP in its `metadata` slot. This way of storage is uniform across all objects withib Bioconductor project (see: `?Annotated-class` for details). # Installation @@ -104,7 +106,7 @@ get(config(bp)$bioconductor$read_fun_name) And that's all there is to it! This PEP consists really of 3 components: the project configuration file, which points to an annotation sheet, and an R file that holds a function that knows how to process this data. With that, we're ready to see how `BiocProject` works. -## How to create a `BiocProject` object +## How to use the `BiocProject` function With a PEP in hand, it takes only a single line of code to do all the magic with `BiocProject`: @@ -112,34 +114,28 @@ With a PEP in hand, it takes only a single line of code to do all the magic with bp = BiocProject(file=configFile) ``` -This loads the project metadata from the PEP, then loads and calls the actual data processing function, and returns a complete R object that contains all your project metadata and data! Therefore, the created object is composed of both the metadata (`pepr::Project` object) and data loaded with your function. Let's inspect the object: +This loads the project metadata from the PEP, then loads and calls the actual data processing function, and returns a the R object that the data processing function produces but enriched with the PEP metadata. Consequently, the object contains all your project metadata and data! Let's inspect the it: ```{r} bp ``` -## How to interact with a `BiocProject` object +Since the data processing function returned `GenomicRanges::GRangesList` object, the final result of the `BiocProject` function is an object of the same class. + +## How to interact with the created object -The `BiocProject` object provides all the `pepr::Project` methods (which you can find in the [reference documentation for pepr](http://code.databio.org/pepr/reference/index.html)). +The created object provides all the `pepr::Project` methods (which you can find in the [reference documentation for pepr](http://code.databio.org/pepr/reference/index.html)). ```{r} samples(bp) config(bp) ``` -In addition. the `BiocProject` is of class `list`, so you can apply `list` methods to interact with the loaded data: - -```{r} -names(bp) = c("myDataset") -names(bp) -bp[[1]] -``` - Finally, there are a few methods specific to `BiocProject` objects: ```{r} -getData(bp) -toProject(bp) +getProject(bp) +is.Project(bp) ``` # How to provide a data load function @@ -196,10 +192,7 @@ configFile = system.file( bpExceptions = BiocProject(configFile) ``` -In case an error is caught, the erorr message is preserved and stored in the `.Data` slot of the `BiocProject` object, so it can be accessed the regular way: -```{r} -getData(bpExceptions) -``` + # Further reading See this [More arguments than just a PEP in your function?](./2multipleArguments.html) vignette if you want to: From 1839abb5d5204d22d5e002a67a4d7af11d320570 Mon Sep 17 00:00:00 2001 From: Michal Stolarczyk Date: Sun, 27 Jan 2019 14:30:58 -0500 Subject: [PATCH 08/17] update basic vignette --- R/methods_Annotated.R | 2 +- R/utils.R | 2 +- vignettes/1getStarted.Rmd | 36 ++++++++++++++++++++++++------------ 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/R/methods_Annotated.R b/R/methods_Annotated.R index f262d37..8892c7e 100644 --- a/R/methods_Annotated.R +++ b/R/methods_Annotated.R @@ -16,7 +16,7 @@ setGeneric("getProject", function(.Object) #' @export setMethod("getProject","Annotated",function(.Object){ - if(is.Project(.Object)) { + if(.is.project(.Object)) { metadata(.Object)[[1]] } else { stop("This object does not have PEP in the metadata slot.") diff --git a/R/utils.R b/R/utils.R index 9c0792e..f69ee5b 100644 --- a/R/utils.R +++ b/R/utils.R @@ -34,7 +34,7 @@ # error handler .wrapFunMessages(e$message,"error") message("No data was read. The error message was returned instead.") - e$message + List(e$message) } res = withCallingHandlers(tryCatch(do.call(func, arguments), error = eHandler),warning = wHandler) if(length(.warnings) > 0){ diff --git a/vignettes/1getStarted.Rmd b/vignettes/1getStarted.Rmd index d47ac5c..674c6e1 100644 --- a/vignettes/1getStarted.Rmd +++ b/vignettes/1getStarted.Rmd @@ -22,9 +22,9 @@ knitr::opts_chunk$set( This vignette assumes you are already familiar with PEPs. If not, see [pepkit.github.io](https://pepkit.github.io/) to learn more about PEP, and the [pepr documentation](http://code.databio.org/pepr/) to learn more about reading PEPs in `R`. -`BiocProject` uses `pepr` to handle PEP metadata, and allows you to provide a data loading/processing function so that you can load both project metadata and data for an entire project with a single line of R code. +`BiocProject` uses objects of [`Project` class](http://code.databio.org/pepr/reference/Project-class.html) (from `pepr`) to handle your project metadata, and allows you to provide a data loading/processing function so that you can load both project metadata and data for an entire project with a **single line of `R` code**. -The output of the `BiocProject` function is the object that your function returns, but enriched with the PEP in its `metadata` slot. This way of storage is uniform across all objects withib Bioconductor project (see: `?Annotated-class` for details). +The output of the `BiocProject` function is the object that your function returns, but enriched with the PEP in its `metadata` slot. **This way of metadata storage is uniform across all objects within Bioconductor project (see: `?Annotated-class` for details).** # Installation @@ -98,13 +98,19 @@ knitr::kable(sampleAnnotationDF, format = "html") In this example, our PEP has two samples, which have two attributes: `sample_name`, and `file_path`, which points the location for the data. -The configuration file also points to a third file (``r { basename(config(bp)$bioconductor$read_fun_path) }``). This file holds a single R function called ``r { basename(config(bp)$bioconductor$read_fun_name) }``, which has these contents: +The configuration file also points to a third file (``r { basename(config(bp)$bioconductor$read_fun_path) }``). This file holds a single `R` function called ``r { basename(config(bp)$bioconductor$read_fun_name) }``, which has these contents: ```{r echo=FALSE, eval=TRUE, comment=""} get(config(bp)$bioconductor$read_fun_name) ``` -And that's all there is to it! This PEP consists really of 3 components: the project configuration file, which points to an annotation sheet, and an R file that holds a function that knows how to process this data. With that, we're ready to see how `BiocProject` works. +And that's all there is to it! **This PEP consists really of 3 components:** + +1. the project configuration file (which points to an annotation sheet and specifies your function name) +1. the annotation sheet +1. an R file that holds a function that knows how to process this data. + +With that, we're ready to see how `BiocProject` works. ## How to use the `BiocProject` function @@ -114,7 +120,7 @@ With a PEP in hand, it takes only a single line of code to do all the magic with bp = BiocProject(file=configFile) ``` -This loads the project metadata from the PEP, then loads and calls the actual data processing function, and returns a the R object that the data processing function produces but enriched with the PEP metadata. Consequently, the object contains all your project metadata and data! Let's inspect the it: +This loads the project metadata from the PEP, then loads and calls the actual data processing function, and returns the R object that the data processing function produces, but enriched with the PEP metadata. Consequently, the object contains all your project metadata and data! Let's inspect the it: ```{r} bp @@ -122,7 +128,7 @@ bp Since the data processing function returned `GenomicRanges::GRangesList` object, the final result of the `BiocProject` function is an object of the same class. -## How to interact with the created object +## How to interact with the returned object The created object provides all the `pepr::Project` methods (which you can find in the [reference documentation for pepr](http://code.databio.org/pepr/reference/index.html)). @@ -135,7 +141,6 @@ Finally, there are a few methods specific to `BiocProject` objects: ```{r} getProject(bp) -is.Project(bp) ``` # How to provide a data load function @@ -160,11 +165,18 @@ The function specified can be a data processing function of any complexity, but ### Rules: -1. must have a single argument, +1. must take at least a single argument, 1. the argument must be a [`pepr::Project`](http://code.databio.org/pepr/reference/Project-class.html) object (should use that input to load all the relevant data into `R`), -1. must return one or more data objects. +1. must return an object of class that extends the class `Annotated`. + +Listed below are some of the classes that extend the class `Annotated`: + +```{r} +showClass("Annotated") +``` + -For example, consider the [readBedFiles function](https://github.com/pepkit/example_peps/blob/master/example_BiocProject/readBedFiles.R): +Consider the [readBedFiles function](https://github.com/pepkit/example_peps/blob/master/example_BiocProject/readBedFiles.R) as an example of a function that can be used with `BiocProject` package: ```{r echo=FALSE, eval=TRUE, comment=""} processFunction = system.file( @@ -179,7 +191,7 @@ readBedFiles ``` # Data reading function error/warning handling -The `BiocProject` constructor provides a way to rigorously monitor exceptions related to your data reading function. All the produced warnings and errors are caught, processed and displayed in an organized way: +The `BiocProject` function provides a way to rigorously monitor exceptions related to your data reading function. All the produced warnings and errors are caught, processed and displayed in an organized way: ```{r} configFile = system.file( @@ -200,6 +212,6 @@ See this [More arguments than just a PEP in your function?](./2multipleArguments * use an anonymous function instead of one defined *a priori* * use a function that requires more arguments than just a PEP -See the [Working with remote data](./4remoteData.html) vignette to learn how to download the data from the Internet and store it conveniently in the `BiocProject` object. +See the [Working with remote data](./4remoteData.html) vignette to learn how to download the data from the Internet, process it and store it conveniently with related metadata in any object from the Bioconductor project. See the [Working with large datasets - simpleCache](./3simpleCache.html) vignette to learn how the `simpleCache` R package can be used to prevent copious and lengthy results recalculations when working with large datasets. \ No newline at end of file From 9d532a2209a76a06ae15eaa3c2a92d1b39a21025 Mon Sep 17 00:00:00 2001 From: Michal Stolarczyk Date: Sun, 27 Jan 2019 14:47:33 -0500 Subject: [PATCH 09/17] update all the vignettes --- vignettes/2multipleArguments.Rmd | 2 +- vignettes/4remoteData.Rmd | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/vignettes/2multipleArguments.Rmd b/vignettes/2multipleArguments.Rmd index 12139b5..a580c06 100644 --- a/vignettes/2multipleArguments.Rmd +++ b/vignettes/2multipleArguments.Rmd @@ -64,7 +64,7 @@ readBedFiles_resize = system.file( package = "BiocProject" ) ``` -Read the function into R environment and create the `BiocProject` object +Read the function into R environment and run the `BiocProject` function ```{r} source(readBedFiles_resize) bpArgs = BiocProject(file=ProjectConfigArgs, funcArgs=list(resize.width=100)) diff --git a/vignettes/4remoteData.Rmd b/vignettes/4remoteData.Rmd index 23f3821..9b0d21b 100644 --- a/vignettes/4remoteData.Rmd +++ b/vignettes/4remoteData.Rmd @@ -69,7 +69,7 @@ library(pepr) .printNestedList(yaml::read_yaml(configFile)) ``` -## Create the `BiocProject` object +## Execute the `BiocProject` function Get path to the config file ```{r echo=T,message=FALSE} @@ -93,12 +93,18 @@ With this simple line of code: 1. data were downloaded from the remote source and processed 1. everything was conveniently stored in a `BiocProject` object -Let's inspect the results +Let's inspect the results: ```{r} -getData(bpRemote) +bpRemote +``` +And the metadata +```{r} +metadata(bpRemote) samples(bpRemote) config(bpRemote) ``` - - +The function that was used to download and process the data: +```{r echo=FALSE, eval=TRUE, comment=""} +get(config(bpRemote)$bioconductor$read_fun_name) +``` \ No newline at end of file From cfa0585b07f6311708fba22a35e1dee156118af6 Mon Sep 17 00:00:00 2001 From: Michal Stolarczyk Date: Sun, 27 Jan 2019 15:28:12 -0500 Subject: [PATCH 10/17] update documentation --- man/config-Annotated-method.Rd | 26 ++++++++++++++++++++++++++ man/dot-insertPEP.Rd | 19 +++++++++++++++++++ man/getProject-Annotated-method.Rd | 25 +++++++++++++++++++++++++ man/is-Annotated-method.Rd | 15 +++++++++++++++ man/samples-Annotated-method.Rd | 26 ++++++++++++++++++++++++++ 5 files changed, 111 insertions(+) create mode 100644 man/config-Annotated-method.Rd create mode 100644 man/dot-insertPEP.Rd create mode 100644 man/getProject-Annotated-method.Rd create mode 100644 man/is-Annotated-method.Rd create mode 100644 man/samples-Annotated-method.Rd diff --git a/man/config-Annotated-method.Rd b/man/config-Annotated-method.Rd new file mode 100644 index 0000000..ffd6cef --- /dev/null +++ b/man/config-Annotated-method.Rd @@ -0,0 +1,26 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/methods_Annotated.R +\docType{methods} +\name{config,Annotated-method} +\alias{config,Annotated-method} +\title{View PEP config of the object of \code{\link[pepr]{Project-class}}} +\usage{ +\S4method{config}{Annotated}(object) +} +\arguments{ +\item{object}{an object of \code{\link[pepr]{Project-class}} or \code{\link[S4Vectors]{Annotated-class}}} +} +\value{ +a list with the config file +} +\description{ +This method can be used to view the config slot of +the \code{\link[pepr]{Project-class}} or or \code{\link[S4Vectors]{Annotated-class}} +} +\examples{ +projectConfig = system.file("extdata", "example_peps-master", +"example_BiocProject", "project_config.yaml", package="BiocProject") +p=BiocProject(projectConfig) +config(p) + +} diff --git a/man/dot-insertPEP.Rd b/man/dot-insertPEP.Rd new file mode 100644 index 0000000..1c8dc92 --- /dev/null +++ b/man/dot-insertPEP.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/functions.R +\name{.insertPEP} +\alias{.insertPEP} +\title{Insert a PEP metadata in a metadata slot of Annotated} +\usage{ +.insertPEP(object, pep) +} +\arguments{ +\item{object}{an object of \code{\link[S4Vectors]{Annotated-class}}} + +\item{pep}{an object of class \code{\link[pepr]{Project-class}}} +} +\value{ +an object of the same class as the object argument but enriched with the metadata from the pep argument +} +\description{ +This function inserts the PEP (\code{\link[pepr]{Project-class}}) into the metadata slot of objects that extend the \code{\link[S4Vectors]{Annotated-class}} +} diff --git a/man/getProject-Annotated-method.Rd b/man/getProject-Annotated-method.Rd new file mode 100644 index 0000000..6551604 --- /dev/null +++ b/man/getProject-Annotated-method.Rd @@ -0,0 +1,25 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/methods_Annotated.R +\docType{methods} +\name{getProject,Annotated-method} +\alias{getProject,Annotated-method} +\title{Extract the object of \code{\link[pepr]{Project-class}} from the \code{\link[S4Vectors]{Annotated-class}}} +\usage{ +\S4method{getProject}{Annotated}(.Object) +} +\arguments{ +\item{object}{an object of \code{\link[S4Vectors]{Annotated-class}}} +} +\value{ +an object of \code{\link[pepr]{Project-class}} +} +\description{ +This method can be used to extract the project metadata from objects of \code{\link[S4Vectors]{Annotated-class}} +} +\examples{ +projectConfig = system.file("extdata", "example_peps-master", +"example_BiocProject", "project_config.yaml", package="BiocProject") +p=BiocProject(projectConfig) +samples(p) + +} diff --git a/man/is-Annotated-method.Rd b/man/is-Annotated-method.Rd new file mode 100644 index 0000000..05ee832 --- /dev/null +++ b/man/is-Annotated-method.Rd @@ -0,0 +1,15 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/methods_Annotated.R +\docType{methods} +\name{is,Annotated-method} +\alias{is,Annotated-method} +\title{Is an Object from a Class?} +\usage{ +\S4method{is}{Annotated}(object, class2) +} +\description{ +Functions to test inheritance relationships between an object and a class or between two classes. It uses the generic is function but overrides its behavior for obejcts of class \code{\link[S4Vectors]{Annotated-class}} when testing for inheritance from \code{\link[pepr]{Project-class}} class. +} +\details{ +see the \code{\link[methods]{is}} for more details +} diff --git a/man/samples-Annotated-method.Rd b/man/samples-Annotated-method.Rd new file mode 100644 index 0000000..0cafae1 --- /dev/null +++ b/man/samples-Annotated-method.Rd @@ -0,0 +1,26 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/methods_Annotated.R +\docType{methods} +\name{samples,Annotated-method} +\alias{samples,Annotated-method} +\title{View samples in the objects of \code{\link[pepr]{Project-class}}} +\usage{ +\S4method{samples}{Annotated}(object) +} +\arguments{ +\item{object}{an object of \code{\link[pepr]{Project-class}} or \code{\link[S4Vectors]{Annotated-class}}} +} +\value{ +a data.table with the with metadata about samples +} +\description{ +This method can be used to view the samples slot +of the \code{\link[pepr]{Project-class}} or \code{\link[S4Vectors]{Annotated-class}} +} +\examples{ +projectConfig = system.file("extdata", "example_peps-master", +"example_BiocProject", "project_config.yaml", package="BiocProject") +p=BiocProject(projectConfig) +samples(p) + +} From 4571cfdd39ed84a706d995231e7113c88bec8be9 Mon Sep 17 00:00:00 2001 From: Michal Stolarczyk Date: Sun, 27 Jan 2019 15:29:35 -0500 Subject: [PATCH 11/17] update changelog and small changes in R files --- NEWS.md | 3 ++- R/functions.R | 9 +++++++- R/methods_Annotated.R | 50 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index 116df2d..589e11b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,7 +4,8 @@ ## Added -* methods: `is.Project`, `samples`, `config` for signiture `Annotated` and functions: `insertPEP` and `BiocProject` (the workhorse of the package) +* methods: `is` (overwrites this method bahavior just for the class `Annotated`), `.is.project`, `samples`, `config` for signiture `Annotated` +* functions: `.insertPEP` and `BiocProject` (the workhorse of the package) ## Changed diff --git a/R/functions.R b/R/functions.R index 7597d21..e1a3529 100644 --- a/R/functions.R +++ b/R/functions.R @@ -148,7 +148,14 @@ BiocProject = function(file, subproject = NULL, autoLoad = T, func = NULL, funcA } } - +#' Insert a PEP metadata in a metadata slot of Annotated +#' +#' This function inserts the PEP (\code{\link[pepr]{Project-class}}) into the metadata slot of objects that extend the \code{\link[S4Vectors]{Annotated-class}} +#' +#' @param object an object of \code{\link[S4Vectors]{Annotated-class}} +#' @param pep an object of class \code{\link[pepr]{Project-class}} +#' +#' @return an object of the same class as the object argument but enriched with the metadata from the pep argument .insertPEP = function(object, pep) { if(is(object, "Annotated") & is(pep, "Project")){ metadata(object) = list(PEP=pep) diff --git a/R/methods_Annotated.R b/R/methods_Annotated.R index 8892c7e..8595f3e 100644 --- a/R/methods_Annotated.R +++ b/R/methods_Annotated.R @@ -14,6 +14,20 @@ setMethod(".is.project","Annotated",function(.Object){ setGeneric("getProject", function(.Object) standardGeneric("getProject")) +#' Extract the object of \code{\link[pepr]{Project-class}} from the \code{\link[S4Vectors]{Annotated-class}} +#' +#' This method can be used to extract the project metadata from objects of \code{\link[S4Vectors]{Annotated-class}} +#' +#' @param object an object of \code{\link[S4Vectors]{Annotated-class}} +#' +#' @return an object of \code{\link[pepr]{Project-class}} +#' +#' @examples +#' projectConfig = system.file("extdata", "example_peps-master", +#' "example_BiocProject", "project_config.yaml", package="BiocProject") +#' p=BiocProject(projectConfig) +#' samples(p) +#' #' @export setMethod("getProject","Annotated",function(.Object){ if(.is.project(.Object)) { @@ -23,6 +37,20 @@ setMethod("getProject","Annotated",function(.Object){ } }) +#' View samples in the objects of \code{\link[pepr]{Project-class}} +#' +#' This method can be used to view the samples slot +#' of the \code{\link[pepr]{Project-class}} or \code{\link[S4Vectors]{Annotated-class}} +#' +#' @param object an object of \code{\link[pepr]{Project-class}} +#' +#' @return a data.table with the with metadata about samples +#' @examples +#' projectConfig = system.file("extdata", "example_peps-master", +#' "example_BiocProject", "project_config.yaml", package="BiocProject") +#' p=BiocProject(projectConfig) +#' samples(p) +#' #' @export setMethod( f = "samples", @@ -31,6 +59,22 @@ setMethod( samples(getProject(object)) }) + +#' View PEP config of the object of \code{\link[pepr]{Project-class}} +#' +#' This method can be used to view the config slot of +#' the \code{\link[pepr]{Project-class}} or or \code{\link[S4Vectors]{Annotated-class}} +#' +#' @param object an object of \code{\link[pepr]{Project-class}} +#' +#' @return a list with the config file +#' +#' @examples +#' projectConfig = system.file("extdata", "example_peps-master", +#' "example_BiocProject", "project_config.yaml", package="BiocProject") +#' p=BiocProject(projectConfig) +#' config(p) +#' #' @export setMethod( f = "config", @@ -41,6 +85,12 @@ setMethod( setGeneric("is", package = "methods") +#' Is an Object from a Class? +#' +#' Functions to test inheritance relationships between an object and a class or between two classes. It uses the generic is function but overrides its behavior for obejcts of class \code{\link[S4Vectors]{Annotated-class}} when testing for inheritance from \code{\link[pepr]{Project-class}} class. +#' +#' see the \code{\link[methods]{is}} for more details +#' #' @export setMethod("is", "Annotated", definition = function(object, class2){ if(class2=="Project" & .is.project(object)){ From e508673bd473b3cc5e1f64ec4a1937599bef4934 Mon Sep 17 00:00:00 2001 From: Michal Stolarczyk Date: Sun, 27 Jan 2019 16:05:06 -0500 Subject: [PATCH 12/17] changes in docs --- man/config-Annotated-method.Rd | 2 +- man/samples-Annotated-method.Rd | 2 +- vignettes/4remoteData.Rmd | 5 ----- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/man/config-Annotated-method.Rd b/man/config-Annotated-method.Rd index ffd6cef..5d54bd3 100644 --- a/man/config-Annotated-method.Rd +++ b/man/config-Annotated-method.Rd @@ -8,7 +8,7 @@ \S4method{config}{Annotated}(object) } \arguments{ -\item{object}{an object of \code{\link[pepr]{Project-class}} or \code{\link[S4Vectors]{Annotated-class}}} +\item{object}{an object of \code{\link[pepr]{Project-class}}} } \value{ a list with the config file diff --git a/man/samples-Annotated-method.Rd b/man/samples-Annotated-method.Rd index 0cafae1..f26ac86 100644 --- a/man/samples-Annotated-method.Rd +++ b/man/samples-Annotated-method.Rd @@ -8,7 +8,7 @@ \S4method{samples}{Annotated}(object) } \arguments{ -\item{object}{an object of \code{\link[pepr]{Project-class}} or \code{\link[S4Vectors]{Annotated-class}}} +\item{object}{an object of \code{\link[pepr]{Project-class}}} } \value{ a data.table with the with metadata about samples diff --git a/vignettes/4remoteData.Rmd b/vignettes/4remoteData.Rmd index 9b0d21b..119be13 100644 --- a/vignettes/4remoteData.Rmd +++ b/vignettes/4remoteData.Rmd @@ -102,9 +102,4 @@ And the metadata metadata(bpRemote) samples(bpRemote) config(bpRemote) -``` - -The function that was used to download and process the data: -```{r echo=FALSE, eval=TRUE, comment=""} -get(config(bpRemote)$bioconductor$read_fun_name) ``` \ No newline at end of file From f7256dcc55bee907efce6ce60ce4b76f27f2dd2d Mon Sep 17 00:00:00 2001 From: nsheff Date: Mon, 28 Jan 2019 09:09:36 -0500 Subject: [PATCH 13/17] Qualify metadata function with namespace. See #18 --- R/functions.R | 2 +- R/methods_Annotated.R | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/R/functions.R b/R/functions.R index e1a3529..b955fb3 100644 --- a/R/functions.R +++ b/R/functions.R @@ -158,7 +158,7 @@ BiocProject = function(file, subproject = NULL, autoLoad = T, func = NULL, funcA #' @return an object of the same class as the object argument but enriched with the metadata from the pep argument .insertPEP = function(object, pep) { if(is(object, "Annotated") & is(pep, "Project")){ - metadata(object) = list(PEP=pep) + S4Vectors::metadata(object) = list(PEP=pep) object }else{ stop("Type error: The 'object' argument has to be of class 'Annotated', got '", class(object),"'. And the pep argument has to be of class 'Project', got '", class(pep),"'") diff --git a/R/methods_Annotated.R b/R/methods_Annotated.R index 8595f3e..d31bbfb 100644 --- a/R/methods_Annotated.R +++ b/R/methods_Annotated.R @@ -2,7 +2,7 @@ setGeneric(".is.project", function(.Object) standardGeneric(".is.project")) setMethod(".is.project","Annotated",function(.Object){ - mData = metadata(.Object) + mData = S4Vectors::metadata(.Object) result = tryCatch(expr = { mData[[1]] }, error = function(e){ @@ -31,7 +31,7 @@ setGeneric("getProject", function(.Object) #' @export setMethod("getProject","Annotated",function(.Object){ if(.is.project(.Object)) { - metadata(.Object)[[1]] + S4Vectors::metadata(.Object)[[1]] } else { stop("This object does not have PEP in the metadata slot.") } From 86862268236bdd7abea1ffae97839bc99898ec8d Mon Sep 17 00:00:00 2001 From: nsheff Date: Mon, 28 Jan 2019 09:12:48 -0500 Subject: [PATCH 14/17] qualify pepr function calls. See #18 --- R/methods_Annotated.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/methods_Annotated.R b/R/methods_Annotated.R index d31bbfb..909503c 100644 --- a/R/methods_Annotated.R +++ b/R/methods_Annotated.R @@ -56,7 +56,7 @@ setMethod( f = "samples", signature = "Annotated", definition = function(object) { - samples(getProject(object)) + pepr::samples(getProject(object)) }) @@ -80,7 +80,7 @@ setMethod( f = "config", signature = "Annotated", definition = function(object) { - config(getProject(object)) + pepr::config(getProject(object)) }) setGeneric("is", package = "methods") From 36995af965e0769240a6a5dfbfac6889712f61df Mon Sep 17 00:00:00 2001 From: nsheff Date: Mon, 28 Jan 2019 09:15:52 -0500 Subject: [PATCH 15/17] bump version --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 8a0cc16..a98d27c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: BiocProject Title: Bioconductor Management with Portable Encapsulated Project (PEP) Objects -Version: 0.0.4 +Version: 0.1 Authors@R: c(person("Michal", "Stolarczyk", email = "mjs5kd@virginia.edu",role = c("aut", "cre")), person("Nathan", "Sheffield", email = "nathan@code.databio.org",role = c("aut"))) Description: A Bioconductor-oriented project management class. It wraps the From eeb3c66897d1174e2fe6c045d62a6adbb47c4a89 Mon Sep 17 00:00:00 2001 From: nsheff Date: Mon, 28 Jan 2019 09:16:26 -0500 Subject: [PATCH 16/17] roxygenize --- man/dot-insertPEP.Rd | 19 ------------------- man/dot-isAbsolute.Rd | 17 ----------------- man/dot-makeAbsPath.Rd | 19 ------------------- 3 files changed, 55 deletions(-) delete mode 100644 man/dot-insertPEP.Rd delete mode 100644 man/dot-isAbsolute.Rd delete mode 100644 man/dot-makeAbsPath.Rd diff --git a/man/dot-insertPEP.Rd b/man/dot-insertPEP.Rd deleted file mode 100644 index 1c8dc92..0000000 --- a/man/dot-insertPEP.Rd +++ /dev/null @@ -1,19 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/functions.R -\name{.insertPEP} -\alias{.insertPEP} -\title{Insert a PEP metadata in a metadata slot of Annotated} -\usage{ -.insertPEP(object, pep) -} -\arguments{ -\item{object}{an object of \code{\link[S4Vectors]{Annotated-class}}} - -\item{pep}{an object of class \code{\link[pepr]{Project-class}}} -} -\value{ -an object of the same class as the object argument but enriched with the metadata from the pep argument -} -\description{ -This function inserts the PEP (\code{\link[pepr]{Project-class}}) into the metadata slot of objects that extend the \code{\link[S4Vectors]{Annotated-class}} -} diff --git a/man/dot-isAbsolute.Rd b/man/dot-isAbsolute.Rd deleted file mode 100644 index 9a91ca1..0000000 --- a/man/dot-isAbsolute.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{.isAbsolute} -\alias{.isAbsolute} -\title{Determine whether a path is absolute.} -\usage{ -.isAbsolute(path) -} -\arguments{ -\item{path}{The path to check for seeming absolute-ness.} -} -\value{ -Flag indicating whether the \code{path} appears to be absolute. -} -\description{ -Determine whether a path is absolute. -} diff --git a/man/dot-makeAbsPath.Rd b/man/dot-makeAbsPath.Rd deleted file mode 100644 index 8d5806d..0000000 --- a/man/dot-makeAbsPath.Rd +++ /dev/null @@ -1,19 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{.makeAbsPath} -\alias{.makeAbsPath} -\title{Create an absolute path from a primary target and a parent candidate.} -\usage{ -.makeAbsPath(perhapsRelative, parent) -} -\arguments{ -\item{perhapsRelative:}{Path to primary target directory.} - -\item{parent:}{Path to parent folder to use if target isn't absolute.} -} -\value{ -Target itself if already absolute, else target nested within parent. -} -\description{ -Create an absolute path from a primary target and a parent candidate. -} From 70beacf42965442e82d3511bb1f8cb130696e27a Mon Sep 17 00:00:00 2001 From: nsheff Date: Mon, 28 Jan 2019 09:17:47 -0500 Subject: [PATCH 17/17] update changelog --- NEWS.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/NEWS.md b/NEWS.md index 589e11b..014860b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,10 +1,10 @@ -# BiocProject 0.0.5 +# BiocProject 0.1 -## Unreleased +## 2019-01-28 ## Added -* methods: `is` (overwrites this method bahavior just for the class `Annotated`), `.is.project`, `samples`, `config` for signiture `Annotated` +* methods: `is` (overwrites this method behavior just for the class `Annotated`), `.is.project`, `samples`, `config` for signiture `Annotated` * functions: `.insertPEP` and `BiocProject` (the workhorse of the package) ## Changed