**0**wrote:

I am using the nearest function to find nearest genomic range but it doesn't seem to return the correct result when I have a large list for subject.Reproducible example below. Here when using all subjects we get the 14093 as the nearest but actually it should be 14094. When testing just 14093 and 14094 this returns the correct result of 2 e.g. 14094

I have uploaded "grangestest.Rdata" to here https://collect.qmul.ac.uk/down?t=61123FRTCMKNEFIQ/59SHP073IU3MOA20452291G (available for 14 days).

`library(GenomicRanges)`

`region=GRanges("NC_007077.3",IRanges(3116601, 3116700)) `

`load("grangestest.Rdata") `

`nearest(region,prpr) `

`#Returns 14093 `

`nearest(region,c(prpr[14093],prpr[14094])) `

`#But 14094 is closer as this returns 2 `

**51k**• written 2.1 years ago by r.lowe •

**0**