collection[["1"]] # NULL, does not exist
collection[c(TRUE, FALSE)] # first element
col2 <- IntegerList(two = int2, one = int1)
sum(col1)  # equivalent to (but faster than) 'sapply(col1, sum)'
mean(col1)  # equivalent to 'sapply(col1, mean)'

### Title: Provide a class name for displaying to users

### Title: Coverage across a set of ranges
### Aliases: coverage-methods coverage coverage,Ranges-method
## B. SOME MATHEMATICAL PROPERTIES OF THE coverage() FUNCTION
## PROPERTY 1: The coverage vector is not affected by reordering the
## Of course, if the ranges are shifted and/or assigned weights, then
## this doesn't hold anymore, unless the 'shift' and/or 'weight'
## PROPERTY 2: The coverage of the concatenation of 2 Ranges objects 'x'
## and 'y' is the sum of the 2 individual coverage vectors:
## Note that, because adding 2 vectors in R recycles the shortest to
## the length of the longest, the following is generally FALSE:
## It would only be TRUE if the 2 coverage vectors we add had the same
## length, which would only happen by chance. By using the same 'width'
## value when we computed the 2 coverages previously, we made sure they
## Because of properties 1 & 2, we have:
## PROPERTY 3: Multiplying the weights by a scalar has the effect of
## multiplying the coverage vector by the same scalar:
## Because of properties 1 & 2 & 3, we have:
## PROPERTY 4: Using the sum of 2 weight vectors produces the same
## result as using the 2 weight vectors separately and summing the
## PROPERTY 5: Repeating any input range N number of times is
## equivalent to multiplying its assigned weight by N:
## In particular, if 'weight' is not supplied:
## PROPERTY 6: If none of the input range actually gets clipped during
##     sum(cvg) = sum(width(x) * weight)
## Note that this property is sometimes used in the context of a
## ChIP-Seq analysis to estimate "the number of reads in a peak", that
## is, the number of short reads that belong to a peak in the coverage
## vector computed from the genomic locations (a.k.a. genomic ranges)
## of the aligned reads. Because of property 6, the number of reads in
## a peak is approximately the area under the peak divided by the short
## PROPERTY 7: If 'weight' is not supplied, then disjoining or reducing
## the ranges before calling coverage() has the effect of "shaving" the
## With a set of distinct single positions:
## Each list element in 'shift' and 'weight' gets recycled to the length
# 1st coverage vector is an integer-Rle, 2nd is a numeric-Rle