bed_merge: Merge overlapping intervals.

Description Usage Arguments Details Value See Also Examples

View source: R/bed_merge.r

Description

Operations can be performed on merged intervals by specifying name-value pairs. Default max_dist of 0 means book-ended intervals are merged.

Usage

1
bed_merge(x, max_dist = 0, ...)

Arguments

x

tbl_interval()

max_dist

maximum distance between intervals to merge

...

name-value pairs that specify operations on merged intervals

Details

input tbls are grouped by chrom by default, and additional groups can be added using dplyr::group_by(). For example, grouping by strand will constrain analyses to the same strand. To compare opposing strands across two tbls, strands on the y tbl can first be inverted using flip_strands().

Value

tbl_interval()

See Also

http://bedtools.readthedocs.org/en/latest/content/tools/merge.html

Other single set operations: bed_cluster, bed_complement, bed_flank, bed_partition, bed_shift, bed_slop

Examples

 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
x <- trbl_interval(
  ~chrom, ~start, ~end,
  'chr1',  1,      50,
  'chr1',  10,     75,
  'chr1',  100,    120
)

bed_glyph(bed_merge(x))

x <- trbl_interval(
 ~chrom, ~start, ~end, ~value, ~strand,
 "chr1", 1,      50,   1,      '+',
 "chr1", 100,    200,  2,      '+',
 "chr1", 150,    250,  3,      '-',
 "chr2", 1,      25,   4,      '+',
 "chr2", 200,    400,  5,      '-',
 "chr2", 400,    500,  6,      '+',
 "chr2", 450,    550,  7,      '+'
)

bed_merge(x)

bed_merge(x, max_dist = 100)

# merge intervals on same strand
bed_merge(dplyr::group_by(x, strand))

bed_merge(x, .value = sum(value))

rnabioco/valr documentation built on Jan. 6, 2019, 9:06 a.m.