GenomicRanges: Possible Bug
1
0
Entering edit mode
r.lowe • 0
@rlowe-8746
Last seen 7.1 years ago

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

 

genomicranges bug • 1.0k views
ADD COMMENT
0
Entering edit mode
@james-w-macdonald-5106
Last seen 10 hours ago
United States

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 COMMENT

Login before adding your answer.

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