I have this granges object:
gr <- GRanges(
seqnames = c(rep("chr1", 3)),
IRanges(start = c(1, 10, 20), end = c(5, 15, 25)),
group = c("A", "A", "B")
)
I would like to concatenate the events that are the same group (f.ex A) joining the intervals, so the final granges object should be:
gr <- GRanges(
seqnames = c(rep("chr1", 3)),
IRanges(start = c(1,20), end = c(15, 25)),
group = c("A", "B")
)
I have tried with reduce and split options but this is not what I am looking for.