[BioC] distanceToNearest for GRanges?

Valerie Obenchain vobencha at fhcrc.org
Wed Apr 11 20:44:25 CEST 2012


Hi Malcom,

For distanceToNearest() I started with the ranges method in IRanges. 
Along the way I did find that distance,GenomicRanges,GenomicRanges was 
not handling the situation of '*','-' and '*','+' strand pairs (simply 
returning NA). Now those strand combinations are considered compatible 
just as '-','-' and '+','+' are.

Let me know if you run into problems with the method or have other 
suggestions.

Take care,
Valerie

On 04/11/2012 09:46 AM, Cook, Malcolm wrote:
> thanks Valerie,
>
> Did you happen to vet the logic of my implementation, or did you just code it lower level from first principals?
>
> Cheers,
>
> ~Malcolm
>
>> -----Original Message-----
>> From: Valerie Obenchain [mailto:vobencha at fhcrc.org]
>> Sent: Wednesday, April 11, 2012 11:13 AM
>> To: Janet Young
>> Cc: Cook, Malcolm; bioconductor at r-project.org
>> Subject: Re: [BioC] distanceToNearest for GRanges?
>>
>> This has been added to GenomicRanges 1.9.4. You will also need IRanges
>> 1.15.2.
>>
>> Valerie
>>
>>
>> On 03/27/2012 10:36 AM, Janet Young wrote:
>>> Hi,
>>>
>>> thank you both - very helpful.
>>>
>>> Janet
>>>
>>>
>>>
>>> On Mar 27, 2012, at 6:35 AM, Valerie Obenchain wrote:
>>>
>>>> Hi Janet, Malcom,
>>>>
>>>> Yes, we can add distanceToNearest for GRanges. This will probably
>> happen after the release (i.e., next week). I'll post back here when it's
>> complete.
>>>> Valerie
>>>>
>>>>
>>>> On 03/26/12 16:26, Cook, Malcolm wrote:
>>>>> Janet,
>>>>>
>>>>> In the mean time....
>>>>>
>>>>> distanceToNearest.GRanges<- function
>> (query,subject=query,...,.AS=DataFrame) {
>>>>>    ## PURPOSE: an implementation of distanceToNearest for GRanges in
>>>>>    ## terms of 'nearest' and 'distance' whose return value is shaped
>>>>>    ## like that of IRange's 'nearest', by default, but you can ask for
>>>>>    ## the result .AS=data.table or .AS=data.frame if you prefer.
>>>>>     if(missing(subject)) {
>>>>>       nearestSubjectIndex<-nearest(query,...)
>>>>>     } else {
>>>>>       nearestSubjectIndex<-nearest(query,subject,...)
>>>>>     }
>>>>>     queryHasNearest<-! is.na(nearestSubjectIndex)
>>>>>     queryIndex<-which(queryHasNearest)
>>>>>     queryHavingNearest<-query[queryIndex]
>>>>>     nearestSubjectIndex<-nearestSubjectIndex[queryIndex]
>>>>>     nearestSubject<-subject[nearestSubjectIndex]
>>>>>     d<-distance(queryHavingNearest,nearestSubject)
>>>>>     .AS(query=queryIndex
>>>>>                ,subject=nearestSubjectIndex
>>>>>                ,distance=d)
>>>>> }
>>>>>
>>>>> You've asked so many questions in this forum whose answer I made use
>> of that I must owe you this tidbit....
>>>>> Lurkers, and fellow travelers, I welcome corrections and stylistic
>> suggestions.
>>>>> Cheers,
>>>>>
>>>>> Malcolm Cook
>>>>>
>>>>>
>>>>> ________________________________________
>>>>> From: bioconductor-bounces at r-project.org [bioconductor-bounces at r-
>> project.org] On Behalf Of Janet Young [jayoung at fhcrc.org]
>>>>> Sent: Monday, March 26, 2012 4:42 PM
>>>>> To: bioconductor at r-project.org
>>>>> Subject: [BioC] distanceToNearest for GRanges?
>>>>>
>>>>> Hi there,
>>>>>
>>>>> Any plans to implement distanceToNearest for GRanges objects?   That
>> would be really useful for me.
>>>>> thanks,
>>>>>
>>>>> Janet
>>>>>
>>>>>
>>>>> -------------------------------------------------------------------
>>>>>
>>>>> Dr. Janet Young
>>>>>
>>>>> Tapscott and Malik labs
>>>>>
>>>>> Fred Hutchinson Cancer Research Center
>>>>> 1100 Fairview Avenue N., C3-168,
>>>>> P.O. Box 19024, Seattle, WA 98109-1024, USA.
>>>>>
>>>>> tel: (206) 667 1471 fax: (206) 667 6524
>>>>> email: jayoung  ...at...  fhcrc.org
>>>>>
>>>>>
>>>>> -------------------------------------------------------------------
>>>>>
>>>>> _______________________________________________
>>>>> Bioconductor mailing list
>>>>> Bioconductor at r-project.org
>>>>> https://stat.ethz.ch/mailman/listinfo/bioconductor
>>>>> Search the archives:
>> http://news.gmane.org/gmane.science.biology.informatics.conductor
>>>>> _______________________________________________
>>>>> Bioconductor mailing list
>>>>> Bioconductor at r-project.org
>>>>> https://stat.ethz.ch/mailman/listinfo/bioconductor
>>>>> Search the archives:
>> http://news.gmane.org/gmane.science.biology.informatics.conductor



More information about the Bioconductor mailing list