Load packages and files

library(vegan)  # For mantel() function
## Loading required package: permute
## Loading required package: lattice
## This is vegan 2.6-4
  gendist <- read.csv("GenDist_mantel.csv", header = TRUE, row.names = 1)
  pathgen <- read.csv("PathGen_mantel.csv", header = TRUE, row.names = 1)
  
  geodist <- read.csv("GeoDistCen_mantel.csv", header = TRUE, row.names = 1)
  pathgeo <- read.csv("PathGeo_mantel.csv", header = TRUE, row.names = 1)
  
  gen <- read.csv("GenDist_mantel2.csv", header = TRUE, row.names = 1)
  geodist2 <- read.csv("GeoDistCen_mantel2.csv", header=TRUE, row.names=1)

#Genetic Distance and path

ncol(gendist)
## [1] 47
set.seed(123)
  mantel_result_1 <- mantel(gendist, pathgen, method = "pearson",
      permutations = 1000, na.rm = TRUE)
  mantel_result_1
## 
## Mantel statistic based on Pearson's product-moment correlation 
## 
## Call:
## mantel(xdis = gendist, ydis = pathgen, method = "pearson", permutations = 1000,      na.rm = TRUE) 
## 
## Mantel statistic r: 0.1148 
##       Significance: 0.024975 
## 
## Upper quantiles of permutations (null model):
##    90%    95%  97.5%    99% 
## 0.0718 0.0968 0.1117 0.1310 
## Permutation: free
## Number of permutations: 1000

#Geo distance and path

set.seed(123)
ncol(geodist)
## [1] 44
  mantel_result_2 <- mantel(geodist, pathgeo, method = "pearson",
      permutations = 1000, na.rm = TRUE)
  mantel_result_2
## 
## Mantel statistic based on Pearson's product-moment correlation 
## 
## Call:
## mantel(xdis = geodist, ydis = pathgeo, method = "pearson", permutations = 1000,      na.rm = TRUE) 
## 
## Mantel statistic r: 0.3629 
##       Significance: 0.000999 
## 
## Upper quantiles of permutations (null model):
##    90%    95%  97.5%    99% 
## 0.0877 0.1142 0.1378 0.1613 
## Permutation: free
## Number of permutations: 1000

#Geo and genetic distance

set.seed(123)
  mantel_result_3 <- mantel(geodist2, gen, method = "pearson", permutations = 1000,
        na.rm = TRUE)
  mantel_result_3
## 
## Mantel statistic based on Pearson's product-moment correlation 
## 
## Call:
## mantel(xdis = geodist2, ydis = gen, method = "pearson", permutations = 1000,      na.rm = TRUE) 
## 
## Mantel statistic r: -0.07115 
##       Significance: 0.94505 
## 
## Upper quantiles of permutations (null model):
##    90%    95%  97.5%    99% 
## 0.0604 0.0863 0.1064 0.1251 
## Permutation: free
## Number of permutations: 1000