Entering edit mode
alessandro.pastore
▴
20
@alessandropastore-10879
Last seen 6.1 years ago
I have a SummarizedExperiment (but we can consider it a GRanges). What I want is to reduce the number of intervals, keeping only one row for every identical adjacent mcol(gr)
, important is to also keep track of the new extend interval.
if a state pair is present also in non adjacent intervals (this second e.g. 1,1 pair has to be report independely from the first)
Thanks a lot!
gr <- GRanges(
seqnames = Rle(c("chr1"), c(12)),
ranges = IRanges(1:12*10, end = 1:12*10+5),
state1 = c(1,1,1,1,2,3,4,5,5,5,1,1),
state2 = c(1,1,1,2,2,2,5,5,6,6,1,1))
must became:
gr2 <- GRanges( seqnames = Rle(c("chr1"), c(8)), ranges = IRanges(start = c(10,40,50,60,70,80,90,110), end = c(35,45,55,65,75,85,105,125)), state1 = c(1,1,2,3,4,5,5,1), state2 = c(1,2,2,2,5,5,6,1))
Thanks this is nice, but it only list the first and last occurrence of a state pair, not if a state pair occur more than one time.
the pair 1,1 occurs at the begin and at the end of the GRanges but in you case is listed as occurring in a interval that span the whole GRanges. I need both interval one for each occurrence of adjacent values
Sorry, I edited my answer to do what you wanted.