Search
Question: GenomicRanges: Possible Bug
0
gravatar for r.lowe
7 weeks ago by
r.lowe0
r.lowe0 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

 

ADD COMMENTlink modified 7 weeks ago by James W. MacDonald45k • written 7 weeks ago by r.lowe0
0
gravatar for James W. MacDonald
7 weeks ago by
United States
James W. MacDonald45k wrote:

You are making a mistake, thinking that the order is staying the same.

> prpr[nearest(region, prpr)]
GRanges object with 1 range and 0 metadata columns:
         seqnames             ranges strand
            <Rle>          <IRanges>  <Rle>
  [1] NC_007077.3 [2966428, 2966429]      -
  -------
  seqinfo: 884 sequences from an unspecified genome; no seqlengths

## Just the two positions

> prpr[14093:14094][nearest(region, prpr[14093:14094])]
GRanges object with 1 range and 0 metadata columns:
         seqnames             ranges strand
            <Rle>          <IRanges>  <Rle>
  [1] NC_007077.3 [3079949, 3079950]      +
  -------
  seqinfo: 884 sequences from an unspecified genome; no seqlengths

## Bump out to a larger window

> prpr[14075:14125][nearest(region, prpr[14075:14125])]
GRanges object with 1 range and 0 metadata columns:
         seqnames             ranges strand
            <Rle>          <IRanges>  <Rle>
  [1] NC_007077.3 [2966428, 2966429]      -
  -------
  seqinfo: 884 sequences from an unspecified genome; no seqlengths
ADD COMMENTlink written 7 weeks ago by James W. MacDonald45k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.2.0
Traffic: 183 users visited in the last hour