Counting overlaps as expected with R data.table foverlaps() or IRanges
问题 I'm having difficulty counting overlaps of intervals as I would expect. Here is an R data.table with intervals defined by start to end: > library(data.table) > dt1 = data.table(start=c(1, 5, 3), end=c(10, 15, 8)) > print(dt1) start end 1: 1 10 2: 5 15 3: 3 8 Here is how I would consider overlaps for these intervals, from 0 to 20: [0, 1]: 0 (there are no intervals here) [1, 3]: 1 (there is only one interval here, from [1, 10]) [3, 5]: 2 (two intervals here, both [1, 10] and [3, 8]) [5, 8]: 3