单细胞测序技术单细胞测序

scCustomize:自定义可视化你的单细胞数据(二)

2022-09-09  本文已影响0人  Davey1220

简介

scCustomize是一个单细胞转录组数据可视化的R包,里面集合了一些常用的数据可视化方法,可以与Seurat包进行很好的联用,支持Seurat,LIGER和SCE等常用对象的数据。

image.png

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
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")
image.png

注意:目前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

# 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)
image.png

同时,还提供了一下可选择的自定义参数:

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)
image.png
# 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)
image.png
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)
image.png

计算每个样本的QC值的中位数

scCustomize 包提供了Median_Stats()函数,可以快速计算不同QC指标 (Genes/, UMIs/, %Mito/Cell, etc)的中位数。

median_stats <- Median_Stats(seurat_object = hca_bm, group_by_var = "orig.ident")
image.png

绘制QC指标中位数值
scCustomize 包提供了以下函数绘制QC指标的中位数值

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")
image.png

内置自定义颜色画板

(1)Continuous Palettes

image.png

(2)Discrete Palettes

PalettePlot(palette = DiscretePalette_scCustomize(num_colors = 26, palette = "alphabet"))
PalettePlot(palette = c("color1", "color2", ...)
image.png image.png
# 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)
image.png
上一篇下一篇

猜你喜欢

热点阅读