/
README.Rmd
57 lines (43 loc) · 1.81 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
---
output: github_document
---
```{r, echo = FALSE, message = FALSE}
knitr::opts_chunk$set(
fig.align = "center",
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-"
)
```
# valr <img src="man/figures/logo.png" align="right" />
<!-- badges: start -->
[![R-CMD-check](https://github.com/rnabioco/valr/workflows/R-CMD-check/badge.svg)](https://github.com/rnabioco/valr/actions)
[![codecov](https://codecov.io/gh/rnabioco/valr/branch/master/graph/badge.svg)](https://app.codecov.io/gh/rnabioco/valr)
[![](https://www.r-pkg.org/badges/version/valr)](https://CRAN.R-project.org/package=valr)
<!-- badges: end -->
valr provides tools to read and manipulate genome intervals and signals, similar to the [BEDtools](https://bedtools.readthedocs.io/en/latest/) suite.
## Installation
The latest stable version can be installed from CRAN:
``` r
install.packages('valr')
```
The latest development version can be installed from github:
``` r
# 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](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)
```