graphClustering: Spectral Graph Clustering

Description Usage Arguments Value Examples

View source: R/cluster.R

Description

Computes a spectral graph-based clustering, either on principal components or diffusion components. A k-nearest neighbor graph is computed, its edges are optionally weighted by the Jaccard overlap of cells' neighborhoods, and then a clustering is computed with either the Louvain or Infomap algorithms. The resultant clustering is stored as a column in the slot @group.ids. The number of detected clusters is sensitive to the nearest neighbor parameter, and several should be investigated.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
graphClustering(
  object,
  dim.use = c("pca", "dm"),
  cells.use = NULL,
  which.dims = which(object@pca.sig),
  num.nn = 30,
  do.jaccard = TRUE,
  method = c("Louvain", "Infomap"),
  group.id = method
)

Arguments

object

An URD object

dim.use

(Character) Calculate on principal components (pca) or diffusion components (dm)

cells.use

(Character vector) Which cells to include in the clustering (default is NULL, which uses all cells)

which.dims

(Numeric vector) Which PCs (or diffusion components) to use. Defaults to the significant PCs. (The default will probably work with diffusion components, though it is non-sensical in that case.)

num.nn

(Numeric or numeric vector) How many nearest-neighbors to use in the k-nn graph. (If multiple values are provided, multiple clusterings are calculated.)

do.jaccard

(Logical) Weight edges in the k-nn graph according to their Jaccard overlap?

method

(Character) Clustering method to use (Louvain)

group.id

(Character) Prefix to use for clustering name (Default is method). Number of nearest neighbors is appended.

Value

An URD object with cluster identities saved in @group.ids in the column named group.id.

Examples

1
2
3
4
5
6
7
8
# Try several different nearest neighbor parameters
# Output will be stored as Infomap-10, Infomap-15, ... in object.6s.mnn@group.ids
object.6s.mnn <- graphClustering(object.6s.mnn, num.nn = c(10,15,20,30,40), 
method="Infomap", do.jaccard = T)

# Cluster on the diffusion map instead of PCA
# Output will be stored as Louvain-DM-10, Louvain-DM-20, Louvain-DM-30, etc.
object <- graphClustering(object, dim.use="dm", num.nn = c(10,20,30,40), method="Louvain", do.jaccard=T, group.id="Louvain-DM")

farrellja/URD documentation built on June 17, 2020, 4:48 a.m.