NNGraphParam-class | R Documentation |
Run community detection algorithms on a nearest-neighbor (NN) graph within clusterRows
.
NNGraphParam(
shared = TRUE,
k = 10,
...,
BNPARAM = KmknnParam(),
num.threads = 1,
BPPARAM = NULL,
cluster.fun = "walktrap",
cluster.args = list()
)
SNNGraphParam(
k = 10,
type = "rank",
BNPARAM = KmknnParam(),
num.threads = 1,
BPPARAM = NULL,
cluster.fun = "walktrap",
cluster.args = list()
)
KNNGraphParam(
k = 10,
directed = FALSE,
BNPARAM = KmknnParam(),
num.threads = 1,
BPPARAM = NULL,
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)
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 |
BNPARAM |
A BiocNeighborParam object specifying the nearest neighbor algorithm. |
num.threads |
Integer scalar specifying the number of threads to use. |
BPPARAM |
Deprecated, use |
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.args |
Further arguments to pass to the chosen |
type |
A string specifying the type of weighting scheme to use for shared neighbors. |
directed |
A logical scalar indicating whether the output of |
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. |
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.
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
).
Aaron Lun
makeSNNGraph
and related functions, to build the graph.
cluster_walktrap
and related functions, to perform community detection.
clusterRows(iris[,1:4], NNGraphParam())
clusterRows(iris[,1:4], NNGraphParam(k=5))
# Note: cluster_louvain is randomized as of igraph 1.3.0.
set.seed(100)
clusterRows(iris[,1:4], NNGraphParam(cluster.fun="louvain"))
# On the plus side, we can finally pass a resolution parameter.
set.seed(100)
clusterRows(iris[,1:4], NNGraphParam(cluster.fun="louvain",
cluster.args=list(resolution=0.5)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.