0

I am using vegan Mantel and partial Mantel tests to infer the correlation between those two matrices. Since I have distance ranging from 0 to 400 km, I want to split those matrices in two groups:

  1. Mantel comparing A and B from 0 to 114 km (threshold of Moran`s I autocorrelation);
  2. Mantel comparing A and B from >114 to 400km.

Thanks in advance!

Here is the code I'm using:

setwd("~/Desktop")
library(vegan)
tax <- read.table(file="tax.csv", header=T, row.names=1, sep=";")
geo <- read.table(file="geoc.csv", header=T,  row.names=1, sep=";")

# Distance calculations
tax.dist <- vegdist(tax, method="bray")  # to transform the matrices into Bray-Curtis distance
geo.dist <- vegdist(geo, method="euclidean")

# Mantel test
mantel(geo.dist, tax.dist, method="pearson", permutations=1000) # to perform mantel test

# Plot Mantel correlogram
plot(geo.dist, tax.dist, xlab="Geographic Distance", pch=20, cex=0.8, ylab="Bray-Curtis Dissimilarity") 
abline(lm(tax.dist~env.dist), lwd = 2, col = "red") # to plot the line
Jignasha Royala
  • 1,032
  • 10
  • 27
  • Either this is very easy or extremely tricky (and I don't know how to do this). You do not want to split your data by observations, but inter-observation distances by their length. Basically, `vegan::mantel()` (if that is the function you're writing about – there must be others in R) can handle missing values (`NA`), and you can make long/short `geo.dist` NA, but then `tax.dist` are freely permuted, and you can have `tax.dist` from NA-`geo.dist`. Moreover, the *correct* permutation is not by individual distances, but by rows/columns equally. Combining these two desires gives me headache. – Jari Oksanen Mar 12 '21 at 18:26
  • @JariOksanen. Thank you for your thoughts professor Oksanen. Finally, I solved this issue with the matrices transformation, using reshape2 and metan packages on R. Thank you sir! – Dennis Göss Mar 16 '21 at 11:51

0 Answers0