## The example below is for illustration purpose only and does NOT
## reflect typical usage. This is because, for a one-time use, it is
## NOT advised to explicitely preprocess the input for findOverlaps()
## or countOverlaps(). These functions will take care of it and do a
## better job at it (by preprocessing only what's needed when it's
## needed, and release memory as they go).
query <- IRanges(c(1, 4, 9), c(5, 7, 10))
subject <- IRanges(c(2, 2, 10), c(2, 3, 12))
## Either the query or the subject of findOverlaps() can be preprocessed:
ppsubject <- NCList(subject)
hits1 <- findOverlaps(query, ppsubject)
hits1
ppquery <- NCList(query)
hits2 <- findOverlaps(ppquery, subject)
hits2
## Note that 'hits1' and 'hits2' contain the same hits but not in the
## same order.
stopifnot(identical(sort(hits1), sort(hits2)))
Run the code above in your browser using DataLab