limma | 分层样本的差异分析这样搞!(二)

alt

1写在前面

上期介绍了用limma包做配对样本的差异分析。
本期介绍一下Multi-level如何处理吧。 🥳

应用场景ControlDiseasedT细胞B细胞分层对比。

2用到的包

rm(list = ls())
library(tidyverse)
library(limma)
library(GEOquery)

3示例数据

这里我们还是利用上期介绍的GEO数据库上的dataset。😘
3个样本中对T细胞B细胞分别进行了转录组分析。
每个样本的细胞都分为Controlanti-BTLA组。

GSE194314 <- getGEO('GSE194314', destdir=".",getGPL = F)
exprSet <- exprs(GSE194314[[1]])
exprSet <- normalizeBetweenArrays(exprSet) %>%
log2(.)
alt

4获取分组数据

pdata <- pData(GSE194314[[1]])
alt

5整理分组数据

这里我们提取出分组数据后转为factor

individuals <- factor(unlist(lapply(pdata$characteristics_ch1.1,function(x) strsplit(as.character(x),": ")[[1]][2])))

cell_type <- factor(unlist(lapply(pdata$characteristics_ch1,function(x) strsplit(as.character(x),": ")[[1]][2])))
cell_type <- gsub("[[:punct:]]","", cell_type)
cell_type <- gsub("\\s","_", cell_type)

treatment <- unlist(lapply(pdata$characteristics_ch1.2,function(x) strsplit(as.character(x),": ")[[1]][2]))

treatment <- factor(treatment,levels = unique(treatment))

treatment<- gsub("-", "_", treatment)
alt

6Multi-level的处理与理解

6.1 整理分组矩阵

如果我们的目的是比较两种细胞类型间的差异,可以在样本内部进行,因为每个样本都会产生两种细胞类型的值。 🧐
如果我们想将Controlanti-BTLA进行比较,这种比较就是在不同样本之间进行了。

这里大家可以理解为,需要进行组内组间比较,处理样本时需要用到random effect,在limma包中需要调用duplicateCorrelation函数进行处理。😲

measures <- factor(paste(treatment, cell_type,sep="."))

design <- model.matrix(~ 0 + measures)

colnames(design) <- levels(measures)
alt

6.2 相关性计算

然后,我们在同一样本上计算不同组学间的相关性

corfit <- duplicateCorrelation(exprSet, design, block = individuals)
corfit$consensus

6.3 模型拟合

fit <- lmFit(exprSet, design, block = individuals, correlation = corfit$consensus)

6.4 设置比较组

这里我们设置一下比较组,用-分隔。👐

cm <- makeContrasts(antiBLTA_vs_Control_For_Bcell = 
anti_BTLA.Purified_B_cell-Control.Purified_B_cell,

antiBLTA_vs_Control_For_Tcell =
anti_BTLA.Purified_CD4_T_cell-Control.Purified_CD4_T_cell,

Bcell_vs_Tcell_For_Control =
Control.Purified_B_cell-Control.Purified_CD4_T_cell,

Bcell_vs_Tcell_For_antiBLTA =
anti_BTLA.Purified_B_cell-anti_BTLA.Purified_CD4_T_cell,
levels = design )

6.5 差异分析

1️⃣ 现在我们比较一下在B细胞anti-BLTA组和Control组之间的差异表达基因。

fit2 <- contrasts.fit(fit, cm)
fit2 <- eBayes(fit2)

res_antiBLTA_vs_Control_For_Bcell <- topTable(fit2,
coef = "antiBLTA_vs_Control_For_Bcell",
n = Inf,
#p.value = 0.05
)
alt

2️⃣ 再比较一下在T细胞anti-BLTA组和Control组之间的差异表达基因。

res_antiBLTA_vs_Control_For_Tcell <- topTable(fit2, 
coef = "antiBLTA_vs_Control_For_Tcell",
n = Inf,
#p.value = 0.05
)
alt

3️⃣ 再比较一下Control组内T细胞B细胞之间的差异表达基因。

res_Bcell_vs_Tcell_For_Control <- topTable(fit2, 
coef = "Bcell_vs_Tcell_For_Control",
n = Inf,
#p.value = 0.05
)
alt

4️⃣ 再比较一下anti-BLTA组内T细胞B细胞之间的差异表达基因。

res_Bcell_vs_Tcell_For_antiBLTA <- topTable(fit2, 
coef = "Bcell_vs_Tcell_For_antiBLTA",
n = Inf,
#p.value = 0.05
)
alt

7可视化

我们直接用火山图可视化对比一下吧。🤒 这里我们把阈值设置为|logFC|>1pvalue<0.05

library(EnhancedVolcano)
library(patchwork)

p1 <- EnhancedVolcano(res_antiBLTA_vs_Control_For_Bcell,
lab = rownames(res_antiBLTA_vs_Control_For_Bcell),
x = 'logFC',
y = 'P.Value',
title = 'B cell (anti-BTLA vs Control)',
pointSize = 3.0,
labSize = 6.0,
legendPosition = 'right',
pCutoff = 0.05,
FCcutoff = 1)


p2 <- EnhancedVolcano(res_antiBLTA_vs_Control_For_Tcell,
lab = rownames(res_antiBLTA_vs_Control_For_Tcell),
x = 'logFC',
y = 'P.Value',
title = 'T cell (anti-BTLA vs Control)',
pointSize = 3.0,
labSize = 6.0,
legendPosition = 'right',
pCutoff = 0.05,
FCcutoff = 1)

p3 <- EnhancedVolcano(res_Bcell_vs_Tcell_For_Control,
lab = rownames(res_Bcell_vs_Tcell_For_Control),
x = 'logFC',
y = 'P.Value',
title = 'B cell vs T cell (Control)',
pointSize = 3.0,
labSize = 6.0,
legendPosition = 'right',
pCutoff = 0.05,
FCcutoff = 1)

p4 <- EnhancedVolcano(res_Bcell_vs_Tcell_For_antiBLTA,
lab = rownames(res_Bcell_vs_Tcell_For_antiBLTA),
x = 'logFC',
y = 'P.Value',
title = 'B cell vs T cell (anti-BLTA)',
pointSize = 3.0,
labSize = 6.0,
legendPosition = 'right',
pCutoff = 0.05,
FCcutoff = 1)


wrap_plots(p1,p2,p3,p4)
alt

最后祝大家早日不卷!~

点个在看吧各位~ ✐.ɴɪᴄᴇ ᴅᴀʏ 〰

alt

本文由 mdnice 多平台发布

  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值