Learn R Programming

⚠️There's a newer version (0.8.4) of this package.Take me there.

valr

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

Installation

# Install released version from CRAN
install.packages("valr")
# 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)
#> # A tibble: 1,047 × 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
#> # ℹ 1,037 more rows

Copy Link

Version

Install

install.packages('valr')

Monthly Downloads

674

Version

0.8.3

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Kent Riemondy

Last Published

January 11th, 2025

Functions in valr (0.8.3)

bed_random

Generate randomly placed intervals on a genome.
create_utrs3

Create 3' UTR features.
create_introns

Create intron features.
ivl_df

Bed-like data.frame requirements for valr functions
create_tss

Create transcription start site features.
read_bed

Read BED and related files.
gr_to_bed

Convert Granges to bed tibble
bound_intervals

Select intervals bounded by a genome.
id

Plyr function id packaged due to plyr being retired Compute a unique numeric id for each unique row in a data frame.
bed_window

Identify intervals within a specified distance.
db

Fetch data from remote databases.
create_utrs5

Create 5' UTR features.
flip_strands

Flip strands in intervals.
bed_jaccard

Calculate the Jaccard statistic for two sets of intervals.
bed_sort

Sort a set of intervals.
interval_spacing

Calculate interval spacing.
read_vcf

Read a VCF file.
bed_subtract

Subtract two sets of intervals.
read_gtf

Import and convert a GTF/GFF file into a valr compatible bed tbl format
id_var

Plyr function id_var packaged due to plyr being retired Numeric id for a vector.
bed_shuffle

Shuffle input intervals.
valr_example

Provide working directory for valr example files.
valr

valr: genome interval arithmetic in R
bed_slop

Increase the size of input intervals.
read_bigwig

Read a bigwig file into a valr compatible tbl
read_genome

Read genome files.
bed_flank

Create flanking intervals from input intervals.
bed_cluster

Cluster neighboring intervals.
bed_closest

Identify closest intervals.
bed_fisher

Fisher's test to measure overlap between two sets of intervals.
bed_absdist

Compute absolute distances between intervals.
bed12_to_exons

Convert BED12 to individual exons in BED6.
bed_glyph

Create example glyphs for valr functions.
bed_genomecov

Calculate coverage across a genome
bed_coverage

Compute coverage of intervals.
bed_complement

Identify intervals in a genome not covered by a query.
bed_reldist

Compute relative distances between intervals.
bed_shift

Adjust intervals by a fixed size.
bed_projection

Projection test for query interval overlap.
bed_merge

Merge overlapping intervals.
bed_makewindows

Divide intervals into new sub-intervals ("windows").
bed_partition

Partition intervals into elemental intervals
bed_intersect

Identify intersecting intervals.
bed_map

Calculate summaries from overlapping intervals.