Seurat对象的QC和filter

66 篇文章 0 订阅
21 篇文章 0 订阅
该文介绍了使用Seurat包对单细胞RNA测序数据进行预处理的流程,包括读取数据、细胞过滤、质量控制、正常化方法如LogNormalization和SCTransform,以及高变特征检测。此外,文中还展示了如何利用百分比线粒体基因表达、基因数量等指标进行细胞过滤,并通过可视化工具进行数据探索和分析。
摘要由CSDN通过智能技术生成

文章目录

brief

  • seurat提供的教学里面包含了Standard pre-processing workflow,workflow包括QC,normalization,scale data ,detection of highly variable features。
  • 其中 normalization就有蛮多方法的,seurat自己就提供了两种,一种是"LogNormalization",另一种是目前正在大力推荐的"SCTransform",而且每一种方法参数众多,我觉得有必要对其进行仔细的探究,所以需要分开学习和记录。
  • 还有 detection of highly variable features以及scale data,也是方法和参数众多,我觉得有必要对其进行仔细的探究,所以需要分开学习和记录
  • 概要图以及系列博文可以参见链接
    在这里插入图片描述

这里主要记录了使用 UMI,gene feature,percentage of mitochondrial expression进行细胞过滤和提取的操作,以及一些seurat提供的可视化方法。

  • 其中seurat提供的思路如下:
    在这里插入图片描述

实例

  • 构建seurat对象
library(dplyr)
library(Seurat)
library(patchwork)

rm(list=ls())

# 使用read10X读取output of the cellranger pipeline from 10X,包括barcodes,genes,matrix.mtx三个文件
pbmc.data <- Read10X(data.dir = "D:/djs/pbmc3k_filtered_gene_bc_matrices/filtered_gene_bc_matrices/hg19")
# 使用 CreateSeuratObject函数构造seurat对象
pbmc <- CreateSeuratObject(counts = pbmc.data, project = "pbmc3k",
                           min.cells = 3, min.features = 200,
                           names.delim = "-",names.field = 1)
  • QC信息的构建和过滤
# The [[ operator can add columns to object metadata. This is a great place to stash QC stats
# 计算 a percentage of cell reads originating from the mitochondrial genes
# 这里利用的是正则表达式去map 人的线粒体基因,然后进行计算比例,其他物种的话线粒体基因是不是以MT开头的我不太清楚,所以可能需要手动计算了

pbmc[["percent.mt"]] <- PercentageFeatureSet(pbmc, pattern = "^MT-")

# 手动计算部分percentage of cell reads originating from the mitochondrial genes可以参考下面的链接
# https://github.com/hbctraining/scRNA-seq/blob/master/lessons/mitoRatio.md


# 计算 complexity of the RNA species
pbmc@meta.data$log10GenesPerUMI <- log10(pbmc$nFeature_RNA) / log10(pbmc$nCount_RNA)

# 下面一步把pre-processing workflow中的QC阶段走完了,
# 其中线粒体含量最好根据组织特性设定,比如心肌细胞线粒体基因含量超过20%很正常啊
# 这里的过滤参数设置规定每个细胞包含的gene应该在200-2500个,线粒体基因含量占比小于5%
# 在第一步构建seurat 对象的时候,就把那些少于3个细胞表达的gene以及少于200个gene的cell丢弃了
pbmc <- subset(pbmc, subset = nFeature_RNA > 200 & nFeature_RNA < 2500 & percent.mt < 5)
  • 可视化探索部分
# Visualize QC metrics as a violin plot
# 这里 VlnPlot()函数的参数很多,可视化的内容绝不仅仅是下面这个图形
VlnPlot(pbmc, features = c("nFeature_RNA", "nCount_RNA", "percent.mt"), ncol = 3)

# FeatureScatter is typically used to visualize feature-feature relationships, but can be used
# for anything calculated by the object, i.e. columns in object metadata, PC scores etc.

plot1 <- FeatureScatter(pbmc, feature1 = "nCount_RNA", feature2 = "percent.mt")
plot2 <- FeatureScatter(pbmc, feature1 = "nCount_RNA", feature2 = "nFeature_RNA")
plot1 + plot2

# Visualize the number UMIs/transcripts per cell
pbmc@meta.data %>% 
  ggplot(aes(color=orig.ident, x=nCount_RNA, fill= orig.ident)) + 
  geom_density(alpha = 0.2) + 
  scale_x_log10() + 
  theme_classic() +
  ylab("Cell density") +
  geom_vline(xintercept = 500)


# Visualize the distribution of genes detected per cell via histogram
pbmc@meta.data %>% 
  ggplot(aes(color=orig.ident, x=nFeature_RNA, fill= orig.ident)) + 
  geom_density(alpha = 0.2) + 
  theme_classic() +
  scale_x_log10() + 
  geom_vline(xintercept = 300)

# Visualize the overall complexity of the gene expression by visualizing the genes detected per UMI (novelty score)
pbmc@meta.data %>%
  	ggplot(aes(x=log10GenesPerUMI, color=orig.ident, fill= orig.ident)) +
  	geom_density(alpha = 0.2) +
  	theme_classic() +
  	geom_vline(xintercept = 0.8)

# Visualize the distribution of mitochondrial gene expression detected per cell
pbmc@meta.data %>% 
  	ggplot(aes(x=percent.mt, color=orig.ident, fill= orig.ident)) + 
  	geom_density(alpha = 0.2) + 
  	scale_x_log10() + 
  	theme_classic() +
  	geom_vline(xintercept = 0.2)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值