ranges-tile: Slide or tile over a Ranges object

tile_rangesR Documentation

Slide or tile over a Ranges object

Description

Slide or tile over a Ranges object

Usage

tile_ranges(x, width)

slide_ranges(x, width, step)

Arguments

x

a Ranges object

width

the maximum width of each window/tile (integer vector of length 1)

step

the distance between start position of each sliding window (integer vector of length 1)

Details

The tile_ranges() function paritions a Ranges object x by the given the width over all ranges in x, truncated by the sequence end. The slide_ranges() function makes sliding windows within each range of x of size width and sliding by step. Both slide_ranges() and tile_ranges() return a new Ranges object with a metadata column called "partition" which contains the index of the input range x that a parition belongs to.

Value

a Ranges object

See Also

GenomicRanges::tile()

Examples

 
gr <- data.frame(seqnames = c("chr1", rep("chr2", 3), rep("chr1", 2), rep("chr3", 4)),
                 start = 1:10,
                 end = 11,
                 strand = c("-", rep("+", 2), rep("*", 2), rep("+", 3), rep("-", 2))) %>%
      as_granges() %>%
      set_genome_info(seqlengths = c(11,12,13))

# partition ranges into subranges of width 2, odd width ranges
# will have one subrange of width 1              
tile_ranges(gr, width = 2)

# make sliding windows of width 3, moving window with step size of 2
slide_ranges(gr, width = 3, step = 2)


sa-lee/plyranges documentation built on April 15, 2024, 12:25 p.m.