I am looking for an algorithm that classifies (with letters) a set of intervals according to their overlap.
-
The output should associate each overlapping interval with the same letter, thus constituting a unique group.
-
Intervals that overlap with multiple groups will be classified with several letters corresponding to each unique group.
-
Non-overlapping intervals also constitute a unique group.
Graphically the problem is as follows:
I am working in R and my intervals are these:
structure(list(Interval = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), Start = c(5.3,
6.5, 7.6, 7.8, 8, 8.3, 8.5, 8.7, 8.8, 9.9), End = c(7.5, 8.7,
9.8, 10, 10.2, 10.5, 10.7, 10.9, 11, 12.1)), row.names = c(NA,
-10L), spec = structure(list(cols = list(Interval = structure(list(), class = c("collector_double",
"collector")), Start = structure(list(), class = c("collector_double",
"collector")), End = structure(list(), class = c("collector_double",
"collector"))), default = structure(list(), class = c("collector_guess",
"collector")), delim = "\t"), class = "col_spec"), class = c("spec_tbl_df","tbl_df", "tbl", "data.frame"))
I think the ivs
package may have the solution but I don’t know the procedure.
Your example is oversimplified. Can you do the labeling for this plot (created based on your data)? i.stack.imgur.com/WaBlx.png