Learn R Programming

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

valr

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

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"))
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

2,702

Version

0.8.1

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Kent Riemondy

Last Published

April 22nd, 2024

Functions in valr (0.8.1)

bed_window

Identify intervals within a specified distance.
bed_sort

Sort a set of intervals.
flip_strands

Flip strands in intervals.
db

Fetch data from remote databases.
bed_subtract

Subtract two sets of intervals.
interval_spacing

Calculate interval spacing.
valr

valr: genome interval arithmetic in R
id_var

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

Provide working directory for valr example files.
create_utrs5

Create 5' UTR features.
create_utrs3

Create 3' UTR features.
bound_intervals

Select intervals bounded by a genome.
read_genome

Read genome files.
bed_random

Generate randomly placed intervals on a genome.
read_bigwig

Import and convert a bigwig file into a valr compatible tbl
create_tss

Create transcription start site features.
ivl_df

Bed-like data.frame requirements for valr functions
create_introns

Create intron features.
read_bed

Read BED and related files.
bed_slop

Increase the size of input intervals.
bed_shuffle

Shuffle input intervals.
id

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

Convert Granges to bed tibble
read_vcf

Read a VCF file.
read_gtf

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

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

Identify closest intervals.
bed_coverage

Compute coverage of intervals.
bed_complement

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

Convert BED12 to individual exons in BED6.
bed_flank

Create flanking intervals from input intervals.
bed_genomecov

Calculate coverage across a genome
bed_absdist

Compute absolute distances between intervals.
bed_cluster

Cluster neighboring intervals.
bed_makewindows

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

Calculate summaries from overlapping intervals.
bed_projection

Projection test for query interval overlap.
bed_reldist

Compute relative distances between intervals.
bed_shift

Adjust intervals by a fixed size.
bed_glyph

Create example glyphs for valr functions.
bed_intersect

Identify intersecting intervals.
bed_jaccard

Calculate the Jaccard statistic for two sets of intervals.
bed_merge

Merge overlapping intervals.
bed_partition

Partition intervals into elemental intervals