Expand a range with multiplicative and additive constants

S4ExpandRange(limits, expand = expansion())

# S4 method for `NULL`
S4ExpandRange(limits, expand = expansion())

# S4 method for numeric
S4ExpandRange(limits, expand = expansion())

# S4 method for Ranges
S4ExpandRange(limits, expand = expansion())

Arguments

limits

An object indicating a range

expand

A numeric vector of length 4, typically the result of a call to expansion.

Value

An object indicating a range

Details

The expand argument consist of 4 constants that code for the following:

  1. A multiplicative constant relative to the width of the limits argument to subtract from the start of the limits.

  2. An additive constant to subtract from the start of the limits.

  3. A multiplicative constant relative to the width of the limits argument to add to the end of the limits.

  4. An additive constant to add to the end of the limits.

Integer-based classes such as IRanges and GRanges are rounded to the nearest integer.

Examples

# Regular numeric limits S4ExpandRange(c(10, 20), expansion(0.5, 1))
#> [1] 4 26
# IntegerRanges require(IRanges) S4ExpandRange(IRanges::IRanges(10, 20), expansion(0.5, 1))
#> IRanges object with 1 range and 0 metadata columns: #> start end width #> <integer> <integer> <integer> #> [1] 4 26 23
# GenomicRanges require(GenomicRanges) S4ExpandRange(GenomicRanges::GRanges(c("chr1", "chr2"), c("10-20", "20-30")), expansion(0.5, 1))
#> GRanges object with 2 ranges and 0 metadata columns: #> seqnames ranges strand #> <Rle> <IRanges> <Rle> #> [1] chr1 4-26 * #> [2] chr2 14-36 * #> ------- #> seqinfo: 2 sequences from an unspecified genome; no seqlengths