An open API service indexing awesome lists of open source software.

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

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

[![R-CMD-check](https://github.com/rnabioco/valr/actions/workflows/check-standard.yaml/badge.svg)](https://github.com/rnabioco/valr/actions/workflows/check-standard.yaml)
[![codecov](https://codecov.io/github/rnabioco/valr/graph/badge.svg)](https://app.codecov.io/github/rnabioco/valr)
[![](https://www.r-pkg.org/badges/version/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)
```