Reputation: 1
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:
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