Question: SOLVED. finding distance to nearest neighbour (non-self) within a list in GenomicRanges
0
gravatar for rmash
11 days ago by
rmash0
rmash0 wrote:

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
ADD COMMENTlink modified 11 days ago • written 11 days ago by rmash0
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 16.09
Traffic: 424 users visited in the last hour