View source: R/bed_partition.r
bed_partition | R Documentation |
Convert a set of intervals into elemental intervals that contain each start and end position in the set.
bed_partition(x, ...)
x |
ivl_df |
... |
name-value pairs specifying column names and expressions to apply |
Summary operations, such as min()
or max()
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()
.
ivl_df()
Other single set operations:
bed_cluster()
,
bed_complement()
,
bed_flank()
,
bed_genomecov()
,
bed_merge()
,
bed_shift()
,
bed_slop()
x <- tibble::tribble(
~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 <- tibble::tribble(
~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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.