Learn R Programming

IRanges (version 2.6.1)

slice-methods: Slice a vector-like or list-like object

Description

slice is a generic function that creates views on a vector-like or list-like object that contain the elements that are within the specified bounds.

Usage

slice(x, lower=-Inf, upper=Inf, ...)
"slice"(x, lower=-Inf, upper=Inf, includeLower=TRUE, includeUpper=TRUE, rangesOnly=FALSE)
"slice"(x, lower=-Inf, upper=Inf, includeLower=TRUE, includeUpper=TRUE, rangesOnly=FALSE)

Arguments

x
An Rle or RleList object, or any object coercible to an Rle object.
lower, upper
The lower and upper bounds for the slice.
includeLower, includeUpper
Logical indicating whether or not the specified boundary is open or closed.
rangesOnly
A logical indicating whether or not to drop the original data from the output.
...
Additional arguments to be passed to specific methods.

Value

The method for Rle objects returns an RleViews object if rangesOnly=FALSE or an IRanges object if rangesOnly=TRUE.The method for RleList objects returns an RleViewsList object if rangesOnly=FALSE or an IRangesList object if rangesOnly=TRUE.

Details

slice is useful for finding areas of absolute maxima (peaks), absolute minima (troughs), or fluctuations within specified limits. One or more view summarization methods can be used on the result of slice. See ?`link{view-summarization-methods}`

See Also

Examples

Run this code
## Views derived from coverage
x <- IRanges(start=c(1L, 9L, 4L, 1L, 5L, 10L),
             width=c(5L, 6L, 3L, 4L, 3L,  3L))
cvg <- coverage(x)
slice(cvg, lower=2)
slice(cvg, lower=2, rangesOnly=TRUE)

Run the code above in your browser using DataLab