Question: How to sort set of GRanges object in the list by increasing order?
0
gravatar for Jurat Shahidin
2.7 years ago by
Italy
Jurat Shahidin60 wrote:

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

 

ADD COMMENTlink modified 2.7 years ago • written 2.7 years ago by Jurat Shahidin60
Answer: How to sort set of GRanges object in the list by increasing order?
2
gravatar for Jurat Shahidin
2.7 years ago by
Italy
Jurat Shahidin60 wrote:

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 COMMENTlink modified 2.7 years ago • written 2.7 years ago by Jurat Shahidin60

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 REPLYlink written 2.7 years ago by Hervé Pagès ♦♦ 13k

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 REPLYlink written 2.7 years ago by Jurat Shahidin60
Answer: How to sort set of GRanges object in the list by increasing order?
1
gravatar for Hervé Pagès
2.7 years ago by
Hervé Pagès ♦♦ 13k
United States
Hervé Pagès ♦♦ 13k wrote:

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 COMMENTlink written 2.7 years ago by Hervé Pagès ♦♦ 13k

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 REPLYlink written 2.7 years ago by Jurat Shahidin60
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 116 users visited in the last hour