A wrapper around the RANN::nn2() function - nearest neighbor clustering.

runNearestNeighborClustering(
  object,
  n_pcs = NULL,
  k = 50,
  naming = "nn2_{priority}_{treetype}",
  searchtype = "priority",
  treetype = "bd",
  radius = 0,
  eps = 0,
  overwrite = FALSE,
  verbose = TRUE
)

Arguments

object

An object of class SPATA2 or, in case of S4 generics, objects of classes for which a method has been defined.

n_pcs

Numeric value or NULL. If numeric, specifies the number of principal components to use. If NULL, all principal components are used (as computed with runPCA()).

k

The maximum number of nearest neighbours to compute. The default value is set to the smaller of the number of columnns in data.

naming

Character value. A glue expression for the new cluster variable name.

searchtype

See details

treetype

Character vector. Character vector specifying the standard 'kd' tree or a 'bd' (box-decomposition, AMNSW98) tree which may perform better for larger point sets.

radius

Radius of search for searchtype='radius'

eps

Error bound: default of 0.0 implies exact nearest neighbour search

overwrite

Logical value. Must be TRUE to allow overwriting.

verbose

Logical. If TRUE, informative messages regarding the computational progress will be printed.

(Warning messages will always be printed.)

searchtypes

Character value. Either 'priority', 'standard' or 'radius '. See details for more.

Value

The updated input object, containing the added, removed or computed results.

Details

Search types: priority visits cells in increasing order of distance from the query point, and hence, should converge more rapidly on the true nearest neighbour, but standard is usually faster for exact searches. radius only searches for neighbours within a specified radius of the point. If there are no neighbours then nn.idx will contain 0 and nn.dists will contain 1.340781e+154 for that point.

Note

Requires the RANN packge.