tile-methods: Generate windows for a GenomicRanges

Description Usage Arguments Details Value Author(s) See Also Examples

Description

tile and slidingWindows methods for GenomicRanges. tile partitions each range into a set of tiles, which are defined in terms of their number or width. slidingWindows generates sliding windows of a specified width and frequency.

Usage

1
2
3
4
## S4 method for signature 'GenomicRanges'
tile(x, n, width)
## S4 method for signature 'GenomicRanges'
slidingWindows(x, width, step=1L)

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.

step

The distance between the start positions of the sliding windows.

Details

The tile function splits x into a GRangesList, each element of which corresponds to a tile, or partition, of x. Specify the tile geometry with either n or width (not both). Passing n creates n tiles of approximately equal width, truncated by sequence end, while passing width tiles the region with ranges of the given width, again truncated by sequence end.

The slidingWindows function generates sliding windows within each range of x, according to width and step, returning a GRangesList. If the sliding windows do not exactly cover a range in x, the last window is partial.

Value

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

Author(s)

M. Lawrence

See Also

tile in the IRanges package.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
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(elementNROWS(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))))

windows <- slidingWindows(gr, width=3L, step=2L)
width(windows[[1L]]) # last range is truncated

Example output

Loading required package: stats4
Loading required package: BiocGenerics
Loading required package: parallel

Attaching package:BiocGenericsThe following objects are masked frompackage:parallel:

    clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
    clusterExport, clusterMap, parApply, parCapply, parLapply,
    parLapplyLB, parRapply, parSapply, parSapplyLB

The following objects are masked frompackage:stats:

    IQR, mad, sd, var, xtabs

The following objects are masked frompackage:base:

    anyDuplicated, append, as.data.frame, basename, cbind, colnames,
    dirname, do.call, duplicated, eval, evalq, Filter, Find, get, grep,
    grepl, intersect, is.unsorted, lapply, Map, mapply, match, mget,
    order, paste, pmax, pmax.int, pmin, pmin.int, Position, rank,
    rbind, Reduce, rownames, sapply, setdiff, sort, table, tapply,
    union, unique, unsplit, which.max, which.min

Loading required package: S4Vectors

Attaching package:S4VectorsThe following object is masked frompackage:base:

    expand.grid

Loading required package: IRanges
Loading required package: GenomeInfoDb
[1] 3 3 3 3 3

GenomicRanges documentation built on Nov. 8, 2020, 5:46 p.m.