Literature DB >> 28751969

valr: Reproducible genome interval analysis in R.

Kent A Riemondy1, Ryan M Sheridan2, Austin Gillen1, Yinni Yu2, Christopher G Bennett3, Jay R Hesselberth1,2.   

Abstract

New tools for reproducible exploratory data analysis of large datasets are important to address the rising size and complexity of genomic data. We developed the valr R package to enable flexible and efficient genomic interval analysis. valr leverages new tools available in the "tidyverse", including dplyr. Benchmarks of valr show it performs similar to BEDtools and can be used for interactive analyses and incorporated into existing analysis pipelines.

Entities:  

Keywords:  BEDtools; Genomics; Intervals; R; RStudio; reproducibility

Year:  2017        PMID: 28751969      PMCID: PMC5506536          DOI: 10.12688/f1000research.11997.1

Source DB:  PubMed          Journal:  F1000Res        ISSN: 2046-1402


Introduction

A routine bioinformatic task is the analysis of the relationships between sets of genomic intervals, including the identification of DNA variants within protein coding regions, annotation of regions enriched for nucleic acid binding proteins, and computation of read density within a set of exons. Command-line tools for interval analysis such as BEDtools [1] and BEDOPS [2] enable analyses of genome-wide datasets and are key components of analysis pipelines. Analyses with these tools commonly combine processing intervals on the command-line with visualization and statistical analysis in R. However, the need to master both the command-line and R hinders exploratory data analysis, and the development of reproducible research workflows built in the RMarkdown framework. Existing R packages developed for interval analysis include IRanges [3], bedr [4], and GenometriCorr [5]. IRanges is a Bioconductor package that provides interval classes and methods to perform interval arithmetic, and is used by many Bioconductor packages. bedr is a CRAN-distributed package that provides wrapper R functions to call the BEDtools, BEDOPS, and tabix command-line utilities, providing out-of-memory support for interval analysis. Finally, GenometriCorr provides a set of statistical tests to determine the relationships between interval sets using IRanges data structures. These packages provide functionality for processing and statistical inference of interval data, however they require a detailed understanding of S4 classes ( IRanges) or the installation of external command-line dependencies ( bedr). Additionally, these packages do not easily integrate with the recent advances provided by the popular tidyverse suite of data processing and visualization tools (e.g. dplyr, purrr, broom and ggplot2) [6]. We therefore sought to develop a flexible R package for genomic interval arithmetic built to incorporate new R programming, visualization, and interactivity features.

Methods

Implementation

valr is an R package that makes extensive use of dplyr, a flexible and high-performance framework for data manipulation in R [7]. Additionally, compute intensive functions in valr are written in C++ using Rcpp to enable fluid interactive analysis of large datasets [8]. Interval intersections and related operations use an interval tree algorithm to efficiently search for overlapping intervals [9]. BED files are imported and handled in R as data_frame objects, requiring minimal pre or post-processing to integrate with additional R packages or command-line tools.

Operation

valr is distributed as part of the CRAN R package repository and is compatible with Mac OS X, Windows, and major Linux operating systems. Package dependencies and system requirements are documented in the .

Use cases

To demonstrate the functionality and utility of valr, we present a basic tutorial for using valr and additional common use cases for genomic interval analysis.

Basic usage

valr provides a set of functions to read BED, BEDgraph, and VCF formats into R as convenient tibble (tbl) data_frame objects. All tbls have chrom, start, and end columns, and tbls from multi-column formats have additional pre-determined column names. Standards methods for importing data (e.g. read.table, readr::read_tsv) are also supported provided the constructed dataframes contain the requisite column names ( chrom, start, end). Additionally, valr supports connections to remote databases to access the UCSC and Ensembl databases via the db_ucsc and db_ensembl functions. The functions in valr have similar names to their BEDtools counterparts, and so will be familiar to users of the BEDtools suite. Also, similar to pybedtools [10], a python wrapper for BEDtools, valr has a terse syntax. For example, shown below is a demonstration of how to find all intergenic SNPs within 1 kilobase of genes using valr. The BED files used in the following examples are described in the Data Availability section. By conducting interval arithmetic entirely in R, valr is also an effective teaching tool for introducing interval analysis to early-stage analysts without requiring familiarity with both command-line tools and R. To aid in demonstrating the interval operations available in valr, we developed the bed_glyph() tool which produces plots demonstrating the input and output of operations in valr in a manner similar to those found in the BEDtools documentation. Shown below is the code required to produce glyphs displaying the results of intersecting x and y intervals with bed_intersect(), and the result of merging x intervals with bed_merge() ( Figure 1).
Figure 1.

Visualizing interval operations in valr with bed_glyph().

And this glyph illustrates bed_merge(): The group_by function in dplyr can be used to execute functions on subsets of single and multiple data_frames. Functions in valr leverage grouping to enable a variety of comparisons. For example, intervals can be grouped by strand to perform comparisons among intervals on the same strand. Comparisons between intervals on opposite strands are done using the flip_strands() function: Both single set (e.g. bed_merge()) and multi set operations will respect groupings in the input intervals. Columns in BEDtools are referred to by position: In valr, columns are referred to by name and can be used in multiple name/value expressions for summaries. The major functions available in valr are shown in Table 1.
Table 1.

An overview of major functions available in valr.

Function NamePurpose
Reading Data
read_bedRead BED files
read_bedgraphRead bedGraph files
read_narrowpeakRead narrowPeak files
read_broadpeakRead broadPeak files
Interval Transformation
bed_slopExpand interval coordinates
bed_shiftShift interval coordinates
bed_flankCreate flanking intervals
bed_mergeMerge overlapping intervals
bed_clusterIdentify (but not merge) overlapping intervals
bed_complementCreate intervals not covered by a query
Interval Comparison
bed_intersectReport intersecting intervals from x and y tbls
bed_mapApply functions to selected columns for overlapping intervals
bed_subtractRemove intervals based on overlaps
bed_windowFind overlapping intervals within a window
bed_closestFind the closest intervals independent of overlaps
Randomizing intervals
bed_randomGenerate random intervals from an input genome
bed_shuffleShuffle the coordinates of input intervals
Interval statistics
bed_fisher, bed_ projectionCalculate significance of overlaps between two sets of intervals
bed_reldistQuantify relative distances between sets of intervals
bed_absdistQuantify absolute distances between sets of intervals
bed_jaccardQuantify extent of overlap between two sets of intervals
Utilities
bed_glyphVisualize the actions of valr functions
bound_intervalsConstrain intervals to a genome reference
bed_makewindowsSubdivide intervals
bed12_to_exonsConvert BED12 to BED6 format
interval_spacingCalculate spacing between intervals
db_ucsc, db_ensemblAccess remote databases

Summarizing interval coverage across genomic features

This demonstration illustrates how to use valr tools to perform a “meta-analysis” of signals relative to genomic features. Here we analyze the distribution of histone marks surrounding transcription start sites, using H3K4Me3 Chip-Seq data from the ENCODE project. First we load packages and relevant data. Then, we generate 1 bp intervals to represent transcription start sites (TSSs). We focus on + strand genes, but - genes are easily accommodated by filtering them and using bed_makewindows() with reversed window numbers. Now we use the .win_id group with bed_map() to calculate a sum by mapping y signals onto the intervals in x. These data are regrouped by .win_id and a summary with mean and sd values is calculated. Finally, these summary statistics are used to construct a plot that illustrates histone density surrounding TSSs ( Figure 2).
Figure 2.

Meta-analysis of signals relative to genomic features with valr.

( A) Summarized coverage of human H3K4Me3 Chip-Seq coverage across positive strand transcription start sites on chromosome 22. Data presented +/- SD.

Meta-analysis of signals relative to genomic features with valr.

( A) Summarized coverage of human H3K4Me3 Chip-Seq coverage across positive strand transcription start sites on chromosome 22. Data presented +/- SD.

Interval statistics

Estimates of significance for interval overlaps can be obtained by combining bed_shuffle(), bed_random() and the sample_ functions from dplyr with interval statistics in valr. Here, we examine the extent of overlap of repeat classes (repeatmasker track obtained from the UCSC genome browser) with exons in the human genome (hg19 build, on chr22 only, for simplicity) using the jaccard similarity index. bed_jaccard() implements the jaccard test to examine the similarity between two sets of genomic intervals. Using bed_shuffle() and replicate() we generate a data_frame containing 100 sets of randomly selected intervals then calculate the jaccard index for each set against the repeat intervals to generate a null-distribution of jaccard scores. Finally, an empirical p-value is calculated from the null-distribution.

Benchmarking against bedtools

In order to ensure that valr performs fast enough to enable interactive analysis, key functionality is implemented in C++. To test the speed of major valr functions we generated two data_frames containing 1 million randomly selected 1 kilobase intervals derived from the human genome (hg19). Most of the major valr functions complete execution in less than 1 second, demonstrating that valr can process large interval datasets efficiently ( Figure 3A).
Figure 3.

Performance of valr functions.

( A) Timings were calculated by performing 10 repetitions of indicated functions on data frames preloaded in R containing 1 million random 1 kilobase x/y intervals generated using bed_random(). ( B) Timings for executing functions in BEDtools v2.25.0 or equivalent functions in valr using the same interval sets as in ( A) written to files. All BEDtools function outputs were written to /dev/null/, and were timed using GNU time. Timings for valr functions in ( B) include times for reading files using read_bed() functions and were timed using the microbenchmark package.

Performance of valr functions.

( A) Timings were calculated by performing 10 repetitions of indicated functions on data frames preloaded in R containing 1 million random 1 kilobase x/y intervals generated using bed_random(). ( B) Timings for executing functions in BEDtools v2.25.0 or equivalent functions in valr using the same interval sets as in ( A) written to files. All BEDtools function outputs were written to /dev/null/, and were timed using GNU time. Timings for valr functions in ( B) include times for reading files using read_bed() functions and were timed using the microbenchmark package. We also benchmarked major valr functions against corresponding commands in BEDtools. valr operates on data_frames already loaded into RAM, whereas BEDtools performs file-reading, processing, and writing. To compare valr against BEDtools we generated two BED files containing 1 million randomly selected 1 kilobase intervals derived from the human genome (hg19). For valr functions, we timed reading the table into R (e.g. with read_bed()) and performing the respective function. For BEDtools commands we timed executing the command with the output written to / dev/null. valr functions performed similarly or faster than BEDtools commands, with the exception of bed_map and bed_fisher ( Figure 3B).

Reproducible reports and interactive visualizations

Command-line tools like BEDtools and bedops can be incorporated into reproducible workflows (e.g., with [11]), but it is cumbersome to transition from command-line tools to exploratory analysis and plotting software. RMarkdown documents are plain text files, amenable to version control, which provide an interface to generate feature rich PDF and HTML reports that combine text, executable code, and figures in a single document. valr can be used in RMarkdown documents to provide rapid documentation of exploratory data analyses and generate reproducible work-flows for data processing. Moreover, new features in RStudio, such as notebook viewing, and multiple language support enable similar functionality to another popular notebook platform jupyter notebooks. Additionally, valr seamlessly integrates into R shiny [12] applications allowing for complex interactive visualizations relating to genomic interval analyses. We have developed a shiny application (available on ) that explores ChiP-Seq signal density surrounding transcription start sites and demonstrates the ease of implementing valr to power dynamic visualizations.

Summary

valr provides a flexible framework for interval arithmetic in R/Rstudio. valr functions are written with a simple and terse syntax that promotes flexible interactive analysis. Additionally by providing an easy-to-use interface for interval arithmetic in R, valr is also a useful teaching tool to introduce the analyses necessary to investigate correlations between genomic intervals, without requiring familiarity with the command-line. We envision that valr will help researchers quickly and reproducibly analyze genome interval datasets.

Data and software availability

The valr package includes external datasets stored in the inst/extdata/ directory that were used in this manuscript. These datasets were obtained from the ENCODE Project [13] or the UCSC genome browser [14]. BED files were generated by converting the UCSC tables into BED format. BED and BEDgraph data was only kept from chromosome 22, and was subsampled to produce file sizes suitable for submission to the CRAN repository. The original raw data is available from the following sources: hela.h3k4.chip.bg.gz SRA record: SRR227441, ENCODE identifier: ENCSR000AOF hg19.refGene.chr22.bed.gz hg19.rmsk.chr22.bed.gz hg19.chrom.sizes.gz genes.hg19.chr22.bed.gz hg19.snps147.chr22.bed.gz valr can be installed via CRAN using install.packages("valr"). valr is maintained at . Latest valr source code is available at . The latest stable version of source code is at: Archived source code at the time of publication: [15] License: MIT license. The authors describe a package for manipulating genomic interval data in R using principles from the "tidyverse" for the data structures and API. This sets it apart from existing tools such as GenomicRanges or bedr which have their own ways of storing and manipulating data. As a result, valr should be easier to pick up and integrate with the rest of the R ecosystem, and the “tidyverse” in particular. Illustrative examples give the reader a taste for the package while highlighting the novel features. In general, this looks to be a very useful tool. The code quality is excellent and it is great to see so many tests including the addition of regression tests as issues are identified. My comments are very minor: Group-by code listing: comment "# intersect tbls by strand" should be "# group tbls by strand" Bioconductor might be a more appropriate repository than CRAN Description of in-memory usage: I see from the software documentation that BAM and VCF will be supported in the future, and the documentation explicitly mentions that valr operates on data in-memory. The section comparing with BEDTools briefly mentions the in-memory aspect, but it would be helpful to be clearer about memory usage in the manuscript, especially as users attempting to use large BAM files may run out of memory. This is just a suggestion for improvement: Over the years, numerous bugs from corner cases have been found and handled in BEDTools. It would greatly increase confidence in the underlying algorithms you have written if there is input/output parity between valr and BEDTools, at least for the tools that overlap the two packages. For example I see some test cases that use input from the BEDTools test suite (e.g., test_cluster.r), but don't check the output. It should be straightforward to check the output against that provided by the BEDTools test suite. Correspondingly it would be good for BEDTools to use valr input/expected output in its test suite. I have read this submission. I believe that I have an appropriate level of expertise to confirm that it is of an acceptable scientific standard. Riemondy and colleagues have made a valuable tool, `valr`, available to the general public, one which deserves much merit for bringing modern R idioms from the `tidyverse` into the world of genomic research. As a fellow bioinformatician who has struggled with the idiosyncrasies of the aforementioned tools for interval manipulation in R, `valr` addresses many of the usability issues associated with these legacy methods by fundamentally altering the user experience. Consequently, there are two main advantages to adopting `valr` for interval manipulation in R: ease of writing, and ease of reading, code. Thus, this referee wholeheartedly endorses `valr`, and hopes to see more work that brings many of the `tidyverse` philosophies over to working with genomics in R. Nonetheless, there is some room for improvement of the associated manuscript to better help explain the philosophy and usage of `valr`, and its place amongst the many tools for the manipulation of genomic intervals. Firstly, in the introduction, it is mentioned that there exist `IRanges` methods that utilize the S4 convention, whereas `valr` utilizes a less formal schema where 3 columns, `chrom`, `start`, `end`, are present in the `data_frame` object. Indeed, it may be of use to expand upon such design choices that were made, and what advantages/disadvantages are made in using this less formal schema, and any other highly pertinent choices that affect user experience. In addition, one line mentions integration with other `tidyverse` tools, and should expand upon this with either one to a few specific examples or explain this point in more detail. Additionally, it should also be pointed out how `valr` builds upon these existing toolkits, and either expands upon/adopts their conventions. One way might be to create a table comparing functions between `valr`/bedtools/GenomicRanges might be helpful for a reader to see that the toolkit will be easily adoptable. Indeed, its mentioned that the syntax is similar to bedtools in the use cases, and might be good to mention in the introduction as well. Thus, an expanded introduction/additional section explaining the uniqueness of `valr` would help to better "sell" when one should use `valr` and why. In performing benchmarking, it would be useful to include one or two leading R tools, such as GenomicRanges, into the calculations, as this is likely how many R programmers currently perform interval manipulations natively in R, and I suspect would likely show an impressive performance improvement by relation. `valr` presents an exciting new development in the R+Genomics realm, and this referee is hopeful that this sort of development helps fuel further `tidyomics` tools for R bound together by a cohesive philosophy, great user experience, and pointed utility. I have read this submission. I believe that I have an appropriate level of expertise to confirm that it is of an acceptable scientific standard.
  9 in total

1.  BEDOPS: high-performance genomic feature operations.

Authors:  Shane Neph; M Scott Kuehn; Alex P Reynolds; Eric Haugen; Robert E Thurman; Audra K Johnson; Eric Rynes; Matthew T Maurano; Jeff Vierstra; Sean Thomas; Richard Sandstrom; Richard Humbert; John A Stamatoyannopoulos
Journal:  Bioinformatics       Date:  2012-05-09       Impact factor: 6.937

2.  Snakemake--a scalable bioinformatics workflow engine.

Authors:  Johannes Köster; Sven Rahmann
Journal:  Bioinformatics       Date:  2012-08-20       Impact factor: 6.937

3.  BEDTools: a flexible suite of utilities for comparing genomic features.

Authors:  Aaron R Quinlan; Ira M Hall
Journal:  Bioinformatics       Date:  2010-01-28       Impact factor: 6.937

4.  Software for computing and annotating genomic ranges.

Authors:  Michael Lawrence; Wolfgang Huber; Hervé Pagès; Patrick Aboyoun; Marc Carlson; Robert Gentleman; Martin T Morgan; Vincent J Carey
Journal:  PLoS Comput Biol       Date:  2013-08-08       Impact factor: 4.475

5.  Pybedtools: a flexible Python library for manipulating genomic datasets and annotations.

Authors:  Ryan K Dale; Brent S Pedersen; Aaron R Quinlan
Journal:  Bioinformatics       Date:  2011-09-23       Impact factor: 6.937

6.  Exploring massive, genome scale datasets with the GenometriCorr package.

Authors:  Alexander Favorov; Loris Mularoni; Leslie M Cope; Yulia Medvedeva; Andrey A Mironov; Vsevolod J Makeev; Sarah J Wheelan
Journal:  PLoS Comput Biol       Date:  2012-05-31       Impact factor: 4.475

7.  The UCSC Genome Browser database: 2015 update.

Authors:  Kate R Rosenbloom; Joel Armstrong; Galt P Barber; Jonathan Casper; Hiram Clawson; Mark Diekhans; Timothy R Dreszer; Pauline A Fujita; Luvina Guruvadoo; Maximilian Haeussler; Rachel A Harte; Steve Heitner; Glenn Hickey; Angie S Hinrichs; Robert Hubley; Donna Karolchik; Katrina Learned; Brian T Lee; Chin H Li; Karen H Miga; Ngan Nguyen; Benedict Paten; Brian J Raney; Arian F A Smit; Matthew L Speir; Ann S Zweig; David Haussler; Robert M Kuhn; W James Kent
Journal:  Nucleic Acids Res       Date:  2014-11-26       Impact factor: 19.160

8.  A bedr way of genomic interval processing.

Authors:  Syed Haider; Daryl Waggott; Emilie Lalonde; Clement Fung; Fei-Fei Liu; Paul C Boutros
Journal:  Source Code Biol Med       Date:  2016-12-15

9.  An integrated encyclopedia of DNA elements in the human genome.

Authors: 
Journal:  Nature       Date:  2012-09-06       Impact factor: 49.962

  9 in total
  14 in total

1.  Bedtoolsr: An R package for genomic data analysis and manipulation.

Authors:  Mayura N Patwardhan; Craig D Wenger; Eric S Davis; Douglas H Phanstiel
Journal:  J Open Source Softw       Date:  2019-12-06

2.  Genetic variants drive altered epigenetic regulation of endotoxin response in BTBR macrophages.

Authors:  Annie Vogel Ciernia; Verena M Link; Milo Careaga; Janine M LaSalle; Paul Ashwood
Journal:  Brain Behav Immun       Date:  2020-05-23       Impact factor: 7.217

3.  Quality-controlled R-loop meta-analysis reveals the characteristics of R-loop consensus regions.

Authors:  Henry E Miller; Daniel Montemayor; Jebriel Abdul; Anna Vines; Simon A Levy; Stella R Hartono; Kumar Sharma; Bess Frost; Frédéric Chédin; Alexander J R Bishop
Journal:  Nucleic Acids Res       Date:  2022-07-22       Impact factor: 19.160

4.  The PP2A-Integrator-CDK9 axis fine-tunes transcription and can be targeted therapeutically in cancer.

Authors:  Stephin J Vervoort; Sarah A Welsh; Jennifer R Devlin; Elisa Barbieri; Deborah A Knight; Sarah Offley; Stefan Bjelosevic; Matteo Costacurta; Izabela Todorovski; Conor J Kearney; Jarrod J Sandow; Zheng Fan; Benjamin Blyth; Victoria McLeod; Joseph H A Vissers; Karolina Pavic; Ben P Martin; Gareth Gregory; Elena Demosthenous; Magnus Zethoven; Isabella Y Kong; Edwin D Hawkins; Simon J Hogg; Madison J Kelly; Andrea Newbold; Kaylene J Simpson; Otto Kauko; Kieran F Harvey; Michael Ohlmeyer; Jukka Westermarck; Nathanael Gray; Alessandro Gardini; Ricky W Johnstone
Journal:  Cell       Date:  2021-05-17       Impact factor: 66.850

5.  Dynamic temperature-sensitive A-to-I RNA editing in the brain of a heterothermic mammal during hibernation.

Authors:  Kent A Riemondy; Austin E Gillen; Emily A White; Lori K Bogren; Jay R Hesselberth; Sandra L Martin
Journal:  RNA       Date:  2018-07-31       Impact factor: 4.942

6.  fcScan: a versatile tool to cluster combinations of sites using genomic coordinates.

Authors:  Abdullah El-Kurdi; Ghiwa Ali Khalil; Georges Khazen; Pierre Khoueiry
Journal:  BMC Bioinformatics       Date:  2020-05-19       Impact factor: 3.169

7.  DOT1L complex suppresses transcription from enhancer elements and ectopic RNAi in Caenorhabditis elegans.

Authors:  Ruben Esse; Ekaterina S Gushchanskaia; Avery Lord; Alla Grishok
Journal:  RNA       Date:  2019-07-12       Impact factor: 4.942

8.  GWAS unveils features between early- and late-flowering pearl millets.

Authors:  Oumar Diack; Ghislain Kanfany; Mame Codou Gueye; Ousmane Sy; Amadou Fofana; Hamidou Tall; Desalegn D Serba; Leila Zekraoui; Cécile Berthouly-Salazar; Yves Vigouroux; Diaga Diouf; Ndjido Ardo Kane
Journal:  BMC Genomics       Date:  2020-11-10       Impact factor: 3.969

9.  Liver Transcriptome Dynamics During Hibernation Are Shaped by a Shifting Balance Between Transcription and RNA Stability.

Authors:  Austin E Gillen; Rui Fu; Kent A Riemondy; Jennifer Jager; Bin Fang; Mitchell A Lazar; Sandra L Martin
Journal:  Front Physiol       Date:  2021-05-21       Impact factor: 4.566

10.  plyranges: a grammar of genomic data transformation.

Authors:  Stuart Lee; Dianne Cook; Michael Lawrence
Journal:  Genome Biol       Date:  2019-01-04       Impact factor: 13.583

View more

北京卡尤迪生物科技股份有限公司 © 2022-2023.