哈佛大学单细胞课程|笔记汇总 (六)

news2024/9/30 1:38:58

哈佛大学单细胞课程|笔记汇总 (五)

哈佛大学单细胞课程|笔记汇总 (四)

(六)Single-cell RNA-seq clustering analysis: aligning cells across conditions

我们的数据集包含来自两个不同条件(对照和刺激)的两个样本,因此将这些样本整合在一起以更好地进行比较。

聚类工作流程

聚类分析的目的是在待定义细胞类型的数据集中保留主要的变异来源,同时尽量屏蔽由于无用的变异来源(测序深度,细胞周期差异,线粒体表达,批次效应等)而产生的变异。

在我们的工作流程中需要应用到以下两个资源:

  • Satija Lab: Seurat v3 Guided Integration Tutorial(https://satijalab.org/seurat/v3.0/immune_alignment.html)

  • Paul Hoffman: Cell-Cycle Scoring and Regression(http://satijalab.org/seurat/cell_cycle_vignette.html)

为了识别细胞亚群,我们将进行以下步骤:

(1)Normalizationvariance stabilization, and regression of unwanted variation (e.g. mitochondrial transcript abundance, cell cycle phase, etc.) for each sample

(2)Integrationof the samples using shared highly variable genes (optional, but recommended to align cells from different samples/conditions if cell types are separating by sample/condition)

(3)Clustering cells based on top PCs (metagenes)

(4)Exploration of quality control metrics: determine whether clusters are unbalanced wrt UMIs, genes, cell cycle, mitochondrial content, samples, etc.

(5)Searching for expected cell types using known cell type-specific gene markers

以下流程为前两步。

加载R包

# Single-cell RNA-seq analysis - clustering analysis

# Load libraries
library(Seurat)
library(tidyverse)
library(RCurl)
library(cowplot)

Normalization, variance stabilization, and regression of unwanted variation for each sample

分析的第一步是将count矩阵标准化,以解决每个样品每个细胞的测序深度差异。Seurat最近推出了一种叫sctransform的新方法,用于对scRNA-seq数据进行归一化和方差稳定变化。

sctransform方法使用正则化负二项式模型对UMI counts进行建模,以消除由于测序深度(每个细胞的总nUMI)所引起的变异,同时基于具有相似丰度的基因之间的合并信息来调整方差。

图片

Image credit: Hafemeister C and Satija R. Normalization and variance stabilization of single-cell RNA-seq data using regularized negative binomial regression, bioRxiv 2019 (https://doi.org/10.1101/576827)

模型结果残差(residuals)是每个转录本标准化后的表达水平。

sctransform能通过回归分析校对测序深度(nUMI)。但对于某些数据集,细胞周期可能是基因表达变化的显著来源,对于其他数据集则不一定,我们需要检查细胞周期是否是数据变化的主要来源并在需要时校对细胞周期的影响。

Cell cycle scoring

建议在执行sctransform方法之前检查细胞周期阶段。检查之前先对数据做个标准化使得不同测序深度的细胞可比。

# Normalize the counts
seurat_phase <- NormalizeData(filtered_seurat)

作者提供了人体细胞周期相关基因可以下载 (https://www.dropbox.com/s/hus4mrkueh1tfpr/cycle.rda?dl=1)和其他生物的细胞周期相关基因(https://github.com/hbctraining/scRNA-seq/blob/master/lessons/cell_cycle_scoring.md)。

把细胞周期相关基因读入data目录

# Load cell cycle markers
load("data/cycle.rda")

# Score cells for cell cycle
seurat_phase <- CellCycleScoring(seurat_phase,
                                 g2m.features = g2m_genes,
                                 s.features = s_genes)

# View cell cycle scores and phases assigned to cells
View(seurat_phase@meta.data)

在对细胞进行细胞周期评分后,我们想使用PCA确定细胞周期是否是我们数据集中变异的主要来源。在此之前,我们首先需要对数据进行标准化scale),并使用Seurat ScaleData()函数。

  • 调整每个基因的表达以使整个细胞的平均表达为0

  • 缩放每个基因的表达以使细胞之间的表达值转换标准差的倍数

# Identify the most variable genes
seurat_phase <- FindVariableFeatures(seurat_phase,
                     selection.method = "vst",
                     nfeatures = 2000,
                     verbose = FALSE)

# Scale the counts
seurat_phase <- ScaleData(seurat_phase)

NOTE: For the selection.method and nfeatures arguments the values specified are the default settings. Therefore, you do not necessarily need to include these in your code. We have included it here for transparency and inform you what you are using.

# Perform PCA
seurat_phase <- RunPCA(seurat_phase)

# Plot the PCA colored by cell cycle phase
DimPlot(seurat_phase,
        reduction = "pca",
        group.by= "Phase",
        split.by = "Phase")

图片

我们没有看到在细胞周期方面具有很大的差异,也基于此图,我们不会考虑细胞周期引起的变化。

SCTransform

我们此时可以放心的进行SCTransform,我们打算使用for循环对每个样本进行 NormalizeData()CellCycleScoring()SCTransform() ,并使用 vars.to.regress 去除线粒体相关基因。

# Split seurat object by condition to perform cell cycle scoring and SCT on all samples
split_seurat <- SplitObject(filtered_seurat, split.by = "sample")

split_seurat <- split_seurat[c("ctrl", "stim")]

for (i in 1:length(split_seurat)) {
    split_seurat[[i]] <- NormalizeData(split_seurat[[i]], verbose = TRUE)
    split_seurat[[i]] <- CellCycleScoring(split_seurat[[i]], g2m.features=g2m_genes, s.features=s_genes)
    split_seurat[[i]] <- SCTransform(split_seurat[[i]], vars.to.regress = c("mitoRatio"))
    }

NOTE: By default, after normalizing, adjusting the variance, and regressing out uninteresting sources of variation, SCTransform will rank the genes by residual variance and output the 3000 most variant genes. If the dataset has larger cell numbers, then it may be beneficial to adjust this parameter higher using the variable.features.n argument.

除了原始RNA计数外,assays slot中现在还有一个SCT组件。细胞之间表达变化最大的特征基因存储于SCT assay中。

通常,在决定是否需要进行数据整合之前,我们总是先查看细胞在空间的分布。如果我们在Seurat对象中同时对两个条件进行了归一化并可视化,我们将看到特定于不同条件的聚类:

图片

不同条件下细胞的聚类表明我们需要跨条件整合细胞。

NOTE: Seurat has a vignette for how to run through the workflow without integration(https://satijalab.org/seurat/v3.1/sctransform_vignette.html). The workflow is fairly similar to this workflow, but the samples would not necessarily be split in the beginning and integration would not be performed.

Integrate samples using shared highly variable genes

为了进行整合(“harmony”整合不同平台的单细胞数据之旅),我们将使用不同条件的细胞共有的高可变基因,然后,我们将“整合”或“协调”条件,以鉴定组之间相似或具有“共同的生物学特征”的细胞。

如果不确定要期望的簇或期望条件之间的某些不同细胞类型(例如肿瘤和对照样品),可以先单独处理某个条件,然后一起运行以查看两种条件下是否存在针对特定细胞类型的特定簇。通常在不同条件下进行聚类分析时会出现基于条件的聚类,而数据整合可以帮助相同类型的细胞进行聚类。为了整合,我们首先需要先通过SCTransform筛选高变基因,然行“整合”或者“协调”("integrate" or "harmonize")条件,以便在不同条件下同种细胞具有相似的表达。这些条件包括:

(1)不同条件(control VS stimuli

图片

(2)不同数据集

图片

(3)不同类型 (e.g. scRNA-seq and scATAC-seq)

图片

整合最重要的目的就是使得不同条件和数据集之间细胞类型相同的数据表达谱一致。这也意味着部分细胞亚群的生物学状态是相同的,下图为整合步骤:

图片

Image credit: Stuart T and Butler A, et al. Comprehensive integration of single cell data, bioRxiv 2018 (https://doi.org/10.1101/460147)

具体细节是:

  1. 先执行典型相关性分析(canonical correlation analysis (CCA)):

    CCA是PCA的一种形式,能识别数据中最大的差异,不过前提是组/条件之间共有这个最大变异(使用每个样本中变化最大的3000个基因)。

NOTE: The shared highly variable genes are used because they are the most likely to represent those genes distinguishing the different cell types present.

  1. 在数据集中识别锚点(anchors)或相互最近的邻居(mutual nearest neighbors ,MNN):MMN可以被认为是“最佳搭档”('best buddies')。对于每种条件的细胞来说:

    “The difference in expression values between cells in an MNN pair provides an estimate of the batch effect, which is made more precise by averaging across many such pairs. A correction vector is obtained and applied to the expression values to perform batch correction.” ——Stuart and Bulter et al. (2018)(https://www.biorxiv.org/content/early/2018/11/02/460147).

    • 根据基因表达值确定细胞在其他情况下最接近的邻居-它是'best buddies'

    • 进行二次分析,如果两个细胞在两个方向上都是'best buddies',则这些细胞将被标记为将两个数据集“锚定”在一起的锚点。

  2. 筛选锚点:通过其本地邻域中的重叠来评估锚点对之间的相似性(不正确的锚点得分会较低)——相邻细胞是否具有彼此相邻的'best buddies'

  3. 整合数据/条件:使用锚点和相应分数来转换细胞表达值,从而可以整合条件/数据集(不同的样本、条件、数据集、模态)

NOTE: Transformation of each cell uses a weighted average of the two cells of each anchor across anchors of the datasets. Weights determined by cell similarity score (distance between cell and k nearest anchors) and anchor scores, so cells in the same neighborhood should have similar correction values.

现在,使用我们的SCTransform对象作为输入,进行数据整合:

首先,我们需要指定使用由SCTransform识别的3000个高变基因进行整合。默认情况下,仅选择前2000个基因。

# Select the most variable features to use for integration
integ_features <- SelectIntegrationFeatures(object.list = split_seurat,
                                            nfeatures = 3000)

然后,我们需要准备SCTransform对象以进行整合。

# Prepare the SCT list object for integration
split_seurat <- PrepSCTIntegration(object.list = split_seurat,
                                   anchor.features = integ_features)

现在,我们将执行canonical correlation analysisCCA),找到最佳锚点并过滤不正确的锚点(Cell 深度 一套普遍适用于各类单细胞测序数据集的锚定整合方案)。

# Find best buddies - can take a while to run
integ_anchors <- FindIntegrationAnchors(object.list = split_seurat,
                                        normalization.method = "SCT",
                                        anchor.features = integ_features)

最后,整合不同条件并保存。

# Integrate across conditions
seurat_integrated <- IntegrateData(anchorset = integ_anchors,
                                   normalization.method = "SCT")

# Save integrated seurat object
saveRDS(seurat_integrated, "results/integrated_seurat.rds")

UMAP visualization

我们利用降维技术可视化整合后的数据,例如PCAUniform Manifold Approximation and Projection(UMAP)

尽管PCA将能获得所有PC,但绘图时一般只使用两个或3个。相比之下,UMAP则进一步整合多个PCs获取更多信息,并在二维中进行展示。这样,细胞之间的距离代表表达上的相似性。

为了生成这些可视化,我们需要先运行PCA和UMAP方法。先从PCA开始:

# Run PCA
seurat_integrated <- RunPCA(object = seurat_integrated)

# Plot PCA
PCAPlot(seurat_integrated,
        split.by = "sample")

图片

我们看到在PCA映射中具有很好的重合。然后进行UMAP:

# Run UMAP
seurat_integrated <- RunUMAP(seurat_integrated,
                             dims = 1:40,
                 reduction = "pca")

# Plot UMAP
DimPlot(seurat_integrated)

图片

整合数据后

图片

整合数据前

从图中我们可以看到很好的整合,比起未经过CCA的数据要好太多了。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1991681.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Java JDK 国内外下载镜像地址及安装

Java JDK 国内下载镜像地址及安装 一、Java JDK 国内下载镜像地址及安装二、国外快速下载jdk 一、Java JDK 国内下载镜像地址及安装 各种JAVA JDK的镜像分发&#xff1a;https://www.injdk.cn/ 华为oracle jdk镜像&#xff1a;https://repo.huaweicloud.com/java/jdk/ 华为op…

python:VOC格式数据集转换为YOLO数据集格式

作者&#xff1a;CSDN _养乐多_ 本文将介绍如何将目标检测中常用的VOC格式数据集转换为YOLO数据集&#xff0c;并进行数据集比例划分&#xff0c;从而方便的进行YOLO目标检测。 如果不想分两步&#xff0c;可以直接看第三节代码。 文章目录 一、将VOC格式数据集转换为YOLO格…

司美格鲁肽,又名索玛鲁肽;Semaglutide;CAS号:910463-68-2

司美格鲁肽&#xff0c;又名索玛鲁肽&#xff1b;Semaglutide&#xff1b; CAS号&#xff1a;910463-68-2 分子量&#xff1a;4113.58 结构图&#xff1a; 司美格鲁肽&#xff0c;又名Semaglutide (上海楚肽生物科技有限提供&#xff09; 分子式&#xff1a;C187H291N45O59 …

nginx和php工具的使用

一、本地主机通过域名访问自己写的网页 1、开启phpstudy 2、找到phpstudy目录下的www文件夹&#xff0c;创建less01文件夹、index.html、web.php文件&#xff0c;进行配置&#xff0c;如下图&#xff1a; 3、重启一下phpstudy&#xff0c;然后访问网页 4、上面只能通过文件目录…

MIMO系统中差分空间调制解调matlab误码率仿真

目录 1.算法运行效果图预览 2.算法运行软件版本 3.部分核心程序 4.算法理论概述 4.1 空间调制原理 4.2 发送端模型 4.3 接收端模型 5.算法完整程序工程 1.算法运行效果图预览 (完整程序运行后无水印) 2.算法运行软件版本 matlab2022a 3.部分核心程序 &#xff08;完…

打开法学著作的AI新方式:元典问达「知识+」正式上线!

号外&#xff01;号外&#xff01; 元典问达正式上新 「知识」 法律人现在可以在「知识」板块&#xff0c;直接与《刑法注释书》、《刑事诉讼法注释书》“对话”&#xff0c;通过提问&#xff0c;获得权威法学出版物总结而成的刑事法律解读和案例分析&#xff01; 信息爆炸时…

esp32使用数码管显示数字

前言&#xff1a;本文参考视频链接放在最后&#xff0c;同时本文为学习笔记&#xff0c;为了自己好复习。 #数码管概念 现在显示流行有 LCD OLED 但是数码管也能用来作为显示&#xff0c;相对于前两者&#xff0c;数码管稳定价格低廉&#xff0c;到现在也在被应用&#xff0…

UE4材质基础---方形渐变、中心渐变

1、方形渐变 效果图&#xff1a; 代码&#xff1a; 解析&#xff1a;TexCoord的纹理坐标的R通道&#xff08;0&#xff0c;0.5&#xff0c;1&#xff09;减0.5> &#xff08;-0.5&#xff0c;0&#xff0c;0.5&#xff09;取abs> (0.5&#xff0c;0&#xff0c;0.5)乘…

b站ip地址怎么改到别的城市去

对于B站的忠实用户而言&#xff0c;每当在个人主页、发布动态或评论等&#xff0c;都会注意到IP属地的显示&#xff0c;但在某些情况下&#xff0c;出于对个人隐私的保护、跨越地域限制或其他个性化需求&#xff0c;我们可能会想要改变B站显示的IP地址到另一个城市。那么&#…

有没有值得推荐的加密软件

1. 金刚钻信息数据防泄密系统 特点&#xff1a;专为企业设计&#xff0c;提供全面的信息安全管理功能&#xff0c;支持透明加密技术&#xff0c;确保敏感文件在创建、编辑和保存过程中自动加密&#xff0c;不影响正常办公流程。 功能&#xff1a;提供文档权限管理、数据备份与…

ctfhub Bypass disable_function(完结)

LD_PRELOAD url 蚁剑连接 选择插件 点击开始 查看到此文件名编辑连接拼接到url后面重新连接 点击开启终端 在终端执行命令 ls / /readfile ShellShock url CTFHub 环境实例 | 提示信息 蚁剑连接 写入shell.php <?phpeval($_REQUEST[ant]);putenv("PHP_test() { :…

无心剑七绝《陈梦夺冠》

七绝陈梦夺冠 陈言务去志高扬 梦舞巴黎万里香 夺取天机心气壮 冠轻国重醉千觞 2024年8月8日 平水韵七阳平韵 这首七绝是一首藏头诗&#xff0c;每句的首字连起来是“陈梦夺冠”&#xff0c;表达了对陈梦在巴黎奥运乒乓女单斩获冠军的赞美。 陈言务去志高扬&#xff1a;这句诗意…

【生成式人工智能-五-大模型的修炼-阶段三RLHF】

大模型的修炼-RLHF 增强式学习 大模型修炼阶段Instruct Fine-tune 和 RLHF 的区别和联系 回馈模型 Reward Model增强式学习的难题怎么定义什么是好的&#xff1f;人类也无法判定好坏的 大模型是如何具备人工智能的呢&#xff1f; 上面一篇文章介绍到了前两个阶段&#xff0c;接…

网页 生成桌面快捷应用 manifest.json

效果如图 代码 <link rel"manifest" href"./manifest.json" />// manifest.json {"name": "讨口子","short_name": "TKZ","start_url": "/","display": "standalo…

奔驰GLS450升级迈巴赫四座版内饰 后排电动遮阳帘 后排娱乐案例

多座互联娱乐系统 独乐乐,不如众乐乐。 同级独有的多座互联提乐系统,可令车内所有乘客通过7.0美对中央扶手触控屏与双11.6英寸后排提乐系统缺控屏,随心所欲地分享号航、视频、音频等内容,即便身处后排,您同样也可以享受完M的MBUX智能人都交互体验,直接控制车M的全种功能。 奔驰…

The Otherworld《我独自升级》活动来了!

最近&#xff0c;我们迎来了韩国初创公司 Otherworld&#xff0c;加入 The Sandbox 大家庭。这次合作建立了一个元宇宙网络动漫中心&#xff0c;以 KakaoPage 的热门 IP 为基础&#xff0c;为我们的玩家和创作者在 The Sandbox 中提供多样化的体验。我们将推出一个全新的活动&a…

pikachu: unsafe filedownload(文件下载)

是一个图片下载页面&#xff0c;随便下载一张图片&#xff0c;查看下载链接发现是 http://127.0.0.1:8001/vul/unsafedownload/execdownload.php?filenamekb.png 修改拼接 URL&#xff0c; 构造想要传的的路径来对其进行文件上传 http://127.0.0.1/pikachu-master/vul/unsa…

芯片底部填充工艺流程有哪些?

芯片底部填充工艺流程有哪些&#xff1f;底部填充工艺&#xff08;Underfill&#xff09;是一种在电子封装过程中广泛使用的技术&#xff0c;主要用于增强倒装芯片&#xff08;Flip Chip&#xff09;、球栅阵列&#xff08;BGA&#xff09;、芯片级封装&#xff08;CSP&#xf…

多久没有清理你的电脑磁盘了?轻松解锁免费轻量磁盘清理工具

随着我们日常使用电脑的时间越来越长&#xff0c;磁盘上积累的无用文件和垃圾数据也越来越多。这些文件不仅占用宝贵的存储空间&#xff0c;还可能拖慢电脑的运行速度。 那么&#xff0c;你多久没有清理过你的电脑磁盘了呢&#xff1f; 今天&#xff0c;我将为大家推荐几款免…