Dennis Göss
Dennis Göss

Reputation: 1

How to split vegdist matrices according to geographic distance to perform Mantel or MRM analysis?

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

Upvotes: 0

Views: 216

Answers (0)

Related Questions