**0**wrote:

I am using R Studio (vegan package) to run mantel tests to see if the microbial species diversity in my samples was correlated with specific soil properties (such as, nitrogen or soil pH). (This is hopefully a very simplistic answer for someone more familiar with the R vegan package than myself).

I am able to run a mantel test using the entirety of both of my dissimilarity matrices (one for species and one for soil properties). However, I cannot figure out how to run individual mantel tests on individual soil properties (say, just on soil pH).

My data is formatted correctly (rows are sites and columns are species or soil properties), I just need the code for running it on a portion of my data.

This is the code I ran:

bray.dist.otu<-vegdist(species_data, method = "bray") #using rarefied species data

bray.dist.soil<-vegdist(soil_data, method = "bray") #using scaled soil data

bray.mantel<-mantel(bray.dist.otu, bray.dist.soil, permutations = 999)

bray.mantel

R Output:

```
Mantel statistic based on Pearson's product-moment correlation
Call:
mantel(xdis = bray.dist.otu, ydis = bray.dist.soil, permutations = 999)
Mantel statistic r: 0.4063
Significance: 0.001
Upper quantiles of permutations (null model):
90% 95% 97.5% 99%
0.0678 0.0922 0.1088 0.1227
Permutation: free
Number of permutations: 999
```

Question: How would I get it to run the mantel test **on just one column of my soil data** against my species data? (aka: is there an argument to use for just one column instead of the entirety of the dataset?)

The mantel() function takes two dissimilarity matrices as input so just compute a distance matrix using the part of the data you need, e.g. vegdist(soil_data[, 3], method = "bray"). Or am I missing something ?

16kThank you!! I figured it would be something obvious like that.

0