scCustomize:自定义可视化你的单细胞数据(二)
简介
scCustomize
是一个单细胞转录组数据可视化的R包,里面集合了一些常用的数据可视化方法,可以与Seurat包进行很好的联用,支持Seurat,LIGER和SCE等常用对象的数据。
R包安装
直接使用devtools包进行安装
devtools::install_github(repo = "samuel-marsh/scCustomize")
remotes::install_github(repo = "samuel-marsh/scCustomize")
实例演示
在本教程中,我将使用 SeuratData 包中的 HCA 骨髓单细胞数据。
QC plot
所有 scRNA-seq 数据分析的第一步就是执行一些 QC 检查和绘图,以便可以适当地过滤数据。scCustomize 包含许多功能,可用于快速轻松地生成一些最相关的 QC 图。
library(tidyverse)
library(patchwork)
library(Seurat)
library(scCustomize)
library(qs)
# Load Example Dataset
hca_bm <- hcabm40k.SeuratData::hcabm40k
# Add pseudo group variable just for this vignette
[email protected]$group[[email protected]$orig.ident == "MantonBM1" | [email protected]$orig.ident ==
"MantonBM2" | [email protected]$orig.ident == "MantonBM3" | [email protected]$orig.ident == "MantonBM4"] <- "Group 1"
[email protected]$group[[email protected]$orig.ident == "MantonBM5" | [email protected]$orig.ident ==
"MantonBM6" | [email protected]$orig.ident == "MantonBM7" | [email protected]$orig.ident == "MantonBM8"] <- "Group 2"
添加线粒体和核糖体基因百分比
# These defaults can be run just by providing accepted species name
hca_bm <- Add_Mito_Ribo_Seurat(seurat_object = hca_bm, species = "Human")
注意:目前Add_Mito_Ribo_Seurat函数只支持以上物种计算线粒体和核糖体基因百分比,如果需要,请在 GitHub 上提交问题以获取其他默认物种。请包括线粒体和核糖体基因的正则表达式模式或基因列表,我将在函数中添加额外的内置默认值。
# Using gene name patterns
hca_bm <- Add_Mito_Ribo_Seurat(seurat_object = hca_bm, species = "other", mito_pattern = "regexp_pattern",
ribo_pattern = "regexp_pattern")
# Using feature name lists
mito_gene_list <- c("gene1", "gene2", "etc")
ribo_gene_list <- c("gene1", "gene2", "etc")
hca_bm <- Add_Mito_Ribo_Seurat(seurat_object = hca_bm, species = "other", mito_features = mito_gene_list,
ribo_features = ribo_gene_list)
# Using combination of gene lists and gene name patterns
hca_bm <- Add_Mito_Ribo_Seurat(seurat_object = hca_bm, species = "Human", mito_features = mito_gene_list,
ribo_pattern = "regexp_pattern")
Plotting QC Metrics
- VlnPlot-Based QC Plots
scCustomize 包提供了以下4种函数绘制VlnPlot-Based QC Plots.
-
QC_Plots_Genes()
Plots genes per cell/nucleus. -
QC_Plots_UMIs()
Plots UMIs per cell/nucleus. -
QC_Plots_Mito()
Plots mito% (named “percent_mito”) per cell/nucleus. -
QC_Plots_Feature()
Plots “feature” per cell/nucleus. Using parameterfeature
to allow plotting of any applicable named feature in [email protected] slot.
# All functions contain
p1 <- QC_Plots_Genes(seurat_object = hca_bm, low_cutoff = 800, high_cutoff = 5500)
p2 <- QC_Plots_UMIs(seurat_object = hca_bm, low_cutoff = 1200, high_cutoff = 45000)
p3 <- QC_Plots_Mito(seurat_object = hca_bm, high_cutoff = 20)
wrap_plots(p1, p2, p3, ncol = 3)
同时,还提供了一下可选择的自定义参数:
-
plot_title
: Change plot title -
x_axis_label/y_axis_label
: Change axis labels. -
x_lab_rotate
: Should x-axis label be rotated 45 degrees? -
y_axis_log
: Should y-axis in linear or log10 scale.
p1 <- QC_Plots_UMIs(seurat_object = hca_bm, low_cutoff = 1200, high_cutoff = 45000, pt.size = 0.1)
p2 <- QC_Plots_UMIs(seurat_object = hca_bm, low_cutoff = 1200, high_cutoff = 45000, pt.size = 0.1,
y_axis_log = TRUE)
wrap_plots(p1, p2, ncol = 2)
- FeatureScatter-Based QC Plots
scCustomize 包提供了以下3种函数绘制FeatureScatter-Based QC Plots.
-
QC_Plot_UMIvsGene()
Plots genes vs UMIs per cell/nucleus -
QC_Plot_GenevsFeature()
Plots Genes vs. “feature” per cell/nucleus. Using parameterfeature1
to allow plotting of any applicable named feature in [email protected] slot. -
QC_Plot_UMIvsFeature()
Plots UMIs vs. “feature” per cell/nucleus. Using parameterfeature1
to allow plotting of any applicable named feature in [email protected] slot.
# All functions contain
QC_Plot_UMIvsGene(seurat_object = hca_bm, low_cutoff_gene = 800, high_cutoff_gene = 5500, low_cutoff_UMI = 500,
high_cutoff_UMI = 50000)
QC_Plot_GenevsFeature(seurat_object = hca_bm, feature1 = "percent_mito", low_cutoff_gene = 800,
high_cutoff_gene = 5500, high_cutoff_feature = 20)
QC_Plot_UMIvsGene(seurat_object = hca_bm, meta_gradient_name = "percent_mito", low_cutoff_gene = 800,
high_cutoff_gene = 5500, high_cutoff_UMI = 45000)
QC_Plot_UMIvsGene(seurat_object = hca_bm, meta_gradient_name = "percent_mito", low_cutoff_gene = 800,
high_cutoff_gene = 5500, high_cutoff_UMI = 45000, meta_gradient_low_cutoff = 20)
计算每个样本的QC值的中位数
scCustomize 包提供了Median_Stats()
函数,可以快速计算不同QC指标 (Genes/, UMIs/, %Mito/Cell, etc)的中位数。
median_stats <- Median_Stats(seurat_object = hca_bm, group_by_var = "orig.ident")
绘制QC指标中位数值
scCustomize 包提供了以下函数绘制QC指标的中位数值
Plot_Median_Genes()
Plot_Median_UMIs()
Plot_Median_Mito()
Plot_Median_Other()
Plot_Median_Genes(seurat_object = hca_bm, group_by = "group")
Plot_Median_UMIs(seurat_object = hca_bm, group_by = "group")
Plot_Median_Mito(seurat_object = hca_bm, group_by = "group")
Plot_Median_Other(seurat_object = hca_bm, median_var = "percent_ribo", group_by = "group")
内置自定义颜色画板
(1)Continuous Palettes
- viridis_plasma_dark_high
- viridis_plasma_light_high
- viridis_magma_dark_high
- viridis_magma_light_high
- viridis_inferno_dark_high
- viridis_inferno_light_high
- viridis_dark_high
- viridis_light_high
(2)Discrete Palettes
- alphabet (24)
- alphabet2 (24)
- glasbey (32)
- polychrome (36)
- stepped (24)
- ditto_seq (40)
- varibow (Dynamic)
PalettePlot(palette = DiscretePalette_scCustomize(num_colors = 26, palette = "alphabet"))
PalettePlot(palette = c("color1", "color2", ...)
# Save as variable to global environment
polychrome_pal <- DiscretePalette_scCustomize(num_colors = 36, palette = "polychrome")
# Call within another function
DimPlot(object = obj_name, cols = DiscretePalette_scCustomize(num_colors = 26, palette = "polychrome"))
DimPlot_scCustom(seurat_object = pbmc)
共有 0 条评论