Entering edit mode
Dear all :
I have list of GRanges objects, and I intend to combine them to get new GRangesList respectively. I tried several possible way to make this happen, but none of them addressed my issue. Can anyone point me how to accomplish this task easily? How to combine GRangesList ? Any idea ? Thanks a lot
mini example :
myList_old <- GRangesList( foo = GRanges( seqnames=Rle("chr1", 3),ranges=IRanges(c(2,7,16), c(5,14,20)), rangeName=c("a1", "a2", "a3"), score=c(4, 6,9)), bleh = GRanges(seqnames=Rle("chr1", 3),ranges=IRanges(c(4,13,26), c(11,17,28)), rangeName=c("b1", "b2", "b3"), score=c(11, 7, 8)) ) myList_new <- GRangesList( foo = GRanges( seqnames=Rle("chr2", 3),ranges=IRanges(c(32,51,78), c(45,67,83)), rangeName=c("a9", "a12", "a19"), score=c(34, 46,29)), bleh = GRanges(seqnames=Rle("chr3", 3),ranges=IRanges(c(53,83,106), c(71,97,128)), rangeName=c("b51", "b72", "b93"), score=c(31, 17, 28)) )
my desired output would be :
myFinal_grs <- GRangesList( foo = GRanges( seqnames=Rle(c("chr1", "chr2"), c(3,3)),ranges=IRanges(c(2,7,16,32,51,78), c(5,14,20,45,67,83)), rangeName=c("a1", "a2", "a3","a9","a12","a19"), score=c(4, 6,9,34,46,29)), bleh = GRanges(seqnames=Rle(c("chr1","chr3"), c(3,3)),ranges=IRanges(c(4,13,26,53,83,106), c(71,97,128)), rangeName=c("b1", "b2", "b3","b51","b72","b93"), score=c(11, 7, 8,31,17,28)) )
I intend to combine GRanges object from above list. Is there any way to get this done easily?
Best regards:
Jurat
Thanks your quick respond. Your solution also raised warning message. Should I suppress this warning? why this warning happen?
Just make sure the seqlevels are the same between the two objects.