单细胞分析的小伙伴们一定对 Seurat 不陌生,它几乎是所有scRNA-seq入门必备的“瑞士军刀🔪”。
但你是否也遇到过这样的问题:
“想画个更漂亮的气泡图,却要手写半页 ggplot 代码……”
“整合批次数据后,想快速提取 marker、可视化 module score,却找不到方便的函数……”
别急!今天要介绍的是一款让你在 Seurat 世界里“如虎添翼🐯”的神器——
🧬 SeuratExtend:基于Seurat的强大拓展包!
它不仅兼容原生Seurat工作流,还提供了大量一行命令即可实现的高质量可视化、数据统计与特征分析功能📊。
rm(list = ls())
library(Seurat)
library(SeuratExtend)
pbmc

DimPlot2(pbmc)

DimPlot2(pbmc, features = c("cluster", "orig.ident", "CD14", "CD3D"), theme = NoAxes())

DimPlot2(pbmc, features = c("CD14", "CD3D"), cols = "A")

DimPlot2(pbmc, features = c("cluster", "CD14"), split.by = "orig.ident", ncol = 1)

b_cells <- colnames(pbmc)[pbmc$cluster == "B cell"]
DimPlot2(pbmc, cells.highlight = b_cells)

DimPlot2(
pbmc,
features = c("cluster", "orig.ident", "CD14", "CD3D"),
cols = list(
"cluster" = "default", # dark theme
"CD14" = "D",
"CD3D" = "OrRd"
),
theme = NoAxes())

DimPlot2(pbmc, label = TRUE, box = TRUE, label.color = "black", repel = TRUE, theme = NoLegend())

DimPlot2(pbmc, index.title = "C", box = TRUE, label.color = "black")

# Add simplified axis indicators
DimPlot2(
pbmc,
features = c("cluster", "orig.ident", "CD14", "CD3D"),
theme = NoAxes()
) + theme_umap_arrows()

# Add arrows to each subplot
DimPlot2(
pbmc,
features = c("cluster", "orig.ident", "CD14", "CD3D"),
theme = theme_umap_arrows()
)

FeaturePlot3(pbmc, color = "ryb", feature.1 = "CD3D", feature.2 = "CD14", feature.3 = "CD79A", pt.size = 0.5)

FeaturePlot3.grid(pbmc, features = c("CD3D", "CD14", "CD79A", "FCGR3A", NA, "LYZ"), pt.size = 0.5)

# Calculate z-scores for variable features
genes <- VariableFeatures(pbmc)
toplot <- CalcStats(pbmc, features = genes, method = "zscore", order = "p", n = 5)
# Create a basic heatmap
Heatmap(toplot, lab_fill = "zscore")

# Viridis-A theme
Heatmap(toplot, lab_fill = "zscore", color_scheme = "A")

Heatmap(toplot, lab_fill = "zscore", plot.margin = margin(l = 50))

对于具有许多特征的密集矩阵,可以挑选显示基因。🥸
toplot2 <- CalcStats(pbmc, features = genes[1:500], method = "zscore", order = "p")
Heatmap(toplot2, lab_fill = "zscore", feature_text_subset = genes[1:20], expand_limits_x = c(-0.5, 11))

gene_groups <- sample(c("group1", "group2", "group3"), nrow(toplot2), replace = TRUE)
Heatmap(toplot2, lab_fill = "zscore", facet_row = gene_groups) +
theme(axis.text.y = element_blank())

# Select some variable features
genes <- VariableFeatures(pbmc)[1:10]
DotPlot2(pbmc, features = genes)

# Create grouped features
grouped_features <- list(
"B_cell_markers" = c("MS4A1", "CD79A"),
"T_cell_markers" = c("CD3D", "CD8A", "IL7R"),
"Myeloid_markers" = c("CD14", "FCGR3A", "S100A8")
)
DotPlot2(pbmc, features = grouped_features)

# Basic split visualization
DotPlot2(pbmc, features = genes, group.by = "cluster", split.by = "orig.ident", show_grid = FALSE)

# Using colors instead of borders for split groups
DotPlot2(pbmc,
features = genes,
group.by = "cluster",
split.by = "orig.ident",
split.by.method = "color",
show_grid = FALSE)

修改细节!~
DotPlot2(pbmc,
features = grouped_features,
color_scheme = "BuRd",
border = FALSE, # Remove dot borders
show_grid = FALSE, # Remove grid lines
flip = TRUE) # Flip coordinates
