Utility functions for creating or modifying IRanges objects.
1 2 3 4 5 6 7 8 9  ## Create an IRanges instance:
successiveIRanges(width, gapwidth=0, from=1)
breakInChunks(totalsize, chunksize, nchunk)
## Turn a logical vector into a set of ranges:
whichAsIRanges(x)
## Coercion:
asNormalIRanges(x, force=TRUE)

width 
A vector of nonnegative integers (with no NAs) specifying the widths of the ranges to create. 
gapwidth 
A single integer or an integer vector with one less element than
the 
from 
A single integer specifying the starting position of the first range. 
totalsize 
A single nonnegative integer. The total size of the object to break. 
chunksize 
A single positive integer. The size of the chunks (last chunk might be smaller). 
nchunk 
A single positive integer. The number of chunks. 
x 
A logical vector for 
force 

successiveIRanges
returns an IRanges instance containing the
ranges that have the widths specified in the width
vector
and are separated by the gaps specified in gapwidth
.
The first range starts at position from
.
When gapwidth=0
and from=1
(the defaults), the returned
IRanges can be seen as a partitioning of the 1:sum(width) interval.
See ?Partitioning
for more details on this.
whichAsIRanges
returns an IRanges instance containing all of
the ranges where x
is TRUE
.
If force=TRUE
(the default), then asNormalIRanges
will
turn x
into a NormalIRanges instance by reordering and
reducing the set of ranges if necessary (i.e. only if isNormal(x)
is FALSE
, otherwise the set of ranges will be untouched).
If force=FALSE
, then asNormalIRanges
will turn x
into a NormalIRanges instance only if isNormal(x)
is
TRUE
, otherwise it will raise an error.
Note that when force=FALSE
, the returned object is guaranteed
to contain exactly the same set of ranges than x
.
as(x, "NormalIRanges")
is equivalent to asNormalIRanges(x, force=TRUE)
.
Hervé Pagès
Rangesclass, IRangesclass,
intrarangemethods for intra range transformations,
interrangemethods for inter range transformations,
setopsmethods,
solveUserSEW
,
successiveViews
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25  vec < as.integer(c(19, 5, 0, 8, 5))
successiveIRanges(vec)
breakInChunks(600999, 50000) # 13 chunks of size 50000 (last chunk is
# smaller).
whichAsIRanges(vec >= 5)
x < IRanges(start=c(2L, 6L, 9L, 4L, 1L, 0L, 6L, 10L),
width=c( 5L, 0L, 6L, 1L, 4L, 3L, 2L, 3L))
asNormalIRanges(x) # 3 nonempty ranges ordered from left to right and
# separated by gaps of width >= 1.
## More on normality:
example(`IRangesclass`)
isNormal(x16) # FALSE
if (interactive())
x16 < asNormalIRanges(x16) # Error!
whichFirstNotNormal(x16) # 57
isNormal(x16[1:56]) # TRUE
xx < asNormalIRanges(x16[1:56])
class(xx)
max(xx)
min(xx)

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
All documentation is copyright its authors; we didn't write any of that.