[Bioc-devel] How to use RData files in Bioconductor data and software packages

web working webwork|ng @end|ng |rom po@teo@de
Thu Jan 9 22:06:35 CET 2020


Hi Richard,

It depends on the filetype. I am loading my "non RData" files with 
read.delim and my RData files with a helper function which returns a R 
object of the RData object:

#' Load RData object and returns first entry
#'
#' Load RData object and returns first entry. If there is more than one
#' object in the RData file, only the first object will be returned.
#'
#' @param RDataFile a \code{character} vector to the RData file.
#'
#' @return The \code{R} object of the RData file.
#' @export
#' @examples
#' # load GRanges object stored in a RData file.
#' dummy.GRanges <- loadRData(system.file('extdata', 'dummy.RData', 
package = "dummyData"))
loadRData <- function(RDataFile) {
   load(RDataFile)
   objectToLoad <- ls()[ls() != "RDataFile"]
   if (length(objectToLoad) > 1)
     warning(paste0("RData file contains more than one object. Only the 
first object (",
                    objectToLoad[1], ") will be returned!"))
   get(objectToLoad[1])
}

I know this is not the best solution. I guess saving the R objects in 
RDS files instead of RData files is the better solution here.

My question is if my storage of the RData objects (or RDS objects) in 
the inst/extdata directory is ok for an Bioconductor package.

Best,

Tobias


Am 09.01.20 um 15:45 schrieb Richard Virgen-Slane:
>
> I may be missing a point, but how are you loading the saved files?
>
> On Thu, Jan 9, 2020 at 4:46 AM web working <webworking using posteo.de 
> <mailto:webworking using posteo.de>> wrote:
>
>     Dear all,
>
>     I am currently developing a software package (dummySoftware) and a
>     data package (dummyData) and I am a bit confused in where to store
>     my RData files in the data package. Here my situation:
>
>     I want to store some software package objects (new class objects
>     of the software package) in the data package. This objects are
>     example objects and a to big for software packages. As I have read
>     here (http://r-pkgs.had.co.nz/data.html) all RData objects should
>     be stored in the data directory of a package. BED files of the
>     data package are stored in inst/extdata.
>     The data of the data packaged will be addressed in the software
>     package like this: system.file('extdata', 'subset.bed', package =
>     'dummyData'). And here the problem occurs. After building the data
>     package (devtools::build(args = c('--resave-data'))), all data in
>     data/ are stored in a datalist, Rdata.rdb, Rdata.rds and Rdata.rdx
>     and can not addressed with system.file. Addressing this data with
>     the data() function results in a warning during
>     BiocCheck::BiocCheck().
>
>     My solution is to store the RData files in the inst/extdata
>     directory and address them with system.file. Something similar is
>     mentioned here, but in the context of a vignette
>     (r-pkgs.had.co.nz/data.html#other-data
>     <http://r-pkgs.had.co.nz/data.html#other-data>). Is this the way
>     how to do it?
>
>     Best,
>     Tobias
>
>     _______________________________________________
>     Bioc-devel using r-project.org <mailto:Bioc-devel using r-project.org> mailing
>     list
>     https://stat.ethz.ch/mailman/listinfo/bioc-devel
>

	[[alternative HTML version deleted]]



More information about the Bioc-devel mailing list