https://github.com/rnabioco/valr
Genome Interval Arithmetic in R
https://github.com/rnabioco/valr
bedtools genome interval-arithmetic
Last synced: 8 months ago
JSON representation
Genome Interval Arithmetic in R
- Host: GitHub
- URL: https://github.com/rnabioco/valr
- Owner: rnabioco
- License: other
- Created: 2016-01-10T14:38:43.000Z (over 10 years ago)
- Default Branch: main
- Last Pushed: 2025-10-21T15:15:19.000Z (8 months ago)
- Last Synced: 2025-10-21T19:47:44.775Z (8 months ago)
- Topics: bedtools, genome, interval-arithmetic
- Language: R
- Homepage: http://rnabioco.github.io/valr/
- Size: 69.8 MB
- Stars: 94
- Watchers: 7
- Forks: 24
- Open Issues: 4
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
---
output: github_document
---
```{r, echo = FALSE, message = FALSE}
knitr::opts_chunk$set(
fig.align = "center",
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-"
)
```
# valr 
[](https://github.com/rnabioco/valr/actions/workflows/check-standard.yaml)
[](https://app.codecov.io/github/rnabioco/valr)
[](https://CRAN.R-project.org/package=valr)
valr provides tools to read and manipulate genome intervals and signals, similar to the [BEDtools](https://bedtools.readthedocs.io/en/latest/) suite.
## Installation
::: .pkgdown-release
```{r, eval = FALSE}
# Install released version from CRAN
install.packages("valr")
```
:::
::: .pkgdown-devel
```{r, eval = FALSE}
# Install development version from GitHub
# install.packages("pak")
pak::pak("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](https://daler.github.io/pybedtools/#why-pybedtools), valr has a terse syntax:
```{r syntax_demo, message = FALSE}
library(valr)
library(dplyr)
snps <- read_bed(valr_example("hg19.snps147.chr22.bed.gz"))
genes <- read_bed(valr_example("genes.hg19.chr22.bed.gz"))
# 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)
```