cluster: Cluster cells using Louvain/Leiden community detection

clusterR Documentation

Cluster cells using Louvain/Leiden community detection

Description

Unsupervised clustering is a common step in many workflows. This function takes a matrix as input, clusters the columns using Louvain/Leiden community detection, and returns the clusterassignments. In addition to clusters this function calculates partitions, which represent superclusters of the Louvain/Leiden communities that are found using a kNN pruning method.

Usage

cluster(
  obj,
  pd,
  reduction_method = c("UMAP", "tSNE", "PCA", "LSI", "Aligned"),
  k = 20,
  cluster_method = c("leiden", "louvain"),
  num_iter = 2,
  partition_qval = 0.05,
  weight = FALSE,
  resolution = NULL,
  random_seed = NULL,
  verbose = F,
  ...
)

Arguments

obj

input matrix

pd

phenodata - a dataframe with relevant column metadata

reduction_method

The dimensionality reduction method upon which to base clustering. Options are "UMAP", "tSNE", "PCA" and "LSI".

k

Integer number of nearest neighbors to use when creating the k nearest neighbor graph for Louvain/Leiden clustering. k is related to the resolution of the clustering result, a bigger k will result in lower resolution and vice versa. Default is 20.

cluster_method

String indicating the clustering method to use. Options are "louvain" or "leiden". Default is "leiden". Resolution parameter is ignored if set to "louvain".

num_iter

Integer number of iterations used for Louvain/Leiden clustering. The clustering result giving the largest modularity score will be used as the final clustering result. Default is 1. Note that if num_iter is greater than 1, the random_seed argument will be ignored for the louvain method.

partition_qval

Numeric, the q-value cutoff to determine when to partition. Default is 0.05.

weight

A logical argument to determine whether or not to use Jaccard coefficients for two nearest neighbors (based on the overlapping of their kNN) as the weight used for Louvain clustering. Default is FALSE.

resolution

Parameter that controls the resolution of clustering. If NULL (Default), the parameter is determined automatically.

random_seed

The seed used by the random number generator in louvain-igraph package. This argument will be ignored if num_iter is larger than 1.

verbose

A logic flag to determine whether or not we should print the run details.

...

Additional arguments passed to the leidenbase package.

Value

a list containing 1) the clusters, and 2) the partitions.

References

Rodriguez, A., & Laio, A. (2014). Clustering by fast search and find of density peaks. Science, 344(6191), 1492-1496. doi:10.1126/science.1242072

Vincent D. Blondel, Jean-Loup Guillaume, Renaud Lambiotte, Etienne Lefebvre: Fast unfolding of communities in large networks. J. Stat. Mech. (2008) P10008

V. A. Traag and L. Waltman and N. J. van Eck: From Louvain to Leiden: guaranteeing well-connected communities. Scientific Reports, 9(1) (2019). doi: 10.1038/s41598-019-41695-z.

Jacob H. Levine and et. al. Data-Driven Phenotypic Dissection of AML Reveals Progenitor-like Cells that Correlate with Prognosis. Cell, 2015.


scfurl/seqGlue documentation built on Sept. 1, 2024, 11:20 a.m.