Learn R Programming

GenomicRanges (version 1.18.4)

tile-methods: Tile a GenomicRanges object

Description

tile method for GenomicRanges. Partitions the each range into a set of tiles. Tiles are defined in terms of their number or width.

Usage

"tile"(x, n, width)

Arguments

x
A GenomicRanges object, like a GRanges.
n
The number of tiles to generate. See ?tile in the IRanges package for more information about this argument.
width
The (maximum) width of each tile. See ?tile in the IRanges package for more information about this argument.

Value

A GRangesList object, each element of which corresponds to a tile.

See Also

tile in the IRanges package.

Examples

Run this code
gr <- GRanges(
        seqnames=Rle(c("chr1", "chr2", "chr1", "chr3"), c(1, 3, 2, 4)),
        ranges=IRanges(1:10, end=11),
        strand=Rle(strand(c("-", "+", "*", "+", "-")), c(1, 2, 2, 3, 2)),
        seqlengths=c(chr1=11, chr2=12, chr3=13))

# split every range in half
tiles <- tile(gr, n = 2L)
stopifnot(all(elementLengths(tiles) == 2L))

# split ranges into subranges of width 2
# odd width ranges must contain one subrange of width 1
tiles <- tile(gr, width = 2L)
stopifnot(all(all(width(tiles) %in% c(1L, 2L))))

Run the code above in your browser using DataLab