[BioC] distanceToNearest for GRanges?

Valerie Obenchain vobencha at fhcrc.org
Tue Mar 27 15:35:50 CEST 2012


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