distanceToNearest for GRanges?
1
0
Entering edit mode
Janet Young ▴ 740
@janet-young-2360
Last seen 5.1 years ago
Fred Hutchinson Cancer Research Center,…
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 -------------------------------------------------------------------
Cancer Cancer • 1.1k views
ADD COMMENT
1
Entering edit mode
Malcolm Cook ★ 1.6k
@malcolm-cook-6293
Last seen 4 months ago
United States
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@r-project.org [bioconductor- bounces@r-project.org] On Behalf Of Janet Young [jayoung@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
ADD COMMENT
0
Entering edit mode
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
ADD REPLY
0
Entering edit mode
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 >
ADD REPLY

Login before adding your answer.

Traffic: 558 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