After quantile normalization, users can additionally run the Leiden or Louvain algorithm for community detection, which is widely used in single-cell analysis and excels at merging small clusters into broad cell classes.
While using quantile normalized factor loadings (result from
quantileNorm
) is recommended, this function looks for
unnormalized factor loadings (result from runIntegration
) when
the former is not available.
runCluster(
object,
resolution = 1,
nNeighbors = 20,
prune = 1/15,
eps = 0.1,
nRandomStarts = 10,
nIterations = 5,
method = c("leiden", "louvain"),
useRaw = NULL,
useDims = NULL,
groupSingletons = TRUE,
saveSNN = FALSE,
clusterName = paste0(method, "_cluster"),
seed = 1,
verbose = getOption("ligerVerbose", TRUE)
)
object
with cluster assignment updated in clusterName
variable in cellMeta
slot. Can be fetched with
object[[clusterName]]
. If saveSNN = TRUE
, the SNN graph will
be stored at object@uns$snn
.
A liger object. Should have valid factorization result available.
Numeric, value of the resolution parameter, a larger value
results in a larger number of communities with smaller sizes. Default
1.0
.
Integer, the maximum number of nearest neighbors to
compute. Default 20
.
Numeric. Sets the cutoff for acceptable Jaccard index when
computing the neighborhood overlap for the SNN construction. Any edges with
values less than or equal to this will be set to 0 and removed from the SNN
graph. Essentially sets the stringency of pruning. 0
for no pruning,
while 1
prunes everything. Default 1/15
.
Numeric, the error bound of the nearest neighbor search. Default
0.1
.
Integer number of random starts. Will pick the
membership with highest quality to return. Default 10
.
Integer, maximal number of iterations per random start.
Default 5
.
Community detection algorithm to use. Choose from
"leiden"
or "louvain"
. Default "leiden"
.
Whether to use un-aligned cell factor loadings (\(H\)
matrices). Default NULL
search for quantile-normalized loadings first
and un-aligned loadings then.
Indices of factors to use for clustering. Default NULL
uses all available factors.
Whether to group single cells that make up their own
cluster in with the cluster they are most connected to. Default TRUE
,
if FALSE
, assign all singletons to a "singleton"
group.
Logical, whether to store the SNN graph, as a dgCMatrix
object, in the object. Default FALSE
.
Name of the variable that will store the clustering result
in cellMeta
slot of object
. Default "leiden_cluster"
and
"louvain_cluster"
.
Seed of the random number generator. Default 1
.
Logical. Whether to show information of the progress. Default
getOption("ligerVerbose")
or TRUE
if users have not set.
pbmcPlot <- runCluster(pbmcPlot)
head(pbmcPlot$leiden_cluster)
pbmcPlot <- runCluster(pbmcPlot, method = "louvain")
head(pbmcPlot$louvain_cluster)
Run the code above in your browser using DataLab