前言:加权基因共表达网络分析(weighted gene co-expression network analysis,WGCNA)是研究相似基因表达模式的一种方法,通过寻找协同表达的基因模块,研究这些模块与临床表型之间的关系,并识别网络中的关键基因(Langfelder & Horvath, 2008)。普通的共表达网络分析,通过绝对的阈值对基因相关性进行筛选,将会导致一定的信息丢失,WGCNA通过引入加权的相关系数来更加全面的体现基因表达之间的相关性,发掘其中的生物学意义。我们拟对AGING上发表的“Identification of biomarkers related to CD8+ T cell infiltration with gene co-expression network in clear cell renal cell carcinoma”(Lin et al., 2020)文章进行结果重现。
具体实现过程如下:
1.1 数据获取
从GEO网站下载GSE73731数据,该数据中包括了265个ccRCC样本的测序数据。
1.2 数据预处理
###### 读入数据并进行矫正
### 加载R包,读入数据
library(GEOquery)
library(ggplot2)
library(reshape2)
library(limma)
options(stringsAsFactors=F)
gset <- getGEO(filename='GSE73731_series_matrix.txt',AnnotGPL=TRUE,destdir='./')
exp.mat <- exprs(gset)
sample.info.dat <- pData(gset)
gene.info.dat <- fData(gset)
# 查看样本间表达值分布,如图1所示
boxplot(exp.mat)
图1 样本间基因表达值分布.png
# 芯片间表达数据矫正
exp.norm.mat <- normalizeBetweenArrays(exp.mat)
### 去除没有基因symbol的探针
gene.filtered <- (!grepl("///", gene.info.dat[,"Gene symbol"])) & (gene.info.dat[,"Gene symbol"]!="")
gene.symbol.dat <- data.frame(GeneSymbol=gene.info.dat[gene.filtered,"Gene symbol"])
rownames(gene.symbol.dat) <- rownames(gene.info.dat)[gene.filtered]
exp.norm.mat <- exp.norm.mat[gene.filtered,]
### 对于对应相同基因symbol的多个探针,取各个探针的平均表达值
symbol.mean.list <- by(exp.norm.mat,gene.symbol.dat$GeneSymbol,colMeans)
symbol.mean.mat <- matrix(unlist(symbol.mean.list), byrow=T, ncol=ncol(exp.norm.mat))
rownames(symbol.mean.mat) <- names(symbol.mean.list)
colnames(symbol.mean.mat) <- names(symbol.mean.list[[1]])
# 查看矫正之后各个样本的表达分布,如图2所示,与图1相比,可看出芯片的批次效应得到矫正
exp.melt.dat <- melt(symbol.mean.mat,value.name="Expression")
colnames(exp.melt.dat)[1:2] <- c('Gene','Sample')
pdf('expression.mean.norm.pdf',width=60,height=5)
ggplot(exp.melt.dat,aes(x=Sample,y=Expression,fill=Sample)) +
geom_boxplot() +
theme(legend.position='none',axis.text.x = element_text(angle=45, hjust=1, vjust=0.5))
dev.off()
图2 矫正之后样本间基因表达值分布.png
# 计算基因变异系数(CV),根据CV>0.1取高变异基因进行下游分析
symbol.cv.vec <- apply(symbol.mean.mat,1,function(x){ sd(x)/mean(x) })
symbol.mean.filter.mat <- symbol.mean.mat[symbol.cv.vec > 0.1,]
symbol.mean.dat <- data.frame(symbol.mean.filter.mat)
1.3 WGCNA网络构建
###### 参照WGCNA教程,对265例ccRCC表达数据构建加权共表达网络
### 加载R包
library(WGCNA)
library(ggplot2)
library(reshape2)
library(limma)
library(plyr)
# 检查数据中是否有缺失值
datExpr <- t(symbol.mean.dat)
gsg <- goodSamplesGenes(datExpr, verbose = 3)
gsg$allOK
### 计算合适的相关系数软阈值,如图3所示,据此可选择3或4为相关性软阈值power
powers <- c(c(1:10), seq(from = 12, to=20, by=2))
sft <- pickSoftThreshold(datExpr, powerVector = powers, verbose = 5)
pdf(file = "Plots/SoftThreshold.pdf", width = 8, height = 4)
par(mfrow = c(1,2))
plot(sft$fitIndices[,1], -sign(sft$fitIndices[,3])*sft$fitIndices[,2], xlab="Soft Threshold (power)",ylab="Scale Free Topology Model Fit,signed R^2",type="n", main = paste("Scale independence"))
text(sft$fitIndices[,1], -sign(sft$fitIndices[,3])*sft$fitIndices[,2],labels=powers,cex=0.9,col="red")
abline(h=0.85,col="red")
plot(sft$fitIndices[,1], sft$fitIndices[,5], xlab="Soft Threshold (power)",ylab="Mean Connectivity", type="n", main = paste("Mean connectivity"))
text(sft$fitIndices[,1], sft$fitIndices[,5], labels=powers, cex=0.9,col="red")
dev.off()
图3 scale-free fit index (left) and average connectivity (right) of 1-20 soft threshold power.png
###### Step-by-step network construction
### 计算邻接矩阵与相异矩阵
adjacency <- adjacency(datExpr, power = sft$powerEstimate)
TOM <- TOMsimilarity(adjacency)
dissTOM <- 1-TOM
geneTree <- hclust(as.dist(dissTOM), method = "average")
### 使用动态剪切树算法鉴定相关模块
minModuleSize = 30
dynamicMods <- cutreeDynamic(dendro = geneTree, distM = dissTOM, deepSplit = 2, pamRespectsDendro = FALSE, minClusterSize = minModuleSize,cutHeight=0.99)
table(dynamicMods)
dynamicColors <- labels2colors(dynamicMods)
### 将相似的模块聚类,如图4所示
MEList <- moduleEigengenes(datExpr, colors = dynamicColors)
MEs <- MEList$eigengenes
MEDiss <- 1-cor(MEs)
METree <- hclust(as.dist(MEDiss), method = "average")
pdf(file = "Plots/cluster.module.step2.pdf", width = 8, height = 6)
plot(METree, main = "Clustering of module eigengenes", xlab = "", sub = "")
MEDissThres = 0.25
abline(h=MEDissThres, col = "red")
dev.off()
图4 模块间相似性聚类.png
### 将相似模块聚为一个模块,如图5所示,除灰色模块外,共鉴定到9个信息模块
merge <- mergeCloseModules(datExpr, dynamicColors, cutHeight = MEDissThres, verbose = 3)
mergedColors <- merge$colors
mergedMEs <- merge$newMEs
moduleColors <- mergedColors
pdf(file = "Plots/dendrogram.module.merged.step2.pdf", width = 8, height = 7)
plotDendroAndColors(geneTree, cbind(dynamicColors, mergedColors), c("Dynamic Tree Cut", "Merged dynamic"), dendroLabels = FALSE, hang = 0.03, addGuide = TRUE, guideHang = 0.05)
dev.off()
图5 基因模块聚类图.png
1.4 细胞成分计算
通过CIBERSORTx(Newman et al., 2019)对bulk测序样本中不同类型免疫细胞的成分进行推算,将265个ccRCC样本的表达矩阵上传至CIBERSORTx网站(https://cibersortx.stanford.edu/)进行在线计算。
1.5 T细胞浸润相关模块鉴定
### 数据读入与预处理
infil.t <- read.csv('CIBERSORTx_Job2_Results.csv',head=T,row.names=1)
infil.t <- infil.t[,grep('T.cells',colnames(infil.t))]
infil.t <- infil.t[colnames(symbol.mean.dat),]
datExpr = as.data.frame(t(symbol.mean.dat))
datTraits = infil.t
nGenes = ncol(datExpr)
nSamples = nrow(datExpr)
### 计算模块eigengene与免疫细胞浸润相关性
MEs0 <- moduleEigengenes(datExpr, mergedColors)$eigengenes
MEs <- orderMEs(MEs0)
moduleTraitCor <- cor(MEs, datTraits, use = "p")
moduleTraitPvalue <- corPvalueStudent(moduleTraitCor, nSamples)
### 相关图展示,如图6所示,可以看出绿色模块与CD8T细胞浸润之间存在显著相关,下面的分析中针对这一模块进行重点研究
textMatrix <- paste(signif(moduleTraitCor, 2), "\n(", signif(moduleTraitPvalue, 1), ")", sep = "")
dim(textMatrix) = dim(moduleTraitCor)
pdf('Plots/Module-trait-relationships.pdf',width=10,height=8)
labeledHeatmap(Matrix = moduleTraitCor,
xLabels = names(datTraits),
yLabels = names(MEs),ySymbols = names(MEs),
colorLabels = FALSE,
colors = blueWhiteRed(50),
textMatrix = textMatrix,
setStdMargins = FALSE,
cex.text = 0.5,
zlim = c(-1,1),
main = paste("Module-trait relationships"))
dev.off()
图6 Module-trait relationships.png
1.6 鉴定hub gene
###### 根据gene significance(GS)和module membership(MM)鉴定具有重要作用的hub gene
### 计算MM
geneModuleMembership <- as.data.frame(cor(datExpr, MEs, use = "p"))
MMPvalue <- as.data.frame(corPvalueStudent(as.matrix(geneModuleMembership), nSamples))
modNames <- substring(names(MEs), 3)
names(geneModuleMembership) = paste("MM", modNames, sep="")
names(MMPvalue) = paste("p.MM", modNames, sep="")
### 计算GS
CD8T <- as.data.frame(datTraits$T.cells.CD8)
names(CD8T) <- "CD8T"
geneTraitSignificance <- as.data.frame(cor(datExpr, CD8T, use = "p"))
GSPvalue <- as.data.frame(corPvalueStudent(as.matrix(geneTraitSignificance), nSamples))
names(geneTraitSignificance) <- paste("GS.", names(CD8T), sep="")
names(GSPvalue) <- paste("p.GS.", names(CD8T), sep="")
### 查看绿色模块内部gene与CD8T细胞浸润的相关性(即GS值),以及与绿色模块eigengene相关性(即MM值)
### 如图7所示,这里我们根据GS>0.5且MM>0.8进行筛选,可以得到66个hub gene
module = "green"
column <- match(module, modNames)
moduleGenes <- moduleColors==module
pdf('Plots/MM-GS.green.pdf',width=7,height=7)
verboseScatterplot(abs(geneModuleMembership[moduleGenes, column]),
abs(geneTraitSignificance[moduleGenes, 1]),
xlab = paste("Module Membership in", module, "module"),
ylab = "Gene significance for body weight",
main = paste("Module membership vs. gene significance\n"),
cex.main = 1.2, cex.lab = 1.2, cex.axis = 1.2, col = module)
dev.off()
图7 Module membership and gene significance in green module.png
1.7 结果汇总
# Summary output of network analysis results
geneInfo0 <- data.frame(GeneSymbol= names(datExpr),
ModuleColor = moduleColors,
geneTraitSignificance,
GSPvalue)
# Order modules by their significance for CD8T
modOrder <- order(-abs(cor(MEs, CD8T, use = "p")));
# Add module membership information in the chosen order
for (mod in 1:ncol(geneModuleMembership))
{
oldNames <- names(geneInfo0)
geneInfo0 <- data.frame(geneInfo0, geneModuleMembership[, modOrder[mod]],
MMPvalue[, modOrder[mod]])
names(geneInfo0) = c(oldNames, paste("MM.", modNames[modOrder[mod]], sep=""),paste("p.MM.", modNames[modOrder[mod]], sep=""))
}
# Order the genes in the geneInfo variable first by module color, then by geneTraitSignificance
geneOrder <- order(geneInfo0$ModuleColor, -abs(geneInfo0$GS.CD8T));
geneInfo <- geneInfo0[geneOrder, ]
write.csv(geneInfo, file = "Plots/geneInfo.csv")
write.csv(rownames(geneInfo)[geneInfo$ModuleColor=='green'], file = "Plots/geneInfo.green.csv",row.names=F)
# 自定义标准选择hub gene
############################################
geneInfo <- read.csv("Plots/geneInfo.csv",header=T,row.names=1)
gene.greenInfo <- geneInfo[geneInfo$ModuleColor=='green',1:6]
hub.gene.green <- rownames(gene.greenInfo)[(gene.greenInfo$GS.CD8T > 0.5) & (gene.greenInfo$MM.green > 0.8)]
write.csv(hub.gene.green,'hub.gene.green.csv')
主要参考文献:
Langfelder, P., & Horvath, S. (2008). WGCNA: an R package for weighted correlation network analysis. BMC bioinformatics, 9(1), 559.
Lin, J., Yu, M., Xu, X., Wang, Y., Xing, H., An, J., ... & Zhu, Y. (2020). Identification of biomarkers related to CD8+ T cell infiltration with gene co-expression network in clear cell renal cell carcinoma. Aging (Albany NY), 12(4), 3694.
Newman, A. M., Steen, C. B., Liu, C. L., Gentles, A. J., Chaudhuri, A. A., Scherer, F., ... & Diehn, M. (2019). Determining cell type abundance and expression from bulk tissues with digital cytometry. Nature biotechnology, 37(7), 773-782.
网友评论