To perform marker gene analysis we need to have clustered data. To cluster the data we use the following workflow, adapted from the Orchestrating single cell analysis with Bioconductor book:
g <- buildSNNGraph(sce.pbmc, k = 10, use.dimred = 'PCA')
clust <- igraph::cluster_walktrap(g)$membership
colLabels(sce.pbmc) <- factor(clust)
pbmcs <- sce.pbmc
```
We can now run the marker gene methods. We will focus our attention on cluster 9. Note that this cluster is focused on in the Marker Gene chapter of OCSA.
First we run {scran}:
```{r mg-scran}
# A bit slow on my MacBook Air.
scran_mgs <- findMarkers(pbmcs)
# Focus on the marker genes for cluster 9.
scran_mgs_9 <- scran_mgs[["9"]]
scran_mgs_9
```
Next we can run {Seurat}:
```{r mg-seurat}
# Seurat requires column names and cannot handle DelayedArray objects.
We can now compare the results from {Seurat} and {scran}. We use the genes with `Top <= 6` for {scran}, that is the top 6 genes in each pairwise comparison, as suggested in OSCA. This gives us 52 genes so we filter the {Seurat} genes to the top 52 based on p-value and check the concordance.