knitr::opts_chunk$set(
  fig.align = "center",
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-"
)

valr

R-CMD-check codecov

valr provides tools to read and manipulate genome intervals and signals, similar to the BEDtools suite.

Installation

::: .pkgdown-release

# Install released version from CRAN
install.packages("valr")

:::

::: .pkgdown-devel

# 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, valr has a terse syntax:

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)


rnabioco/valr documentation built on March 29, 2025, 11:56 p.m.