generateNeighbours {beadarray} | R Documentation

## Generate Neighbours Matrix for BeadLevelList object

### Description

Generates a Neighbours matrix from the X and Y co-ordinates in a `BeadLevelList` object.

### Usage

    generateNeighbours(BLData, array, window = 30, margin = 10, thresh = 2.2)

### Arguments

`BLData` | `BeadLevelList`
`array` | integer specifying which strip/array to plot
`window` | numeric value, specifying window size (see below)
`margin` | numeric value, specifying size of window margin (see below)
`thresh` | numeric value, which determines how large links are removed. (see below)

### Details

generateNeighbours determines, for each bead on the array, which beads are next to it. It assumes that the beads are in a hexagonal lattice.

The algorithm used first links each bead to its 6 closest neighbours. It then removes the longest link if its squared length is more than `thresh` multiplied by the squared length of the next longest link. A similar process is applied to the 2nd and 3rd longest links.

Finally, any one way links are removed (i.e. a link between two beads is only preserved if each bead considers the other to be its neighbour).

To ease computation, the algorithm only computes neighbours of beads in a square window of side length `2*(window)` which travels across the array. Beads in a margin around the square, of width `(margin)`, are also considered as possible neighbours.

The Neighbours matrix is designed for use with the BASH functions.

### Value

A matrix with 6 columns, and a number of rows equal to the number of beads on the array. The neighbours of bead i are found in row i. 0 denotes a deleted link. (For example, if row 15 consists of 20, 35, 0, 0, 60, 4, then bead 15 is considered a neighbour of beads 4, 20, 35 and 60.)

### Author(s)

Jonathan Cairns

### Examples

    data(BLData)
    neighbours <- generateNeighbours(BLData, 1)

[Package beadarray version 1.10.0 Index]