热点新闻
scCustomize:自定义可视化你的单细胞数据(二)
2023-08-01 12:19  浏览:500  搜索引擎搜索“早勤网”
温馨提示:信息一旦丢失不一定找得到,请务必收藏信息以备急用!本站所有信息均是注册会员发布如遇到侵权请联系文章中的联系方式或客服删除!
联系我时,请说明是在早勤网看到的信息,谢谢。
展会发布 展会网站大全 报名观展合作 软文发布

简介

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

  • 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 parameter feature 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)


image.png

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

  • 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)


image.png

  • 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 parameter feature1 to allow plotting of any applicable named feature in object@meta.data slot.
  • QC_Plot_UMIvsFeature() Plots UMIs vs. “feature” per cell/nucleus. Using parameter feature1 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)


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()
  • 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")


image.png

内置自定义颜色画板

(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



image.png

(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", ...)


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

发布人:32e6****    IP:117.173.60.***     举报/删稿
展会推荐
让朕来说2句
评论
收藏
点赞
转发