NNGraphParam-class {bluster} | R Documentation

## Graph-based clustering

### Description

Run community detection algorithms on a nearest-neighbor (NN) graph within `clusterRows`.

### Usage

    NNGraphParam(
      shared = TRUE,
      k = 10,
      ...,
      BNPARAM = KmknnParam(),
      BPPARAM = SerialParam(),
      cluster.fun = "walktrap",
      cluster.args = list()
    )

    SNNGraphParam(
      k = 10,
      type = "rank",
      BNPARAM = KmknnParam(),
      BPPARAM = SerialParam(),
      cluster.fun = "walktrap",
      cluster.args = list()
    )

    KNNGraphParam(
      k = 10,
      directed = FALSE,
      BNPARAM = KmknnParam(),
      BPPARAM = SerialParam(),
      cluster.fun = "walktrap",
      cluster.args = list()
    )

    ## S4 method for signature 'ANY,SNNGraphParam'
    clusterRows(x, BLUSPARAM, full = FALSE)

    ## S4 method for signature 'ANY,KNNGraphParam'
    clusterRows(x, BLUSPARAM, full = FALSE)

### Arguments

`shared` | Logical scalar indicating whether a shared NN graph should be constructed.
`k` | An integer scalar specifying the number of nearest neighbors to consider during graph construction.
`...` | Further arguments to pass to `SNNGraphParam` (if `shared=TRUE`) or `KNNGraphParam`.
`BNPARAM` | A BiocNeighborParam object specifying the nearest neighbor algorithm.
`BPPARAM` | A BiocParallelParam object to use for parallel processing.
`cluster.fun` | Function specifying the method to use to detect communities in the NN graph. The first argument of this function should be the NN graph and the return value should be a communities object. Alternatively, this may be a string containing the suffix of any igraph community detection algorithm. For example, `cluster.fun="louvain"` will instruct `clusterRows` to use `cluster_louvain`. Defaults to `cluster_walktrap`.
`cluster.args` | Further arguments to pass to the chosen `cluster.fun`.
`type` | A string specifying the type of weighting scheme to use for shared neighbors.
`directed` | A logical scalar indicating whether the output of `buildKNNGraph` should be a directed graph.
`x` | A matrix-like object containing expression values for each observation (row) and dimension (column).
`BLUSPARAM` | A NNGraphParam object.
`full` | Logical scalar indicating whether the graph-based clustering objects should be returned.

### Details

The SNNGraphParam and KNNGraphParam classes are both derived from the NNGraphParam virtual class. This former will perform clustering with a shared nearest-neighbor (SNN) graph while the latter will use a simpler k-nearest neighbor (KNN) graph - see `?makeSNNGraph` for details.

To modify an existing NNGraphParam object `x`, users can simply call `x[[i]]` or `x[[i]] <- value` where `i` is any argument used in the constructor. The exception is that of `shared`, which is not a valid `i` as it is implicit in the identity of the class.

### Value

The constructors will return a NNGraphParam object with the specified parameters. If `shared=TRUE`, this is a SNNGraphParam object; otherwise it is a KNNGraphParam object.

The `clusterRows` method will return a factor of length equal to `nrow(x)` containing the cluster assignments. If `full=TRUE`, a list is returned with `clusters` (the factor, as above) and `objects`; the latter is a list with `graph` (the graph) and `communities` (the output of `cluster.fun`).

### Author(s)

Aaron Lun

### See Also

`makeSNNGraph` and related functions, to build the graph.

`cluster_walktrap` and related functions, to perform community detection.

### Examples

    clusterRows(iris[,1:4], NNGraphParam())
    clusterRows(iris[,1:4], NNGraphParam(k=5))
    clusterRows(iris[,1:4], NNGraphParam(cluster.fun="louvain"))

[Package bluster version 1.2.1 Index]