Keywords
Assay data, Bioconductor, Collaboration, Data science, Package, Reproducibility, Rmarkdown, Rstats, Version control
Assay data, Bioconductor, Collaboration, Data science, Package, Reproducibility, Rmarkdown, Rstats, Version control
A central idea of reproducible research is that results are published along with underlying data and software code necessary to reproduce and verify the findings. Termed a research compendium, this idea has received significant attention in the literature1–5.
Many software tools have since been developed to facilitate reproducible data analytics, and scientific journals have increasingly demanded that code and primary data be made publicly available with scientific publications2,6–27. Tools like git and Github, figshare, and Rmarkdown are increasingly used by researchers to make code, figures, and data open, accessible and reproducible. Nonetheless, in the life sciences, practicing reproducible research with large data sets and complex processing pipelines continues to be challenging.
Data preprocessing, quality control (QC), data standardization, analysis, and reporting are tightly coupled in most discussions of reproducible research, and indeed, literate programming frameworks such as Sweave and Rmarkdown are designed around the idea that code, data, and research results are tightly integrated2,25. Tools like Docker, a software container that virtualizes an operating system environment for distribution, have been used to ensure consistent versions of software and other dependencies are used for reproducible data analysis16. The use of R in combination with other publicly available tools has been proposed in the past to build reproducible research compendia3,28,29. Many existing tools already implement such ideas. The workflowr package provides mechanisms to turn a data analysis project into a version-controlled, documented, website presenting the results. The drake package30 is a general purpose work-flow manager that implements analytic "plans", caching of intermediate data objects, and provides scalability, and provides tangible evidence of reproducibility by detecting when code, data and results are in sync.
However, tight coupling of preprocessing and analysis can be challenging for teams analyzing and integrating large volumes of diverse data, where different individuals in the team have different areas of expertise and may be responsible for processing different data sets from a larger study. These challenges are compounded when a processing pipeline is split across multiple teams. A primary problem in data science is the programmatic integration of software tools with dynamic data sources.
Here, we argue that data processing, QC, and analysis can be treated as modular components in a reproducible research pipeline. For some data types, it is already common practice to factor out the processing and QC from the data analysis. For rnaseq data, for example, it is clearly impractical and time consuming to re-run monolithic code that performs alignment, QC, gene expression quantification, and analysis each time the downstream analysis is changed. Our goal is to ensure that downstream data analysis maintains dependencies on upstream raw data and processing but that the processed data can be efficiently distributed to users in an independent manner and updated when there are changes.
Here, we present how the Vaccine Immunology Statistical Center (VISC) at the Fred Hutchinson Cancer Research Center has addressed this problem and implemented a reproducible research work-flow that scales to medium-sized collaborative teams by leveraging free and open source tools, including R, Bioconductor and git22,31.
In order to use DataPackageR an R installation (≥3.5.0) is required. Associated dependencies are listed in the package’s DESCRIPTION file and are automatically installed when using the install_github() API from the devtools package. There are no minimum memory, CPU, or storage requirements apart from what is necessary to perform data processing, which varies on a case–by-case basis.
Our work-flow is built around the DataPackageR R package, which provides a framework for decoupling data preprocessing from data analysis, while maintaining traceability and data provenance18.
DataPackageR builds upon the features already provided by the R package system. R packages provide a convenient mechanism for including documentation as part of the built-in help system, as well as long-form vignettes, and version information and distribution of the entire package. Importantly, R packages often include data stored as R objects, and some packages, particularly under BioConductor, are devoted solely to the distribution of data sets22. The accepted mechanism for such distribution is to store R objects as rda files in the data directory of the package source tree and to store the source code used to produce those data sets in data-raw. The devtools package provides some mechanisms to process the source code into stored data objects32.
Data processing code provided by the user (in the form of Rmd files preferably, and R files optionally) is run and the results are automatically included as package vignettes, with output data sets (specified by the user) included as data objects in the package. Notably, this process, while apparently mirroring much of the existing R package build process, is disjointed from it, thereby allowing the decoupling of computationally long or expensive data processing from routine package building and installation. This allows DataPackageR to decouple data munging and tidying from data analysis while maintaining data provenance in the form of a vignette in the final package where the end-user can view and track how individual data sets have been processed. This is particularly useful for large or complex data that involve extensive preprocessing of primary or raw data (e.g. alignment of fastq files for rnaseq or gating of fcm data), and where computation may be prohibitively long or involve software dependencies not immediately available to the end-user.
DataPackageR implements these features on top of a variety of tidyverse tools including devtools, roxygen2, rmarkdown, utils, yaml, purrr. The complete list of package dependencies is in the package DESCRIPTION file.
To construct a data package using DataPackageR, the user invokes the datapackage.skeleton() API, which behaves like R’s package.skeleton(), creating the necessary directory structure with some modifications. A listing of the structure of DataPackageR skeleton package directory, with other associated files is shown below:
package root
|--- datapackager.yml # Configuration file controlling
| # the package build process.
|--- DESCRIPTION # Adds a DataVersion
| # string to version the
| # data set.
|--- NAMESPACE
|--- DATADIGEST # Stores an MD5 hash of each
| # data object in the package.
|--- R
|--- Read-and-delete-me.txt # Further instructions
| # on building the package.
|--- data # Holds processed, analysis-ready data objects.
|--- data-raw # User code for data
| # processing is placed here by
| # datapackage.skeleton().
|--- documentation.R # Auto generated roxygen documentation
| # for data set objects.
|--- inst
| |___ extdata # (small) raw data files.
| |___ doc # Processed vignettes are moved here.
| # Data processing code is accessible in the
| # final package via the vignette() API.
|--- vignettes # Scripts in data-raw
| # are processed into vignettes.
|___ man # Autogenerated documentation is processed
# into rd files.
The datapackage.skeletion API takes several new arguments apart from the package name. First, code_files takes a vector of paths to Rmd or R scripts that perform the data processing. These are moved into the data-raw directory by package.skeleton(). The argument r_object_names takes a vector of quoted R object names. These are objects that are to be stored in the final package and it is expected that they are created by the code in the R or Rmd files. These can be tidy data tables, or arbitrary R objects and data structures (e.g. S4 objects) that will be consumed by the package end-user. Information about the processing scripts and data objects is stored in a configuration file named datapackager.yml in the package root directory and only used by the package build process. The scripts may read raw data from any location, but generally the package maintainer should place it in inst/extdata if file size is not prohibitive for distribution.
Once code and data are in place, the build_package() API invokes the build process. This API is the only way to invoke the execution of code in data-raw to produce data sets stored in data. It is not invoked through R’s standard R CMD build or R CMD INSTALL APIs, thereby decoupling long and computationally intensive processing from the standard build process invoked by end-users. Upon invocation of build_package() the R and Rmd files specified in datapackager.yml will be compiled into package vignettes and moved into the inst/doc directory, data objects will be created and moved into data, data objects will be version tagged with their checksum and recorded in the DATADIGEST file in the package root, and a roxygen markup skeleton will be created for each data object in the package.
The datapackager.yml configuration file in the package root controls the build process by specifying which R and Rmd files should be processed and which named R objects are expected to be included as data sets in the package. The listing below shows the structure of the YAML configuration file used by DataPackageR to control compilation and inclusion of data objects in the package:
configuration:
files: # files property lists
process_dataset_one.Rmd: # R or Rmd code files
name: process_dataset_one.Rmd # Each file has a name
enabled: yes # The enabled property specifies
# if the file should be processed
process_dataset_two.Rmd:
name: process_dataset_two.Rmd
enabled: yes
objects: # A list of the data objects created
- dataset_one # by processing the files.
- dataset_two
- dataset_three
The API for interacting with this file is outlined in Table 1.
During the build, the DATADIGEST file is auto-generated. This file contains an md5 hash of each data object stored in the package as well as an overall data set version string. These hashes are checked when the package is rebuilt; if they do not match, it indicates the format of the processed data has changed (either because the primary data has changed, or because the processing code has changed to update the data set). In these cases, the DATADIGEST for the changed object is updated and the minor version of the DataVersion string in the DESCRIPTION file is automatically incremented. The DataVersion for a package can be checked by the dataVersion() API, allowing end-users to produce reports based on the expected version of a data set (Figure 1).
DataPackageR ensures that documentation is available for each data object included in a package by automatically creating a roxygen markup stub for each object that can then be filled in by the user. Undocumented objects are explicitly excluded from the final package.
Packages can be readily distributed in source or tarball form (together with the processed data sets under /data/ and raw data sets under /inst/extdata). Within VISC we leverage git and github to provide version control of data package source code. By leveraging DataPackageR, the data processing is decoupled from the usual build process and does not need to be run by the end-user each time a package is downloaded and installed. Documentation in the form of Rd files, one for each data object in the package, as well as html vignettes describing the data processing, are included in the final package. These describe the data sets as well as how data was transformed, filtered, and otherwise processed from its raw state.
DataPackageR was developed as a lightweight alternative to existing reproducible work-flow tools (e.g. Galaxy33), or to fully fledged database solutions that are often beyond the scope of most short-term projects. DataPackageR plugs easily into any existing R-based data analysis work-flow, since existing data processing code needs only to be formatted into Rmarkdown (ideally). It is particularly suited for long-running or complex data processing tasks, or tasks that depend on large data sets that may not be available to the end user (e.g. FASTQ alignment or raw flow cytometry data processing). Such tasks do not fit well into the standard R CMD build paradigm, for example either as vignettes or .R files under /data since these would be invoked each time an end user builds a package from source. We desire, however, to maintain a link between the processed data sets and the processing code that generates them. We note that DataPackageR is distinct from other reproducible research frameworks such as workflowr or drake30, in that it is designed to reproducibly prepare data for analysis, using an existing code base, with little additional effort. The product of DataPackageR is nothing more than an R package that can be used by anyone. The resulting data packages are meant to be shared, to serve as the basis for further analysis (Figure 1) and distributed as part of publications. These downstream analyses may leverage any of the existing work-flow management tools. Our goal is that data sets forming the basis of scientific findings can be confidently shared in their processed form which is often much smaller and easier to distribute.
Within the VISC, a team of analysts, statistical programmers, and data managers work collaboratively to analyze pre-clinical data arising from multiple trials. There are multiple assays per trial. The challenges associated with ensuring the entire team works from the same version of a frequently changing and dynamic data set, motivated the development of DataPackageR. The tool is routinely used to process and standardize trial data for submission to The Collaboration for AIDS Vaccine Discovery (CAVD) Data Space.
We demonstrate how DataPackageR is used to process and package multiple types of assay data from an animal trial of an experimental HIV vaccine.
We demonstrate the use of DataPackageR for processing data from a vaccine study, named MX1, designed to examine the antibody responses to heterologous N7 Env prime-boost immunization in macaques. The study had four treatment groups plus a control arm, with six animals per group. Samples were collected at three time points: t1: baseline, post-prime 2, post-boost 1, t2: post-boost 2, t3: post-boost 3. Six assays were run at each time point, using either serum samples or peripheral blood mononuclear cells (PBMCs). The assays were: 1) enzyme-linked immunosorbent assay (ELISA), an immunological assay that enables detection of antibodies, antigens, proteins and/or glycoproteins (serum); 2) a neutralizing antibody (Ab) assay (serum); 3) a binding antibody multiplex assay (BAMA) to assess antibody response breadth (serum); 4) a BAMA assay to permit epitope mapping (serum); 5) an antibody dependent cellular cytotoxicity (ADCC) assay (serum); and 6) an intracellular cytokine staining assay to assess cellular responses (PBMCs).
The raw data and environment to reproduce the processing with DataPackageR are distributed as a Docker image on hub.docker.com as gfinak/datapackager:latest. We have restricted the number of FCS files distributed in the container to limit the size of the image and speed up processing of FCM data for demonstration purposes.
Flow cytometry (FCM) is a high content, high throughput assay for which VISC leverages specialized data processing and analytics tools. Raw FCS files and manual gate information in the form of FlowJo (FlowJo LLC, Ashland, OR) workspace files are uploaded directly to VISC by the labs. The raw data are processed with open source BioConductor software (flowWorkspace) to import and reproduce the manual gating, extract cell subpopulation statistics, and access the single-cell event-level data required for downstream modeling of T-cell polyfunctionality and immunogenicity34–36. Tables of extracted cell populations, cell counts, proportions, and fluorescence intensities are included in study packages, together with an Rmarkdown vignette describing the data processing. Due to the size of the raw FCS files, they are imported for processing from a location external to the data package source tree, so that the raw files are not part of the final package, but vignettes outlining the data processing are automatically included.
Remaining assay data are of reasonable size and are provided raw data in tabular (csv) form, imported into the package, processed and standardized from the inst/extdata package directory. Users can run and connect to an Rstudio instance in the container, where code and data to build the MX1 data package reside.
Reproducibility is increasingly emphasized for scientific publications. We describe a new utility R package, DataPackageR that serves to help automate and track the processing and standardization of diverse data sets into analysis-ready data packages that can be easily distributed for analysis and publication. DataPackageR, when paired with a version control system such as git, decouples data processing from data analysis while tracking changes to data sets, ensuring data objects are documented, and keeping a record of data processing pipelines as vignettes within the data package. The principle behind the tool is that it remains a lightweight and non-intrusive framework that easily plugs into most R-based data analytic work-flows. It places few restrictions on the user code therefore most existing scripts can be ported to use the package. The VISC has been using DataPackageR for a number of years to perform reproducible end-to-end analysis of animal trial data, and the package has been used to publicly share sets for a number of published manuscripts35,37,38.
Source code available from: http://github.com/RGLab/DataPackageR
Archived source code as at time of publication: https://doi.org/10.5281/zenodo.129209539
Reproducible examples: http://hub.docker.com/r/gfinak/datapackager/
License: MIT license
Partial data for the MX1 study to demonstrate processing using DataPackageR are available as a docker container from gfinak/DataPackageR:latest. The processed MX1 data are available on the CAVD DataSpace data sharing and discovery tool at http://dataspace.cavd.org under study identifier, CAVD 451. At the time of publication the complete data set is available to CAVD members only.
This work was supported by the Bill and Melinda Gates Foundation [OPP1032317; to RG]; and the National Institute of General Medical Sciences [R01 GM118417-01A1; to GF].
The funders had no role in study design, data collection and analysis, decision to publish, or preparation of the manuscript.
The authors wish to acknowledge the contributions of the members of the VISC and the CAVD Data Space (CDS) for contributions to testing and feedback on the software. We also acknowledge the Collaboration for AIDS Vaccine Discovery (CAVD), the Comprehensive Antibody Vaccine Immune Monitoring Consortium (CAVIMC) and the Comprehensive Cellular Vaccine Immune Monitoring Consortium (CCVIMC), as well as Dr. Shiu-Lok Hu.
Views | Downloads | |
---|---|---|
Gates Open Research | - | - |
PubMed Central
Data from PMC are received and updated monthly.
|
- | - |
Is the rationale for developing the new software tool clearly explained?
Yes
Is the description of the software tool technically sound?
Yes
Are sufficient details of the code, methods and analysis (if applicable) provided to allow replication of the software development and its use by others?
Yes
Is sufficient information provided to allow interpretation of the expected output datasets and any results generated using the tool?
Yes
Are the conclusions about the tool and its performance adequately supported by the findings presented in the article?
Partly
Competing Interests: No competing interests were disclosed.
Alongside their report, reviewers assign a status to the article:
Invited Reviewers | |||
---|---|---|---|
1 | 2 | 3 | |
Version 2 (revision) 10 Jul 18 |
read | read | read |
Version 1 22 Jun 18 |
read |
Provide sufficient details of any financial or non-financial competing interests to enable users to assess whether your comments might lead a reasonable person to question your impartiality. Consider the following examples, but note that this is not an exhaustive list:
Sign up for content alerts and receive a weekly or monthly email with all newly published articles
Register with Gates Open Research
Already registered? Sign in
If you are a previous or current Gates grant holder, sign up for information about developments, publishing and publications from Gates Open Research.
We'll keep you updated on any major new updates to Gates Open Research
The email address should be the one you originally registered with F1000.
You registered with F1000 via Google, so we cannot reset your password.
To sign in, please click here.
If you still need help with your Google account password, please click here.
You registered with F1000 via Facebook, so we cannot reset your password.
To sign in, please click here.
If you still need help with your Facebook account password, please click here.
If your email address is registered with us, we will email you instructions to reset your password.
If you think you should have received this email but it has not arrived, please check your spam filters and/or contact for further assistance.
Comments on this article Comments (0)