使用ggClusternet包探索不同种类微生物之间的相关关系-以不同门之间相关关系为例
写在前面
在微生物网络中,整体的网络往往让我们损失一部分信息,或者对于一些比较小的信息不容易看到,例如,门水平之间的相关关系对于不同门的微生物来讲是不一样的,我们整个网络中不会注意到这部分相关,但是如果将不同门分开来,仅仅展示门与门之间的相关连线,就可以很方便的查看不同门水平之间的关系。
当然其他水平的微生物之间相互作用也可以做,就看你的选择!
实战
准备数据
将数据过滤到200个左右,降低运行时间。
library(ggClusterNet)
data(ps)
ps_sub = filter_taxa(ps, function(x) sum(x ) > 500 , TRUE);ps_sub #筛选序列数量大于1的
# phyloseq-class experiment-level object
# otu_table() OTU Table: [ 192 taxa and 18 samples ]
# sample_data() Sample Data: [ 18 samples by 10 sample variables ]
# tax_table() Taxonomy Table: [ 192 taxa by 7 taxonomic ranks ]
# phy_tree() Phylogenetic Tree: [ 192 tips and 191 internal nodes ]
准备分组文件,这里必须在tax文件后面加上一列filed,作为分组,注意一定要列名是filed,因为计算过程会识别这个列名,没有就会出现错误。
其次准备一个分组文件,用于布局计算。
tax = as.data.frame(vegan_tax(pssub))
head(tax)
tax$filed = tax$Phylum
tax_table(pssub) = as.matrix(tax)
group2 <- data.frame(SampleID = row.names(tax),Group = tax$filed)
group2$taxg = gsub("g__","",tax$Family)
colnames(group2) <- c("ID","group","taxg")
group2$group =as.factor(group2$group)
使用典型布局函数进行运算出图
result <- corBiostripe(ps = pssub,
# group = group2,
r.threshold = 0.8,
p.threshold = 0.05
)
#--提取相关矩阵
cor = result[[1]]
result2 = PolygonRrClusterG (cor = cor,nodeGroup = group2,zoom = 1,zoom2 = 1 )
node = result2[[1]]
### nodeadd 节点注释的简单封装,便捷实用otu表格和分组文件进行注释
library(dplyr)
nodes <- node %>%
inner_join(group2,by =c("elements" = "ID") )
#-----计算边#--------
edge = edgeBuild(cor = cor,plotcord = node)
head(edge)
### 出图
pnet <- ggplot() + geom_segment(aes(x = X1, y = Y1, xend = X2, yend = Y2,color = as.factor(wei_label)),
data = edge, size = 0.5) +
geom_point(aes(X1, X2,fill = group),pch = 21, size = 5,data = nodes) +
scale_colour_brewer(palette = "Set1") + theme_void()
pnet
多边形布局半径相同
result2 = PolygonClusterG(cor = cor,nodeGroup = group2,zoom = 3,zoom2 = 2 )
node = result2[[1]]
# layouts = c("circle","adj","circrand","eigen","random")
#-------计算网络布局-得到节点坐标=node#---------
result2 = ranSNEClusterG (cor= cor,layout ="random")
result2 = ranSNEClusterG (cor= cor,layout ="circrand")
node = result2[[1]]
library(dplyr)
nodes <- node %>%
inner_join(group2,by =c("elements" = "ID") )
edge = edgeBuild(cor = cor,plotcord = node)
pnet <- ggplot() + geom_segment(aes(x = X1, y = Y1, xend = X2, yend = Y2,color = as.factor(wei_label)),
data = edge, size = 0.5) +
geom_point(aes(X1, X2,fill = group),pch = 21, size = 5,data = nodes) +
scale_colour_brewer(palette = "Set1") + theme_void()
pnet
基于聚类的”random”可视化
# layouts = c("circle","adj","circrand","eigen","random")
#-------计算网络布局-得到节点坐标=node#---------
result2 = ranSNEClusterG (cor= cor,layout ="random")
node = result2[[1]]
library(dplyr)
nodes <- node %>%
inner_join(group2,by =c("elements" = "ID") )
edge = edgeBuild(cor = cor,plotcord = node)
pnet <- ggplot() + geom_segment(aes(x = X1, y = Y1, xend = X2, yend = Y2,color = as.factor(wei_label)),
data = edge, size = 0.5) +
geom_point(aes(X1, X2,fill = group),pch = 21, size = 5,data = nodes) +
scale_colour_brewer(palette = "Set1") + theme_void()
pnet
基于聚类的circrand可视化
# layouts = c("circle","adj","circrand","eigen","random")
result2 = ranSNEClusterG (cor= cor,layout ="circrand")
node = result2[[1]]
library(dplyr)
nodes <- node %>%
inner_join(group2,by =c("elements" = "ID") )
edge = edgeBuild(cor = cor,plotcord = node)
pnet <- ggplot() + geom_segment(aes(x = X1, y = Y1, xend = X2, yend = Y2,color = as.factor(wei_label)),
data = edge, size = 0.5) +
geom_point(aes(X1, X2,fill = group),pch = 21, size = 5,data = nodes) +
scale_colour_brewer(palette = "Set1") + theme_void()
pnet
根际互作生物学研究室 简介
根际互作生物学研究室是沈其荣教授土壤微生物与有机肥团队下的一个关注于根际互作的研究小组。本小组由袁军副教授带领,主要关注:1.植物和微生物互作在抗病过程中的作用;2 环境微生物大数据整合研究;3 环境代谢组及其与微生物过程研究体系开发和应用。团队在过去三年中在 isme J, Microbiome, PCE,SBB,Horticulture Research等期刊上发表了多篇文章。欢迎关注 微生信生物 公众号对本研究小组进行了解。
团队工作及其成果 (点击查看)
了解 交流 合作
团队成员邮箱 袁军:
junyuan@njau.edu.cn;
文涛:
2018203048@njau.edu.cn
团队公众号: