Hi :
I have GRangesList grs
to find overlap and other meta-analyses, after several workflows, I obtained resGR
, which needed to be relisted. However, I come up with the solution to relist `resGR` as GRangesList, but I got an error. My solution works fine with data.frame, but can't work with the S4 class. Can anyone point me out how to fix this error? Is there any simplest way to relist GRanges
respect to GRangesList
?
Here is input GRangesList :
grs <- GRangesList( bar= GRanges(seqnames = Rle("chr1",4), IRanges(c(8,18,33,53), c(14,21,39,61)), score=c(48,7,10,8)), cat = GRanges(seqnames = Rle("chr1",4), IRanges( c(6,15,20,44), c(10,17,34,51)), score=c(54,21,14,12)), foo= GRanges(seqnames = Rle("chr1",2), IRanges(c(11,43), c(36,49)), score=c(49,13)) )
After several workflows, I obtained resGR
:
resGR <- GRanges(seqnames = Rle("chr1",9), IRanges(c(53,8,6,15,11,44,43,44,43), c(61,14,10,17,36,51,49,51,49)), score=c(8,48,54,21,49,12,13,12,13))
I want to relist resGR
respect to grs
, so I come up with this solution (my attempt might not be desired, perhaps there is might have a more straightforward way to do this); Here is my solution:
lapply(grs, function(x) resGR[do.call(paste, resGR) %in% do.call(paste, x),])
I have this error:
Error in do.call(paste, resGR) : second argument must be a list
Perhaps my attempt is not feasible, but it works well if use data.frame. Is there any simple and vectorized approach to get this done? Any idea? Thanks a lot.
Best regards:
Jurat
I'm not sure I totally follow what you're trying to do, but does
resGR
now contain a subset of the ranges in your originalGRangesList
, but in a different order? Any you're trying to match them back to the original? Is it intentional that you have one fewer range inresGR
?Dear Mike:
Yes,
in
resGR
was generated asGRanges
which contains a subset of rangesgrs
(where the order of ranges was different).
Yes, I want backresGR
as GRangesList.resGR
has fewer ranges because some of the ranges were filtered out by a threshold. Why my solution won't work with S4 class? Is there any straightforward, simplest way to do this? Thank youBest regards:
Jurat