Learn R Programming

easybio (version 1.2.2)

plotSeuratDot: Create a Dot Plot to Visualize Marker Gene Expression

Description

This function generates a Seurat::DotPlot to visualize the expression of specified marker genes across different cell clusters or groups. It is designed to work with a list of features, such as the output from the check_marker function.

Usage

plotSeuratDot(features, srt, split = FALSE, ...)

Value

A ggplot2 object representing the dot plot, which can be further customized.

Arguments

features

A named list of character vectors. Each name in the list represents a cell type or category, and the corresponding character vector contains the marker genes to be plotted for that category. This is typically the output of check_marker().

srt

A Seurat object containing the single-cell expression data.

split

Logical, if TRUE, generates separate dot plots for each cell type in features

...

Additional arguments passed to Seurat::DotPlot(), such as cols, dot.scale, etc.

See Also

check_marker to generate the features list.

Examples

Run this code
if (FALSE) {
library(easybio)
library(Seurat)
data(pbmc.markers)

# In a real scenario, 'srt' would be your fully processed Seurat object.
# For this example, we create a minimal Seurat object.
# The expression matrix should contain the marker genes for the plot to be meaningful.
marker_genes <- unique(pbmc.markers$gene)
counts <- matrix(
  abs(rnorm(length(marker_genes) * 50, mean = 1, sd = 2)),
  nrow = length(marker_genes),
  ncol = 50
)
rownames(counts) <- marker_genes
colnames(counts) <- paste0("cell_", 1:50)

srt <- CreateSeuratObject(counts = counts)
srt$seurat_clusters <- sample(0:3, 50, replace = TRUE)
Idents(srt) <- "seurat_clusters"

# Step 1: Generate cell type annotations
matched_cells <- matchCellMarker2(pbmc.markers, n = 50, spc = "Human")

# Step 2: Get canonical markers for cluster 0's top annotation
reference_markers <- check_marker(matched_cells, cl = 0, topcellN = 1)

# Step 3: Plot the expression of these markers
if (!is.null(reference_markers) && length(reference_markers) > 0) {
  plotSeuratDot(features = reference_markers, srt = srt)
}
}

Run the code above in your browser using DataLab