Perform SNN graph clustering on a SingleCellExperiment object, with graph construction by buildSNNGraph and graph clustering by "igraph" package.

runScranSNN(
  inSCE,
  useReducedDim = NULL,
  useAssay = NULL,
  useAltExp = NULL,
  altExpAssay = "counts",
  altExpRedDim = NULL,
  clusterName = "scranSNN_cluster",
  k = 8,
  nComp = 10,
  weightType = c("rank", "number", "jaccard"),
  algorithm = c("louvain", "leiden", "walktrap", "infomap", "fastGreedy", "labelProp",
    "leadingEigen"),
  BPPARAM = BiocParallel::SerialParam(),
  seed = 12345,
  ...
)

Arguments

inSCE

A SingleCellExperiment object.

useReducedDim

A single character, specifying which low-dimension representation (reducedDim) to perform the clustering algorithm on. Default NULL.

useAssay

A single character, specifying which assay to perform the clustering algorithm on. Default NULL.

useAltExp

A single character, specifying the assay which altExp to perform the clustering algorithm on. Default NULL.

altExpAssay

A single character, specifying which assay in the chosen altExp to work on. Only used when useAltExp is set. Default "counts".

altExpRedDim

A single character, specifying which reducedDim within the altExp specified by useAltExp to use. Only used when useAltExp is set. Default NULL.

clusterName

A single character, specifying the name to store the cluster label in colData. Default "scranSNN_cluster".

k

An integer, the number of nearest neighbors used to construct the graph. Smaller value indicates higher resolution and larger number of clusters. Default 8.

nComp

An integer. The number of components to use for graph construction. Default 10. See Detail.

weightType

A single character, that specifies the edge weighing scheme when constructing the Shared Nearest-Neighbor (SNN) graph. Choose from "rank", "number", "jaccard". Default "rank".

algorithm

A single character, that specifies the community detection algorithm to work on the SNN graph. Choose from "leiden", "louvain", "walktrap", "infomap", "fastGreedy", "labelProp", "leadingEigen". Default "louvain". See Detail.

BPPARAM

A BiocParallelParam object to use for processing the SNN graph generation step in parallel.

seed

Random seed for reproducibility of results. Default NULL will use global seed in use by the R environment.

...

Other optional parameters passed to the igraph clustering functions. See Details.

Value

The input SingleCellExperiment object with factor cluster labeling updated in colData(inSCE)[[clusterName]].

Details

Different graph based clustering algorithms have diverse sets of parameters that users can tweak. The help information can be found here:

The Scran SNN building method can work on specified nComp components. When users specify input matrix by useAssay or useAltExp + altExpAssay, the method will generate nComp components and use them all. When specifying useReducedDim or useAltExp + altExpRedDim, this function will subset the top nComp components and pass them to the method.

References

Aaron Lun and et. al., 2016

Examples

data("mouseBrainSubsetSCE")
mouseBrainSubsetSCE <- runScranSNN(mouseBrainSubsetSCE,
                                   useReducedDim = "PCA_logcounts")
#> Sat Mar 18 10:31:23 2023 ... Running 'scran SNN clustering' with 'louvain' algorithm
#> Sat Mar 18 10:31:23 2023 ...   Identified 2 clusters