# valr valr provides tools to read and manipulate genome intervals and signals, similar to the [BEDtools](https://bedtools.readthedocs.io/en/latest/) suite. ## Installation ``` r # Install released version from CRAN install.packages("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 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,343 × 4 #> name.x name.y .overlap .dist #> #> 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,333 more rows ``` # Package index ## Data types - [`tibble()`](https://tibble.tidyverse.org/reference/tibble.html) [`tibble_row()`](https://tibble.tidyverse.org/reference/tibble.html) : Build a data frame (from tibble) - [`tribble()`](https://tibble.tidyverse.org/reference/tribble.html) : Row-wise tibble creation (from tibble) ## Load data - [`read_bed()`](https://rnabioco.github.io/valr/reference/read_bed.md) [`read_bed12()`](https://rnabioco.github.io/valr/reference/read_bed.md) [`read_bedgraph()`](https://rnabioco.github.io/valr/reference/read_bed.md) [`read_narrowpeak()`](https://rnabioco.github.io/valr/reference/read_bed.md) [`read_broadpeak()`](https://rnabioco.github.io/valr/reference/read_bed.md) : Read BED and related files. - [`read_genome()`](https://rnabioco.github.io/valr/reference/read_genome.md) : Read genome files. - [`read_gtf()`](https://rnabioco.github.io/valr/reference/read_gtf.md) **\[deprecated\]** : Import and convert a GTF/GFF file into a valr compatible bed tbl format - [`read_vcf()`](https://rnabioco.github.io/valr/reference/read_vcf.md) : Read a VCF file. - [`db_ucsc()`](https://rnabioco.github.io/valr/reference/db.md) [`db_ensembl()`](https://rnabioco.github.io/valr/reference/db.md) : Fetch data from remote databases. - [`read_bigwig()`](https://rnabioco.github.io/cpp11bigwig/reference/read_bigwig.html) : Read data from bigWig files. (from cpp11bigwig) - [`read_bigbed()`](https://rnabioco.github.io/cpp11bigwig/reference/read_bigbed.html) : Read data from bigBed files. (from cpp11bigwig) ## Single set operations - [`bed_cluster()`](https://rnabioco.github.io/valr/reference/bed_cluster.md) : Cluster neighboring intervals. - [`bed_complement()`](https://rnabioco.github.io/valr/reference/bed_complement.md) : Identify intervals in a genome not covered by a query. - [`bed_flank()`](https://rnabioco.github.io/valr/reference/bed_flank.md) : Create flanking intervals from input intervals. - [`bed_genomecov()`](https://rnabioco.github.io/valr/reference/bed_genomecov.md) : Calculate coverage across a genome - [`bed_merge()`](https://rnabioco.github.io/valr/reference/bed_merge.md) : Merge overlapping intervals. - [`bed_partition()`](https://rnabioco.github.io/valr/reference/bed_partition.md) : Partition intervals into elemental intervals - [`bed_slop()`](https://rnabioco.github.io/valr/reference/bed_slop.md) : Increase the size of input intervals. - [`bed_shift()`](https://rnabioco.github.io/valr/reference/bed_shift.md) : Adjust intervals by a fixed size. - [`bed_sort()`](https://rnabioco.github.io/valr/reference/bed_sort.md) : Sort a set of intervals. ## Multiple set operations - [`bed_closest()`](https://rnabioco.github.io/valr/reference/bed_closest.md) : Identify closest intervals. - [`bed_coverage()`](https://rnabioco.github.io/valr/reference/bed_coverage.md) : Compute coverage of intervals. - [`bed_intersect()`](https://rnabioco.github.io/valr/reference/bed_intersect.md) : Identify intersecting intervals. - [`bed_map()`](https://rnabioco.github.io/valr/reference/bed_map.md) [`concat()`](https://rnabioco.github.io/valr/reference/bed_map.md) [`values_unique()`](https://rnabioco.github.io/valr/reference/bed_map.md) [`values()`](https://rnabioco.github.io/valr/reference/bed_map.md) : Calculate summaries from overlapping intervals. - [`bed_subtract()`](https://rnabioco.github.io/valr/reference/bed_subtract.md) : Subtract two sets of intervals. - [`bed_window()`](https://rnabioco.github.io/valr/reference/bed_window.md) : Identify intervals within a specified distance. ## Randomizing intervals - [`bed_random()`](https://rnabioco.github.io/valr/reference/bed_random.md) : Generate randomly placed intervals on a genome. - [`bed_shuffle()`](https://rnabioco.github.io/valr/reference/bed_shuffle.md) : Shuffle input intervals. ## Interval statistics - [`bed_absdist()`](https://rnabioco.github.io/valr/reference/bed_absdist.md) : Compute absolute distances between intervals. - [`bed_reldist()`](https://rnabioco.github.io/valr/reference/bed_reldist.md) : Compute relative distances between intervals. - [`bed_fisher()`](https://rnabioco.github.io/valr/reference/bed_fisher.md) : Fisher's test to measure overlap between two sets of intervals. - [`bed_jaccard()`](https://rnabioco.github.io/valr/reference/bed_jaccard.md) : Calculate the Jaccard statistic for two sets of intervals. - [`bed_projection()`](https://rnabioco.github.io/valr/reference/bed_projection.md) : Projection test for query interval overlap. ## Utilities - [`create_introns()`](https://rnabioco.github.io/valr/reference/create_introns.md) : Create intron features. - [`create_tss()`](https://rnabioco.github.io/valr/reference/create_tss.md) : Create transcription start site features. - [`create_utrs3()`](https://rnabioco.github.io/valr/reference/create_utrs3.md) : Create 3' UTR features. - [`create_utrs5()`](https://rnabioco.github.io/valr/reference/create_utrs5.md) : Create 5' UTR features. - [`bed_makewindows()`](https://rnabioco.github.io/valr/reference/bed_makewindows.md) : Divide intervals into new sub-intervals ("windows"). - [`bed12_to_exons()`](https://rnabioco.github.io/valr/reference/bed12_to_exons.md) : Convert BED12 to individual exons in BED6. - [`bed_glyph()`](https://rnabioco.github.io/valr/reference/bed_glyph.md) : Create example glyphs for valr functions. - [`bound_intervals()`](https://rnabioco.github.io/valr/reference/bound_intervals.md) : Select intervals bounded by a genome. - [`flip_strands()`](https://rnabioco.github.io/valr/reference/flip_strands.md) : Flip strands in intervals. - [`gr_to_bed()`](https://rnabioco.github.io/valr/reference/gr_to_bed.md) : Convert Granges to bed tibble - [`interval_spacing()`](https://rnabioco.github.io/valr/reference/interval_spacing.md) : Calculate interval spacing. - [`check_interval()`](https://rnabioco.github.io/valr/reference/ivl_df.md) [`check_genome()`](https://rnabioco.github.io/valr/reference/ivl_df.md) : Bed-like data.frame requirements for valr functions - [`valr`](https://rnabioco.github.io/valr/reference/valr.md) : valr: genome interval arithmetic in R - [`valr_example()`](https://rnabioco.github.io/valr/reference/valr_example.md) : Provide working directory for valr example files. # Articles ### All vignettes - [Interval statistics](https://rnabioco.github.io/valr/articles/interval-stats.md): - [valr overview](https://rnabioco.github.io/valr/articles/valr.md):