11 Clustering
11.1 Generate Clusters
To generate clusters, we first build a ‘neighbourhood’ graph. This is a network graph, that links up cells on the basis of their transcriptional similarity (‘neighbours’). Its not something for looking at directly, its simply stored inside the object, but its an importantin input for downstream steps like clustering.
Forget to run it and you’ll generate an error.
Note that we need to specify the ‘harmony’ reduction, else it would default to ‘pca’. Just like the UMAP, we want our clusters to represent different cell types or states, not the differences between individuals.
so <- FindNeighbors(so, reduction = "harmony", dims = 1:15)
Now clustering can be as simple as running ‘FindClusters’.
so <- FindClusters(so)
## Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
##
## Number of nodes: 50662
## Number of edges: 1195831
##
## Running Louvain algorithm...
## Maximum modularity in 10 random starts: 0.8230
## Number of communities: 12
## Elapsed time: 31 seconds
DimPlot(so, group.by='seurat_clusters')

ACTIVITY: Choose a clustering resolution between 0.1 and 2 - plot on UMAP and spatially. Share in chat. What resuolution is good? How can we decide?
For the res of the workshop, we’ll use resolution of 0.2.
For more info regarding selecting the ‘right’ clustering resolution, consider the clustree package. There is an example of its use here in the context of single cell transcriptomics.
so <- FindClusters(so, resolution = 0.2)
## Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
##
## Number of nodes: 50662
## Number of edges: 1195831
##
## Running Louvain algorithm...
## Maximum modularity in 10 random starts: 0.9031
## Number of communities: 7
## Elapsed time: 31 seconds
DimPlot(so, group.by='seurat_clusters')
