Permutational multivariate analysis of variance (PERMANOVA), also known as nonparametric multivariate analysis of variance, or ADONIS analysis. It uses the distance matrix (such as Euclidean distance, Bray-Curtis distance) to decompose the total variance, analyzes the explanation degree of different grouping factors or different environmental factors to the sample differences, and uses the "permutation test" to analyze the statistical significance of each variable explanation . Significant analysis.
one example
PCA
For example, after // dimensionality reduction visualization of species abundance data detected by metagenomics , there is some NMDS
overlap PCoA
between samples in different groups, so how to judge whether there are significant differences in sample composition between these groups? This requires PERMANOVA
a test to test whether the center points of samples in different groups overlap.
Taking the above PCoA
picture as an example, the four groups of sample points circled by ellipses correspond to the four altitude groups. Are the community differences among these four groups of samples significant? The essence of testing community differences between groups is to test the differences between distance matrices, and ordinary ANOVA analysis is powerless. The analysis based on the distance matrix PerMANOVA
showed that the difference between these four groups was significant (p<0.05).
❝Rui J, Li J, Wang S, et al. Responses of Bacterial Communities to Simulated Climate Changes in Alpine Meadow Soil of the Qinghai-Tibet Plateau. Appl Environ Microbiol. 2015;81(17):6070-6077. doi:10.1128/AEM.00557-15
❞
Sample data and code collection
点赞
, 在看
This article, share it in the circle of friends 集赞20个
and 保留30分钟
send the screenshot to WeChat mzbj0002
to receive it.
"Chuzhou Notes 2022 VIP can receive it for free" .
❝"Note:" 2022 will be over soon, for the convenience of readers and friends, it is now launched
❞木舟笔记永久VIP
at a price169¥
.2022VIP
Only pay the difference to upgrade.木舟笔记永久VIP
Enjoy all the resources of this account (except for limited courses), and no VIP plans will be launched in the future.
Muzhou Notes 2022 VIP Plan
"rights and interests:"
"2022" Muzhou Notes all tweet sample data and codes ( "updated in real time in the VIP group" ).
data+code Muzhou Notes "Scientific Research Exchange Group" .
"Half price" purchase
跟着Cell学作图系列合集
(free tutorial + code collection) | Follow Cell to learn drawing series collection .
"TOLL:"
"99¥/person" . You can add WeChat: mzbj0002
transfer, or directly reward at the end of the article.
combat
PCoA
# Load package
library(vegan)
library(ggplot2)
library(ggthemes)
# Load data
otu <- read.table('otu.txt',row.names = 1,header = T)
group <- read.table('group.txt',header = T)
#pcoa
# vegdist函数,计算距离;method参数,选择距离类型
distance <- vegdist(otu, method = 'bray')
# 对加权距离进行PCoA分析
pcoa <- cmdscale(distance, k = (nrow(otu) - 1), eig = TRUE)
## plot data
# 提取样本点坐标
plot_data <- data.frame({pcoa$point})[1:2]
# 提取列名,便于后面操作。
plot_data$ID <- rownames(plot_data)
names(plot_data)[1:2] <- c('PCoA1', 'PCoA2')
# eig记录了PCoA排序结果中,主要排序轴的特征值(再除以特征值总和就是各轴的解释量)
eig = pcoa$eig
#为样本点坐标添加分组信息
plot_data <- merge(plot_data, group, by = 'ID', all.x = TRUE)
head(plot_data)
# 计算加权bray-curtis距离
dune_dist <- vegdist(otu, method="bray", binary=F)
dune_pcoa <- cmdscale(dune_dist, k=(nrow(otu) - 1), eig=T)
dune_pcoa_points <- as.data.frame(dune_pcoa$points)
sum_eig <- sum(dune_pcoa$eig)
eig_percent <- round(dune_pcoa$eig/sum_eig*100,1)
colnames(dune_pcoa_points) <- paste0("PCoA", 1:3)
dune_pcoa_result <- cbind(dune_pcoa_points, group)
head(dune_pcoa_result)
library(ggplot2)
ggplot(dune_pcoa_result, aes(x=PCoA1, y=PCoA2, fill=group)) +
geom_point(shape = 21,color = 'black',size=4) +
stat_ellipse(level=0.95)+
scale_fill_manual(values = c('#73bbaf','#d15b64','#592c93'))+
labs(x=paste("PCoA 1 (", eig_percent[1], "%)", sep=""),
y=paste("PCoA 2 (", eig_percent[2], "%)", sep="")) +
theme_classic()
PERMANOVA
# 基于bray-curtis距离进行计算
dune.div <- adonis2(otu ~ group, data = group, permutations = 999, method="bray")
dune.div
library(ggalt)
dune_adonis <- paste0("adonis R2: ",round(dune.div$R2,2), "; P-value: ", dune.div$`Pr(>F)`)
p <- ggplot(dune_pcoa_result, aes(x=PCoA1, y=PCoA2, fill=group)) +
geom_point(shape = 21,color = 'black',size=4) +
stat_ellipse(level=0.95)+
scale_fill_manual(values = c('#73bbaf','#d15b64','#592c93'))+
labs(x=paste("PCoA 1 (", eig_percent[1], "%)", sep=""),
y=paste("PCoA 2 (", eig_percent[2], "%)", sep=""),
title=dune_adonis) +
theme_classic()
p
Pair Adonis
# 配对Adonis确定两两分组之间对物种组成差异的影响
#devtools::install_github("pmartinezarbizu/pairwiseAdonis/pairwiseAdonis")
library(pairwiseAdonis)
dune.pairwise.adonis <- pairwise.adonis(x=otu, factors=group$group,
sim.function = "vegdist",
sim.method = "bray",
p.adjust.m = "BH",
reduce = NULL,
perm = 999)
library(ggpubr)
library(patchwork)
tab2 <- ggtexttable(dune.pairwise.adonis[,c("pairs","R2","p.value","p.adjusted")], rows = NULL,
theme = ttheme("blank")) %>%
tab_add_hline(at.row = 1:2, row.side = "top", linewidth = 1) %>%
tab_add_hline(at.row = nrow(dune.pairwise.adonis)+1, row.side = "bottom", linewidth = 1)
p + tab2 + plot_layout(design=c(area(1,1), area(2,1)))
previous content
How to draw this picture | Correlation Analysis Lollipop Chart
(Free tutorial + code collection) | Follow Cell to learn drawing series collection
R actual combat | Lasso regression model establishment and variable screening
Follow NC to map | Advanced interaction network diagram (protein + enrichment pathway) (Cytoscape)
R actual combat | Add a circle to the clustering (ggunchull)