導(dǎo)讀
用R軟件corr.test函數(shù)進(jìn)行兩組數(shù)組的相關(guān)性分析欲低,用Cytoscape繪制相關(guān)網(wǎng)絡(luò)圖。
一艰额、輸入數(shù)據(jù)
代謝數(shù)據(jù):metabo.txt
16S數(shù)據(jù):genus.txt
二肪凛、R分析相關(guān)性
計(jì)算genus和metabo相關(guān)性
利用psych函數(shù)包中的corr.test函數(shù)計(jì)算兩組數(shù)據(jù)之間的相關(guān)性
參數(shù)說明:
pairwise: 樣品配對(duì)剔除
use: 相關(guān)性計(jì)算方法pearson/spearman/kendall
adjust: 矯正方法
ci & alpha: 置信區(qū)間
minlength: 縮寫長(zhǎng)度
# 加載函數(shù)包
library(psych)
# 數(shù)據(jù)導(dǎo)入
genus=read.table("genus.txt", row.names=1, header=T, sep="\t")
metabo=read.table("metabo.txt", row.names=1, header=T, sep="\t")
# 計(jì)算相關(guān)性: print & data.frame調(diào)整結(jié)果格式
result_pair=data.frame(print(corr.test(genus, metabo, use="pairwise", method="spearman", adjust="fdr", alpha=.05, ci=TRUE, minlength=10), short=FALSE))
# 查看結(jié)果
head(result_pair)
三骡苞、整理分析結(jié)果
pair=rownames(result_pair) # 行名
result_pair2=data.frame(result_pair[, c(2, 4)], pair) # 提取信息
# P值排序
result_pair3=data.frame(result_pair2[order(result_pair2[,"raw.p"], decreasing=F),])
# 統(tǒng)計(jì)顯著相關(guān)的數(shù)量
n=0
for(i in 1:nrow(result_pair3))
{
if(result_pair3[i, 2]<=0.05)
{
n=n+1
}
}
# n=71
# 提取顯著相關(guān)結(jié)果
result_pair4=result_pair3[result_pair3$raw.p<=0.05, ]
# 保存提取的結(jié)果
write.table(result_pair4, file="corr.txt", sep="\t", row.names=F, quote=F)
查看結(jié)果:相關(guān)性大于在[-1, 1]之間,絕對(duì)值越接近1表示相關(guān)性越強(qiáng)
四喘先、準(zhǔn)備Cytoscape輸入文件
相關(guān)數(shù)據(jù):input_network.txt
用vlookup把genus和keggID換成具體的名稱钳吟;正相關(guān)標(biāo)記為pos,負(fù)相關(guān)標(biāo)記為neg苹祟,r值去掉正負(fù)砸抛。
分組數(shù)據(jù):input_group.txt
五、Cytoscape數(shù)據(jù)導(dǎo)入
- 1 打開cytoscape3.5.1
- 2 點(diǎn)擊With Empty Network
- 3 輸入network name树枫,點(diǎn)擊OK
- 4 導(dǎo)入相關(guān)數(shù)據(jù)
- 5 以genus為source node直焙,kegg為target,點(diǎn)擊OK
- 6 導(dǎo)入分組文件:打開砂轻,OK
六奔誓、Cytoscape圖形設(shè)置
1 設(shè)置圖形大小、線條粗細(xì)
顯著相關(guān)越多,圖形越大厨喂;相關(guān)性越強(qiáng)線條越粗
2 設(shè)置圖形顏色
3 設(shè)置線條顏色
七派阱、保存結(jié)果
保存:整個(gè)工作
保存:pdf或png
參考:
微生物研究必備:Cytoscape繪制網(wǎng)絡(luò)圖(一)
微生物研究必備:Cytoscape繪制網(wǎng)絡(luò)圖(二)
微生物研究必備:Cytoscape繪制網(wǎng)絡(luò)圖(三)
微生物研究必備:Cytoscape繪制網(wǎng)絡(luò)圖(四)
微生物研究必備:Cytoscape繪制網(wǎng)絡(luò)圖(五)