SOLVED. finding distance to nearest neighbour (non-self) within a list in GenomicRanges
0
2
Entering edit mode
rmash ▴ 20
@rmash-21927
Last seen 2.7 years ago

I'm interested in finding the nearest neighbor to each gene within a list.

> distanceToNearest(x = sub.gr, subject = sub.gr)
Hits object with 5803 hits and 1 metadata column:
         queryHits subjectHits |  distance
         <integer>   <integer> | <integer>
     [1]         1           1 |         0
     [2]         2           2 |         0
     [3]         3           3 |         0
     [4]         4           4 |         0
     [5]         5           5 |         0
     ...       ...         ... .       ...
  [5799]      5799        5799 |         0
  [5800]      5800        5800 |         0
  [5801]      5801        5800 |         0
  [5802]      5802        5802 |         0
  [5803]      5803        5802 |         0
  -------
  queryLength: 5803 / subjectLength: 5803

It effectively finds itself in the list and so distance = 0. Is there a way to find the second Nearest?

SOLUTION

> distanceToNearest(x = sub.gr)
Hits object with 5301 hits and 1 metadata column:
         queryHits subjectHits |  distance
         <integer>   <integer> | <integer>
     [1]         1           2 |        38
     [2]         2           1 |        38
     [3]         3           4 |      2613
     [4]         4           5 |       297
     [5]         5           4 |       297
     ...       ...         ... .       ...
  [5297]      5799        5800 |        52
  [5298]      5800        5801 |         0
  [5299]      5801        5800 |         0
  [5300]      5802        5803 |         0
  [5301]      5803        5802 |         0
  -------
  queryLength: 5803 / subjectLength: 5803
GenomicRanges GenomicFeatures grange distanceToNearest R • 436 views
ADD COMMENT

Login before adding your answer.

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