普氏分析在生信中的应用

普氏分析(Procrustes Analysis)

在微生物群落研究的过程中,我们经常需要评估微生物群落结构与环境因子整体之间是否具有显著的相关性,此时,通常使用的方式是Mantel test普氏分析

普鲁克分析(Procrustes Analysis) 又名普氏分析,是一种用来分析形状分布的统计方法。应用在数据分析中,可以理解为比较两组数据一致性的方法,主要用于表示样品不同方面的数据关联度。在宏基因组测序中, Procrustes分析常用于解释细菌组成与耐药基因的相关性,细菌与功能基因的相关性;在转录组测序中, Procrustes分析可用于解释基因与表型的相关性等;在物种分类中,普氏分析可以解释不同基因对物种鉴定的一致性。

在这里,我用Procrustes Analysis分析了地表水和地下水微生物群落的相似性和一致性。

library(vegan)
groundwater<-read.table("clipboard",header = T)
surface<-read.table("clipboard",header=T)
groundwater.dist<-vegdist(groundwater,method = "bray")
surface.dist<-vegdist(surface,method = "bray")

mds.ground<-monoMDS(groundwater.dist)
mds.surface<-monoMDS(surface.dist)

pro.g.s<-procrustes(mds.ground,mds.surface)
pro.g.s
protest(mds.ground,mds.surface)

Y <- cbind(data.frame(pro.g.s$Yrot), data.frame(pro.g.s$X))
X <- data.frame(pro.g.s$rotation)

Y$ID <- rownames(Y)

p <- ggplot(Y) +
  geom_segment(aes(x = X1, y = X2, xend = (X1 + MDS1)/2, yend = (X2 + MDS2)/2), 
               arrow = arrow(length = unit(0, 'cm')),
               color = "#B2182B", size = 1) +
  geom_segment(aes(x = (X1 + MDS1)/2, y = (X2 + MDS2)/2, xend = MDS1, yend = MDS2), 
               arrow = arrow(length = unit(0, 'cm')),
               color = "#56B4E9", size = 1) +
  geom_point(aes(X1, X2), fill = "#B2182B", size = 4, shape = 21) +
  geom_point(aes(MDS1, MDS2), fill = "#56B4E9", size = 4, shape = 21) +
  theme(panel.grid = element_blank(), 
        panel.background = element_rect(color = 'black', fill = 'transparent'),
        legend.key = element_rect(fill = 'transparent'),
        axis.ticks.length = unit(0.4,"lines"), axis.ticks = element_line(color='black'),
        axis.line = element_line(colour = "black"), 
        axis.title.x=element_text(colour='black', size=14),
        axis.title.y=element_text(colour='black', size=14),
        axis.text=element_text(colour='black',size=12)) +
  labs(x = 'Dimension 1', y = 'Dimension 2', color = '') +
  labs(title="Correlation between community and environment") + 
  geom_vline(xintercept = 0, color = 'gray', linetype = 2, size = 0.3) +
  geom_hline(yintercept = 0, color = 'gray', linetype = 2, size = 0.3) +
  geom_abline(intercept = 0, slope = X[1,2]/X[1,1], size = 0.3) +
  geom_abline(intercept = 0, slope = X[2,2]/X[2,1], size = 0.3) +
  annotate('text', label = 'Procrustes analysis:\n    M2 = ###, p-value = ###',x = -1.5, y = 1.2, size = 4,hjust = 0) +
  theme(plot.title = element_text(size=16,colour = "black",hjust = 0,face = "bold"))
p

其中groundwater和surface分别是地下水和地表水的物种相对丰度表,行为样本,列为物种。普氏分析需要两张表的行相对应,这里是按照地下水的采样点和地表水采样点的距离最近相对应。
普氏分析在生信中的应用_第1张图片
执行完protest(mds.ground,mds.surface)会出现以下信息:
普氏分析在生信中的应用_第2张图片
其中Procrustes Sum of Squares就是M²,Significance是P-value。M²越小表示两个群落之间越一致。

普氏分析在生信中的应用_第3张图片
其中的M²和p值可以将图片导出pdf用AI手动填入。

你可能感兴趣的:(R,宏基因组,生信,r语言)