[BioC] nearest for GRanges ignoring overlapping ranges

Valerie Obenchain vobencha at fhcrc.org
Tue Aug 21 19:08:14 CEST 2012


Hi Janet,

This is fixed in GenomicRanges 1.9.53 in devel. I'll look to port these 
changes to release today.

Valerie


On 08/20/2012 01:42 PM, Janet Young wrote:
> Hi there,
>
> I'm using the release version of GenomicRanges (1.8.12).   The nearest function is giving me an answer on my GRanges objects, but it's not including overlapping ranges (the help page says it should, and that behaviour makes sense to me).  The GRanges version of nearest is ignoring overlapping ranges, whereas the IRanges version is reporting them.   I think the code below will demonstrate the issue(?)
>
> thanks very much,
>
> 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
>
>
> -------------------------------------------------------------------
>
>
>
>
>
> library(GenomicRanges)
>
> gr1<- GRanges(seqnames=c("chr1","chr1","chr1","chr2"),ranges=IRanges(start=c(10,20,30,10),width=10) )
>
> gr2<- GRanges(seqnames=c("chr1","chr1"),ranges=IRanges(start=c(15,20),width=2) )
>
> ### using the GRanges version of nearest ignores overlapping ranges
> near1<- nearest( gr1, gr2)
> # [1]  2  1  2 NA
> ### but gr1[1] overlaps gr2[1], so near1[1] should be 1
> ### and gr1[2] overlaps gr2[2], so near1[2] should be 2
>
> #### using the IRanges version of nearest gives us the right answer. Just doing the chr1 ranges here:
> near2<- nearest( ranges( gr1[which(seqnames(gr1)=="chr1")]), ranges(gr2[which(seqnames(gr2)=="chr1")])  )
> # [1] 1 2 2
> #### this looks right
>
> sessionInfo()
>
> R version 2.15.1 (2012-06-22)
> Platform: i386-apple-darwin9.8.0/i386 (32-bit)
>
> locale:
> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
>
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
>
> other attached packages:
> [1] GenomicRanges_1.8.12 IRanges_1.14.4       BiocGenerics_0.2.0
>
> loaded via a namespace (and not attached):
> [1] stats4_2.15.1
>
> _______________________________________________
> 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