Skip to content



Download the presentation


This chapter uses the gbm dataset

The method implemented in Seurat first constructs a SNN graph based on the euclidean distance in PCA space, and refine the edge weights between any two cells based on the shared overlap in their local neighborhoods (Jaccard similarity). This step is performed using the FindNeighbors() function, and takes as input the previously defined dimensionality of the dataset.

gbm <- Seurat::FindNeighbors(gbm, dims = 1:25)

To cluster the cells, Seurat next implements modularity optimization techniques such as the Louvain algorithm (default) or SLM [SLM, Blondel et al., Journal of Statistical Mechanics], to iteratively group cells together, with the goal of optimizing the standard modularity function. The FindClusters() function implements this procedure, and contains a resolution parameter that sets the ‘granularity’ of the downstream clustering, with increased values leading to a greater number of clusters.

gbm <- Seurat::FindClusters(gbm, resolution = seq(0.1, 0.8, by=0.1))

Cluster id of each cell is added to the metadata object, as a new column for each resolution tested:


To view how clusters sub-divide at increasing resolution:

clustree::clustree([,grep("RNA_snn_res", colnames(],
                   prefix = "RNA_snn_res.")

You can view the UMAP coloring each cell according to a cluster id like this:

Seurat::DimPlot(gbm, = "RNA_snn_res.0.1")

Exercise: Visualise clustering based on a few more resolutions. Taking the clustering and the UMAP plots into account what do you consider as a good resolution to perform the clustering?


Of course, there is no ‘optimal’ resolution, but based on resolution of 0.2, it seems that clustering fits the UMAP well:

Seurat::DimPlot(gbm, = "RNA_snn_res.0.2")

Save the dataset and clear environment

Now, save the dataset so you can use it later today:

saveRDS(gbm, "gbm_day2_part1.rds")

Clear your environment:

rm(list = ls())