scDotPlot 0.99.4
Dot plots of single-cell RNA-seq data allow for an examination of the relationships between cell groupings (e.g. clusters) and marker gene expression. The scDotPlot package offers a unified approach to perform a hierarchical clustering analysis and add annotations to the columns and/or rows of a scRNA-seq dot plot. It works with SingleCellExperiment and Seurat objects as well as data frames. The scDotPlot()
function uses data from scater::plotDots()
or Seurat::DotPlot()
along with the aplot
package to add dendrograms from ggtree
and optional annotations.
if (!requireNamespace("BiocManager", quietly = TRUE)) {
install.packages("BiocManager")
}
BiocManager::install("scDotPlot")
To install the development version directly from GitHub:
if (!requireNamespace("remotes", quietly = TRUE)) {
install.packages("remotes")
}
remotes::install_github("ben-laufer/scDotPlot")
First, we normalize the object and then, for the purpose of this example, subset to remove cells without cell-type labels.
library(scRNAseq)
library(scuttle)
sce <- ZeiselBrainData()
sce <- sce |>
logNormCounts() |>
subset(x = _, , level2class != "(none)")
The features argument accepts a character vector with the gene IDs. For this example, we quickly obtain the top markers of for each cell type and then add them to the rowData of the object.
library(scran)
library(purrr)
library(dplyr)
library(AnnotationDbi)
features <- sce |>
scoreMarkers(sce$level1class) |>
map(~ .x |>
as.data.frame() |>
arrange(desc(mean.AUC))|>
dplyr::slice(1:6) |>
rownames()) |>
unlist2()
rowData(sce)$Marker <- features[match(rownames(sce), features)] |>
names()
Finally, we create the plot. The group
arguments utilize the colData, while the features
arguments use the rowData. The paletteList
argument can be used to manually specify the colors for the annotations specified through groupAnno
and featureAnno
. The clustering of the columns shows that cell the cell sub-types cluster by cell-type, while the clustering of the rows shows that most of the markers clusters by their cell type.
library(scDotPlot)
library(ggsci)
sce |>
scDotPlot(features = features,
group = "level2class",
groupAnno = "level1class",
featureAnno = "Marker",
groupLegends = FALSE,
annoColors = list("level1class" = pal_d3()(7),
"Marker" = pal_d3()(7)),
annoWidth = 0.02)