Mantel test 是對兩個矩陣相關關系的檢驗,由Nathan Mantel在1976年提出。之所以拋開相關系數發展這樣一種方法,是因為相關系數只能處理兩列數據之間的相關性,而在面對兩個矩陣之間的相關性時就束手無策。Mantel檢驗專治這種不服。
這種方法多用於生態學上,不同的樣本case對應不同的變量,而不同的變量可以分屬不同的類別,對case有不同角度的刻畫。如基於不同植物種類數量可以建立樣本間的兩兩距離矩陣,只需套用距離計算公式即可;不同樣本的微生物clone序列,通過Unifrac方法也可以計算得到樣本間距離矩陣;不同位置,兩兩間距離也可以用距離表示。所得到這些矩陣,如果希望驗證兩類描述間有沒有相關關系,就非常有用了。比如我希望檢驗微生物群落是否和植被群落有對應關系,就可以將微生物Unifrac矩陣對植物的比如Bray-Curtis距離矩陣做個相關分析,由得到的結果得出自己的推論。這種方法的好處在於,不管你是什么數據,只要能計算有距離屬性的值,都可以轉化為距離矩陣進行分析。
Mantel test,顧名思義,是一種檢驗。既然是檢驗就得有原假設,它的原假設是兩個矩陣見沒有相關關系。檢驗過程如下:兩個矩陣都對應展開,變量兩列,計算相關系數(理論上什么相關系數都可以計算,但常用pearson相關系數),然后其中一列或兩列同時置換,再計算一個值,permutation 成千上萬次,看實際的r值在所得r值分布中的位置,如果跟隨機置換得到的結果站隊較近,則不大相關,如果遠遠比隨機由此得到顯著性。
如圖,得到的值在這個區域,說明跟隨機出現的數值比較接近,因此
$z.stat
[1] 6.009877
$p
[1] 0.519
這里使用的是z統計量,不是r,使用的ape包里的mantel.test()函數。
The function calculates a Z-statistic for the Mantel test, equal to the sum of the pairwise product of the lower triangles of the permuted matrices, for each permutation of rows and columns. It compares the permuted distribution with the Z-statistic observed for the actual data.
然后用vegan算,用r統計量,得到差不多的結果,也是不顯著。
> mantel(q1,q2)
Mantel statistic based on Pearson's product-moment correlation
Call:
mantel(xdis = q1, ydis = q2)
Mantel statistic r: 0.169
Significance: 0.279
Empirical upper confidence limits of r:
90% 95% 97.5% 99%
0.351 0.425 0.516 0.597
Based on 999 permutations
但是不同相關方法會對結果造成很大的影響,
> mantel(veg.dist, env.dist)
Mantel statistic based on Pearson's product-moment correlation
Call:
mantel(xdis = veg.dist, ydis = env.dist)
Mantel statistic r: 0.3047
Significance: 0.001
Empirical upper confidence limits of r:
90% 95% 97.5% 99%
0.113 0.150 0.174 0.215
Based on 999 permutations
> mantel(veg.dist, env.dist, method="spear")
Mantel statistic based on Spearman's rank correlation rho
Call:
mantel(xdis = veg.dist, ydis = env.dist, method = "spear")
Mantel statistic r: 0.2838
Significance: 0.001
Empirical upper confidence limits of r:
90% 95% 97.5% 99%
0.126 0.160 0.187 0.223
Based on 999 permutations
此處我的理解是:這說明對矩陣也需要檢驗其分布假設,不符合分布假設的條件下用spearman秩相關更靠譜。偏mantel相關函數包括三個變量(矩陣),即控制第三個矩陣影響下前兩個矩陣的相關性。
進一步關於Mantel correlogram。這種方法基於上述相關系數,不過其中一個矩陣換成了設計好的不同距離矩陣,分析相關性,得到不同距離下某多元變量組與之相關性的結果。
> mite.correlog = mantel.correlog(mite.hel.D, XY=mite.xy, nperm=999)
> mite.correlog
Mantel Correlogram Analysis
Call:
mantel.correlog(D.eco = mite.hel.D, XY = mite.xy, nperm = 999)
class.index n.dist Mantel.cor Pr(Mantel) Pr(corrected)
D.cl.1 0.514182 358.000000 0.135713 0.001 0.001 ***
D.cl.2 1.242546 650.000000 0.118174 0.001 0.002 **
D.cl.3 1.970910 796.000000 0.037820 0.052 0.052 .
D.cl.4 2.699274 696.000000 -0.098605 0.001 0.004 **
D.cl.5 3.427638 500.000000 -0.112682 0.001 0.005 **
D.cl.6 4.156002 468.000000 -0.107603 0.001 0.006 **
D.cl.7 4.884366 364.000000 -0.022264 0.134 0.134
D.cl.8 5.612730 326.000000 NA NA NA
D.cl.9 6.341094 260.000000 NA NA NA
D.cl.10 7.069458 184.000000 NA NA NA
D.cl.11 7.797822 130.000000 NA NA NA
D.cl.12 8.526186 66.000000 NA NA NA
D.cl.13 9.254550 32.000000 NA NA NA
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
A table with the distance classes as rows and the class indices, number of distances per class, Mantel statistics (computed using Pearson's r, Spearman's r, or Kendall's tau), and p-values as columns. A positive Mantel statistic indicates positive spatial correlation. An additional column with p-values corrected for multiple testing is added unless mult="none"
.
這種方法多用於空間分析中,用於表征不同尺度下某多元變量的變化趨勢。我還沒有見過用到dna數據上的,可以考慮寫個東西。
基本就這些吧,見到有新鮮應用再討論。