How to sort set of GRanges object in the list by increasing order?
2
0
Entering edit mode
@jurat-shahidin-9488
Last seen 4.7 years ago
Chicago, IL, USA

Dear all:

I am seeking any efficient way that sorting set of GRanges objects in the list by increasing order. I know sort method from GenomicRangs do this task, but it is very generic. The case that I faced bit of different, and using sort method won't effective to solve my problems. Does anyone knows how to accomplish this task more efficiently? Many thanks

# example

grs.li <- list(gr1, gr2, gr3, gr4, ...)

# desired output that after sorting

out_1 <-  list(gr1, gr2, gr3, gr4)   # the very beginning, no need to sort
out_2 <-  list(gr2, gr1, gr3, gr4)   # first sorting
out_3 <-  list(gr3, gr1, gr2, gr4)   # second sorting
out_4 <-  list(gr4, gr1, gr2, gr3)   # third sorting

according to the format of desired format that proposed, how can I get this kind of sorting more efficiently. I mean, carrying out this kind of sort operation is also appreciated. Thanks

Best regards:

JS

 

granges grangeslist genomicranges • 1.6k views
ADD COMMENT
2
Entering edit mode
@jurat-shahidin-9488
Last seen 4.7 years ago
Chicago, IL, USA

Regarding the issue that I asked, I figured out my own solution as follows:

out_1 <- grs.li[seq_len(length(grs.li))]
out_2 <- grs.li[c(2, seq_len(length(grs.li))[-2])]
out_3 <- grs.li[c(3, seq_len(length(grs.li))[-3])]
out_4 <- grs.li[c(4, seq_len(length(grs.li))[-4])]

this solution is bit of generic, but it works pretty well if user need to permute set of GRanges object in the list. Cheers.

JS

ADD COMMENT
0
Entering edit mode

I see. You just wanted to permute the elements of a list. This has nothing to do with sorting them by increasing order. There is also nothing specific to GRanges objects here.

ADD REPLY
0
Entering edit mode

I admit my post was confused readers and question was not clearly motivated. I will do my best in my further post. Cheers.

JS

ADD REPLY
1
Entering edit mode
@herve-pages-1542
Last seen 7 days ago
Seattle, WA, United States

Hi Jurat,

Unfortunately, it's again very hard to help you. The code you're showing doesn't make much sense. Before you can sort a set of things you need to be able to compare these things between each other. More precisely, given 2 things in the set, you need to be able to tell which one is greater than the other one. So in your case, your final order (what you call third sorting) is gr4, gr1, gr2, gr3. But what is your criteria for deciding that gr3 is greater than gr2, gr2 greater than gr1, and gr1 greater than gr4? You're not saying anything about what makes a GRanges object greater than another! Once we know this, we might be able to help you sort a set of GRanges objects.

Thanks,

H.

ADD COMMENT
0
Entering edit mode

Dear Herve:

Thanks for your respond. The reason I raised this question on this sites, I had unexpected bug when I ran unit testing on my own developed packages - MSPC, and I aware that it possibly caused by order of GRanges object in the list if multiple testing happens. It is just my guess work and try to do this kind of sorting. However, I got my own possible solution how to carry out this kind of sorting. Thanks again for your supporting.

JS

ADD REPLY

Login before adding your answer.

Traffic: 490 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6