Skip to content

[Bioc-devel] "nearest" & related methods for GRangesList & friends?

4 messages · Ryan, Hervé Pagès

#
Hello,

I recently found myself in want of a nearest method that handles 
GRangesList objects. Is there any plan to add one? I just want to define 
"nearest" for elements of a GRangesList by the shortest distance between 
any query range and any subject range. Obviously I can do this by 
unlisting the GRangesList, calling nearest, and then post-processing to 
figure out which element of the original GRangesList includes the 
nearest range, but it would be nice to have a function that already does 
this for me.

-Ryan
#
Hi Ryan,
On 05/22/2014 03:38 PM, Ryan C. Thompson wrote:
Not that I know of. I guess most of the times it's probably good enough
to call range() on both GRangesList objects before passing them to
nearest(). What's the use case for caring about "gaps" within each
GRangesList element?
The easy one is a "nearest" method between a GRanges and a GRangesList.
Is it what you need? That would cover finding the nearest gene or
transcript for ChIPseq peaks when the exon structure actually matters
(seems like it would matter only for peaks that fall inside more than
1 transcript).

Or do you need a method that operates on 2 GRangesList objects? Can't
think of a use case for that one. Finding the nearest gene or transcript
for junction reads?

Thanks,
H.

  
    
#
Here is my use case (relevant lines highlighted):

https://gist.github.com/anonymous/0cd0c926fb21a8d62fcc#file-annotatepeaks-r-L49-L54

The idea is to annotate each peak with the Entrez ID of the nearest 
transcription start site. Each Entrez ID can have multiple transcripts, 
hence multiple TSS, so I basically want to call nearest with a GRanges 
of peaks against a GRangesList of TSS (each TSS is a range with a width 
of 1 containing the first base pair of a transcript). I don't personally 
need a method that works for a GRangesList query.

-Ryan
On Fri 23 May 2014 11:13:24 AM PDT, Herv? Pag?s wrote:
#
On 05/23/2014 11:20 AM, Ryan C. Thompson wrote:
Good. nearest() between a GRanges and a GRangesList is the easy one:

   togroup(subject, nearest(query, unlist(subject, use.names=FALSE)))

Is this doing what you need?

Cheers,
H.