Genome Interval Arithmetic in R
Clone or download
Permalink
Failed to load latest commit information.
.github add issue template, intersect example Mar 4, 2017
R dont call as_tibble on tibble input related to issue #338 (#339) Nov 13, 2018
docs Update site [skip ci] Aug 4, 2018
inst use new intersect_impl to speed-up bed_map. (#304) Jan 25, 2018
man-roxygen covert docs to markdown. (#231) Apr 29, 2017
man Update site [skip ci] Aug 4, 2018
src add new function `bed_partition()` with cpp implementation (#336) May 11, 2018
tests add new function `bed_partition()` with cpp implementation (#336) May 11, 2018
vignettes add new function `bed_partition()` with cpp implementation (#336) May 11, 2018
.Rbuildignore Cran release Jun 8, 2018
.codecov.yml suppress codecov comments Sep 13, 2016
.gitignore update site Apr 4, 2018
.travis.yml dont call as_tibble on tibble input related to issue #338 (#339) Nov 13, 2018
DESCRIPTION dont call as_tibble on tibble input related to issue #338 (#339) Nov 13, 2018
LICENSE update license and news Mar 2, 2018
LICENSE.md update license and news Mar 2, 2018
NAMESPACE dont call as_tibble on tibble input related to issue #338 (#339) Nov 13, 2018
NEWS.md dont call as_tibble on tibble input related to issue #338 (#339) Nov 13, 2018
README.Rmd simplify readme to improve search results Apr 4, 2018
README.md update site [ci skip] Apr 26, 2018
_pkgdown.yml add new function `bed_partition()` with cpp implementation (#336) May 11, 2018
appveyor.yml dont call as_tibble on tibble input related to issue #338 (#339) Nov 13, 2018
cran-comments.md Cran release Jun 8, 2018
valr.Rproj skip vignette for CHECK/BUILD Jul 20, 2017

README.md

valr

Build Status AppVeyor Build Status Coverage Status DOI

The valr package provides tools to read and manipulate genome intervals and signals, similar to the BEDtools suite. valr enables analysis in the R/RStudio environment, leveraging modern R tools in the tidyverse for a terse, expressive syntax. Compute-intensive algorithms are implemented in Rcpp/C++, and many methods take advantage of the speed and grouping capability provided by dplyr. See vignette(valr) for more details.

Installation

The latest stable version can be installed from CRAN:

install.packages('valr')

The latest development version can be installed from github:

# install.packages("devtools")
devtools::install_github('rnabioco/valr')

valr Example

Functions in valr have similar names to their BEDtools counterparts, and so will be familiar to users coming from the BEDtools suite. Unlike other tools that wrap BEDtools and write temporary files to disk, valr tools run natively in memory. Similar to pybedtools, valr has a terse syntax:

library(valr)
library(dplyr)

snps <- read_bed(valr_example('hg19.snps147.chr22.bed.gz'), n_fields = 6)
genes <- read_bed(valr_example('genes.hg19.chr22.bed.gz'), n_fields = 6)

# find snps in intergenic regions
intergenic <- bed_subtract(snps, genes)
# find distance from intergenic snps to nearest gene
nearby <- bed_closest(intergenic, genes)

nearby %>%
  select(starts_with('name'), .overlap, .dist) %>%
  filter(abs(.dist) < 5000)
#> # A tibble: 1,047 x 4
#>    name.x      name.y   .overlap .dist
#>    <chr>       <chr>       <int> <int>
#>  1 rs530458610 P704P           0  2579
#>  2 rs2261631   P704P           0  -268
#>  3 rs570770556 POTEH           0  -913
#>  4 rs538163832 POTEH           0  -953
#>  5 rs190224195 POTEH           0 -1399
#>  6 rs2379966   DQ571479        0  4750
#>  7 rs142687051 DQ571479        0  3558
#>  8 rs528403095 DQ571479        0  3309
#>  9 rs555126291 DQ571479        0  2745
#> 10 rs5747567   DQ571479        0 -1778
#> # ... with 1,037 more rows