bed_shift: Adjust intervals by a fixed size.

View source: R/bed_shift.r

bed_shiftR Documentation

Adjust intervals by a fixed size.

Description

Out-of-bounds intervals are removed by default.

Usage

bed_shift(x, genome, size = 0, fraction = 0, trim = FALSE)

Arguments

x

ivl_df

genome

ivl_df

size

number of bases to shift. positive numbers shift right, negative shift left.

fraction

define size as a fraction of interval

trim

adjust coordinates for out-of-bounds intervals

Value

ivl_df

See Also

https://bedtools.readthedocs.io/en/latest/content/tools/shift.html

Other single set operations: bed_cluster(), bed_complement(), bed_flank(), bed_merge(), bed_partition(), bed_slop()

Examples

x <- tibble::tribble(
  ~chrom, ~start, ~end,
  "chr1", 25, 50,
  "chr1", 100, 125
)

genome <- tibble::tribble(
  ~chrom, ~size,
  "chr1", 125
)

bed_glyph(bed_shift(x, genome, size = -20))

x <- tibble::tribble(
  ~chrom, ~start, ~end, ~strand,
  "chr1", 100,    150,  "+",
  "chr1", 200,    250,  "+",
  "chr2", 300,    350,  "+",
  "chr2", 400,    450,  "-",
  "chr3", 500,    550,  "-",
  "chr3", 600,    650,  "-"
)

genome <- tibble::tribble(
  ~chrom, ~size,
  "chr1", 1000,
  "chr2", 2000,
  "chr3", 3000
)

bed_shift(x, genome, 100)

bed_shift(x, genome, fraction = 0.5)

# shift with respect to strand
stranded <- dplyr::group_by(x, strand)
bed_shift(stranded, genome, 100)


valr documentation built on Sept. 19, 2023, 1:07 a.m.