蒙特尔检验简介
Mantel检验是一种将两个矩阵放在一起,求它们之间的相关性的一种方法。Mantel检验的分析过程主要包括:分别使用各自的距离公式计算两个数据矩阵的距离矩阵,然后将两个距离矩阵进行压缩得到两个压缩距离列,然后计算这两列的相关性;在完成一次计算后,对原数据矩阵中的一列或者两列进行置换,重新计算距离公式以及压缩距离公式,计算新的相关性系数;经过成千上万次的置换后,观察实际数据的相关性系数在经过多次置换后所得的相关性系数分布中位置,如果跟随机置换得到的结果站队接近,则说明相关性不显著,相反则说明两个矩阵具有较强的显著相关性。Mantel分析一般用于植物、微生物群落与生态环境之间相关性的建议以及人体肠道微生物群落与人体疾病相关性检验等领域。
标签:#微生物组数据分析 #MicrobiomeStatPlot #蒙特尔检验相关性热图 #R语言可视化 #Mantel test correlation heatmap
作者:First draft(初稿):Defeng Bai(白德凤);Proofreading(校对):Ma Chuang(马闯) and Jiani Xun(荀佳妮);Text tutorial(文字教程):Defeng Bai(白德凤)
源代码及测试数据链接:
https://github.com/YongxinLiu/MicrobiomeStatPlot/项目中目录 3.Visualization_and_interpretation/MantelTestCorrelationHeatmap
或公众号后台回复“MicrobiomeStatPlot”领取
这篇文章是石河子大学Li Junhua团队2022年发表于Science of the Total Environment(He et al., 2022)上的一篇论文,论文题目为:Commercial organic fertilizer substitution increases wheat yield by improving soil quality. https://doi.org/10.1016/j.scitotenv.2022.158132
图 3 | 土壤性质的Mantel检验分析。
SOM,土壤有机质;TN,土壤总氮;TP,土壤总磷;TK,土壤总钾;AN,土壤碱解氮;AP,土壤有效磷;AK,土壤有效钾;C/N、土壤碳氮比;N/P、土壤碳磷比;pH,土壤pH。R2值代表解释的变化。,****表示p<0.05、p<0.01和p<0.001的显著性水平。
结果
相关分析显示,LF和HF中的小麦生长指标与产量组成部分(除1000粒重外)之间存在显著(p<0.05)正相关,而这些指标与产量显著(p<0.01)正相关(图S2)。此外,在LF和HF中,SOM与土壤总养分和有效养分(HF中的AP和TK除外)之间存在显著的正相关(p<0.05)(图第3a和c段)。在LF和HF中,pH与大多数土壤指标(C/N除外)呈显著负相关(p<0.05,图第3a和C段)。
Mantel检验分析表明,土壤性质(C/N除外)与小麦生长指标(HF中的TK和AK除外)以及LF和HF中的产量及其成分显著正相关(p<0.05,Mantel’r≥0.25,图第3a和C段)。随机森林模型进一步确定,LF中的SOM、AN、AP和AK(p<0.05,图3b),HF中的SOM、TN、AN、美联社、AK和pH是影响产量的关键土壤因素(p<0.05,图图3d)。
源代码及测试数据链接:
https://github.com/YongxinLiu/MicrobiomeStatPlot/
或公众号后台回复“MicrobiomeStatPlot”领取
软件包安装
# 基于CRAN安装R包,检测没有则安装
p_list = c("ggplot2", "dplyr", "vegan")
for(p in p_list){if (!requireNamespace(p)){install.packages(p)}
library(p, character.only = TRUE, quietly = TRUE, warn.conflicts = FALSE)}
# 基于github安装
library(devtools)
if(!requireNamespace("ggradar", quietly = TRUE))
install_github("Hy4m/linkET", force = TRUE)
# 加载R包 Load the package
suppressWarnings(suppressMessages(library(ggplot2)))
suppressWarnings(suppressMessages(library(dplyr)))
suppressWarnings(suppressMessages(library(vegan)))
suppressWarnings(suppressMessages(library(linkET)))
实战
# Load and transform data
## OTU data
df <- read.table("data/otu.txt", header = TRUE, row.names = 1, check.names = FALSE, sep = "\t")
df <- data.frame(t(df))
df <- df[c(1, 3, 4, 2, 8, 10, 6, 9, 7, 11, 5, 12), ]
## Environmental data
env <- read.table("data/env.txt", sep = "\t", header = TRUE, row.names = 1, check.names = FALSE)
env <- as.data.frame(env)
# Perform Mantel test and create custom labels
df_mantel <- mantel_test(df, env,
spec_select = list(
"Yield components" = 1:4,
"Wheat growth indicators" = 5:8,
"Yield" = 9:12
)) %>%
mutate(
df_r = cut(r, breaks = c(-Inf, 0.25, 0.5, Inf),
labels = c("< 0.25", "0.25 - 0.5", ">= 0.5")),
df_p = cut(p, breaks = c(-Inf, 0.01, 0.05, Inf),
labels = c("< 0.01", "0.01 - 0.05", ">= 0.05"))
)
# 连线在右上(The connection is in the top right)
# Save the plot
pdf("results/mantel_plot.pdf", width = 10, height = 8) # Adjust width and height as needed
# Plotting
qcorrplot(correlate(env), type = "lower", diag = FALSE) +
geom_square() +
geom_couple(
aes(
xend = .xend + 1.25, # Define end of line for connections
yend = .yend + 0.5,
colour = df_p,
size = df_r
),
data = df_mantel,
curvature = 0.1
) +
geom_diag_label(
mapping = aes(y = .y + 0.05), # Define label positions on the diagonal
hjust = 0.15
) +
scale_fill_gradientn(colours = RColorBrewer::brewer.pal(11, "RdBu")) + # Color scale for squares
scale_size_manual(values = c(0.5, 1, 2)) +
scale_colour_manual(values = color_pal(3)) +
guides(
size = guide_legend(
title = "Mantel's r",
override.aes = list(colour = "grey35"),
order = 2
),
colour = guide_legend(
title = "Mantel's p",
override.aes = list(size = 3),
order = 1
),
fill = guide_colorbar(title = "Pearson's r", order = 3)
) +
theme(
axis.text.y = element_blank() # Remove y-axis text
)
dev.off() # Close the PDF device
#> png
#> 2
# 连线在左下(The connection is in the bottom left)
# Save the plot
pdf("results/mantel_plot2.pdf", width = 12, height = 8) # Adjust width and height as needed
# Plotting
qcorrplot(correlate(env), type = "upper", diag = FALSE) +
geom_square() +
geom_couple(
aes(
xend = .xend - 0.5, # Define end of line for connections
yend = .yend - 0.25,
colour = df_p,
size = df_r
),
data = df_mantel,
curvature = 0.1
) +
geom_diag_label(
mapping = aes(y = .y + 0.05), # Define label positions on the diagonal
hjust = 0.05
) +
scale_fill_gradientn(colours = RColorBrewer::brewer.pal(11, "RdBu")) + # Color scale for squares
scale_size_manual(values = c(0.5, 1, 2)) +
scale_colour_manual(values = color_pal(3)) +
guides(
size = guide_legend(
title = "Mantel's r",
override.aes = list(colour = "grey35"),
order = 2
),
colour = guide_legend(
title = "Mantel's p",
override.aes = list(size = 3),
order = 1
),
fill = guide_colorbar(title = "Pearson's r", order = 3)
) +
theme(
axis.text.y = element_blank() # Remove y-axis text
)
dev.off() # Close the PDF device
#> png
#> 2
使用此脚本,请引用下文:
Yong-Xin Liu, Lei Chen, Tengfei Ma, Xiaofang Li, Maosheng Zheng, Xin Zhou, Liang Chen, Xubo Qian, Jiao Xi, Hongye Lu, Huiluo Cao, Xiaoya Ma, Bian Bian, Pengfan Zhang, Jiqiu Wu, Ren-You Gan, Baolei Jia, Linyang Sun, Zhicheng Ju, Yunyun Gao, Tao Wen, Tong Chen. 2023. EasyAmplicon: An easy-to-use, open-source, reproducible, and community-based pipeline for amplicon data analysis in microbiome research. iMeta 2: e83. https://doi.org/10.1002/imt2.83
Copyright 2016-2024 Defeng Bai baidefeng@caas.cn, Chuang Ma 22720765@stu.ahau.edu.cn, Jiani Xun 15231572937@163.com, Yong-Xin Liu liuyongxin@caas.cn
猜你喜欢
iMeta高引文章 fastp 复杂热图 ggtree 绘图imageGP 网络iNAP
iMeta网页工具 代谢组MetOrigin 美吉云乳酸化预测DeepKla
iMeta综述 肠菌菌群 植物菌群 口腔菌群 蛋白质结构预测
10000+:菌群分析 宝宝与猫狗 梅毒狂想曲 提DNA发Nature
一文读懂:宏基因组 寄生虫益处 进化树 必备技能:提问 搜索 Endnote
16S功能预测 PICRUSt FAPROTAX Bugbase Tax4Fun
生物科普: 肠道细菌 人体上的生命 生命大跃进 细胞暗战 人体奥秘
写在后面
为鼓励读者交流快速解决科研困难,我们建立了“宏基因组”讨论群,己有国内外6000+ 科研人员加入。请添加主编微信meta-genomics带你入群,务必备注“姓名-单位-研究方向-职称/年级”。高级职称请注明身份,另有海内外微生物PI群供大佬合作交流。技术问题寻求帮助,首先阅读《如何优雅的提问》学习解决问题思路,仍未解决群内讨论,问题不私聊,帮助同行。
点击阅读原文