a <- RangedData(IRanges(c(1,2,3),c(4,5,6)), score = c(10L, 2L, NA))
RangedDataList(sample1 = a, sample2 = b)

### Title: Selection of ranges and columns

rl <- RangesList(chr1 = IRanges(c(1, 5), c(3, 6)))
as(rl, "RangedSelection") # same as above

### Aliases: class:Ranges Ranges-class Ranges length,Ranges-method
###   width,Ranges-method end,Ranges-method mid mid,Ranges-method start<-
###   width<- end<- isEmpty,Ranges-method as.matrix,Ranges-method
## Use the replacement methods to resize the ranges:

end(x) <- start(x)            # equivalent to width(x) <- 0
start(x)[3] <- end(x)[3] - 2  # resize the 3rd range

### Title: Comparing and ordering ranges
## A. ELEMENT-WISE (AKA "PARALLEL") COMPARISON OF 2 Ranges OBJECTS
## Handling of zero-width ranges (a.k.a. empty ranges):
## Note that x1[2] and x1[6] are empty ranges on the edge of non-empty
## range IRanges(12, 15). Even though -1 and 3 could also be considered
## valid codes for describing these configurations, compare()
## considers x1[2] and x1[6] to be *adjacent* to IRanges(12, 15), and
## B. match(), selfmatch(), %in%, duplicated(), unique()

compare(x0, y0) < 0   # equivalent to 'x0 < y0'
compare(x0, y0) == 0  # equivalent to 'x0 == y0'
compare(x0, y0) > 0   # equivalent to 'x0 > y0'

###   RangesList-class SimpleRangesList-class RangesList SimpleRangesList
# edit the width of the ranges in the list

named <- RangesList(one = range1, two = range2)
start(named) # same as start(c(range1, range2))
RangesList(range1, range2, universe = "hg18")
collection <- RangesList(one = range1, range2)

### Aliases: rdapply rdapply,RDApplyParams-method RDApplyParams-class
###   RDApplyParams applyFun applyFun,RDApplyParams-method applyFun<-

rd <- RangedData(ranges, score, space = c("chr1","chr2","chr1"))
rdapply(params) # list(chr1 = 2L, chr2 = 1L)
params <- RDApplyParams(rd, function(rd, x) nrow(rd)*x, list(x = 2))
rdapply(params) # list(chr1 = 4L, chr2 = 2L)
rules <- FilterRules(filter = score > cutoff)
params <- RDApplyParams(rd, countrows, filterRules = rules)
rdapply(params) # list(chr1 = 2L, chr2 = 0L)
rules <- FilterRules(list(fun = function(rd) rd[["score"]] < 2),
rdapply(params) # list(chr1 = 1L, chr2 = 0L)
rdapply(params) # list(chr1 = 1L, chr2 = 1L)
params <- RDApplyParams(rd, countrows, simplify = TRUE)
rdapply(params) # c(chr1 = 2L, chr2 = 1L)
params <- RDApplyParams(rd, countrows, reducerFun = unlist,
reducerParams = list(use.names = FALSE))