bed_partition: Partition intervals into elemental intervals

Description Usage Arguments Details Value See Also Examples

View source: R/bed_partition.r

Description

Convert a set of intervals into elemental intervals that contain each start and end position in the set.

Usage

1

Arguments

x

trbl_interval()

...

name-value pairs specifying column names and expressions to apply

Details

Summary operations, such as min() or count() can be performed on elemental intervals by specifying name-value pairs.

This function is useful for calculating summaries across overlapping intervals without merging the intervals.

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

https://bedops.readthedocs.io/en/latest/content/reference/set-operations/bedops.html#partition-p-partition

Other single set operations: bed_cluster, bed_complement, bed_flank, bed_merge, 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
29
30
31
32
x <- trbl_interval(
  ~chrom, ~start, ~end, ~value, ~strand,
 'chr1', 100,    500,  10, "+",
 'chr1', 200,    400,  20, "-",
 'chr1', 300,    550,  30, "+",
 'chr1', 550,    575,   2, "+",
 'chr1', 800,    900,   5, "+" )


bed_glyph(bed_partition(x))
bed_glyph(bed_partition(x, value = sum(value)), label = "value")

bed_partition(x)

# compute summary over each elemental interval
bed_partition(x, value = sum(value))

# partition and compute summaries based on group
x <- dplyr::group_by(x, strand)
bed_partition(x, value = sum(value))

# combine values across multiple tibbles
y <- trbl_interval(
  ~chrom, ~start, ~end, ~value, ~strand,
 'chr1', 10,     500,  100, "+",
 'chr1', 250,    420,  200, "-",
 'chr1', 350,    550,  300, "+",
 'chr1', 550,    555,   20, "+",
 'chr1', 800,    900,   50, "+" )

x <- dplyr::bind_rows(x, y)
bed_partition(x, value = sum(value))

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