簡(jiǎn)介
scCustomize
是一個(gè)單細(xì)胞轉(zhuǎn)錄組數(shù)據(jù)可視化的R包沃斤,里面集合了一些常用的數(shù)據(jù)可視化方法蛋铆,可以與Seurat包進(jìn)行很好的聯(lián)用触幼,支持Seurat拆祈,LIGER和SCE等常用對(duì)象的數(shù)據(jù)恨闪。
R包安裝
直接使用devtools包進(jìn)行安裝
devtools::install_github(repo = "samuel-marsh/scCustomize")
remotes::install_github(repo = "samuel-marsh/scCustomize")
實(shí)例演示
在本教程中,我將使用 SeuratData 包中的 HCA 骨髓單細(xì)胞數(shù)據(jù)放坏。
QC plot
所有 scRNA-seq 數(shù)據(jù)分析的第一步就是執(zhí)行一些 QC 檢查和繪圖咙咽,以便可以適當(dāng)?shù)剡^(guò)濾數(shù)據(jù)。scCustomize 包含許多功能淤年,可用于快速輕松地生成一些最相關(guān)的 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
hca_bm@meta.data$group[hca_bm@meta.data$orig.ident == "MantonBM1" | hca_bm@meta.data$orig.ident ==
"MantonBM2" | hca_bm@meta.data$orig.ident == "MantonBM3" | hca_bm@meta.data$orig.ident == "MantonBM4"] <- "Group 1"
hca_bm@meta.data$group[hca_bm@meta.data$orig.ident == "MantonBM5" | hca_bm@meta.data$orig.ident ==
"MantonBM6" | hca_bm@meta.data$orig.ident == "MantonBM7" | hca_bm@meta.data$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函數(shù)只支持以上物種計(jì)算線粒體和核糖體基因百分比蜡豹,如果需要,請(qǐng)?jiān)?GitHub 上提交問(wèn)題以獲取其他默認(rèn)物種溉苛。請(qǐng)包括線粒體和核糖體基因的正則表達(dá)式模式或基因列表镜廉,我將在函數(shù)中添加額外的內(nèi)置默認(rèn)值。
# 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種函數(shù)繪制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 object@meta.data 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)
同時(shí)愚战,還提供了一下可選擇的自定義參數(shù):
-
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種函數(shù)繪制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 object@meta.data slot. -
QC_Plot_UMIvsFeature()
Plots UMIs vs. “feature” per cell/nucleus. Using parameterfeature1
to allow plotting of any applicable named feature in object@meta.data 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)
計(jì)算每個(gè)樣本的QC值的中位數(shù)
scCustomize 包提供了Median_Stats()
函數(shù)桨吊,可以快速計(jì)算不同QC指標(biāo) (Genes/, UMIs/, %Mito/Cell, etc)的中位數(shù)。
median_stats <- Median_Stats(seurat_object = hca_bm, group_by_var = "orig.ident")
繪制QC指標(biāo)中位數(shù)值
scCustomize 包提供了以下函數(shù)繪制QC指標(biāo)的中位數(shù)值
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")
內(nèi)置自定義顏色畫(huà)板
(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)