INTEGBI C156 R Project

Diversity Indices

Your goal for this assignment is to find a dataset online that includes species abundances across different plots, sites, or regions. You will conduct diversity analyses on the dataset to compare diversity among these areas.

Tips

Your dataset should include different plots/sites/etc. (at least 3), different species (at least 10), and abundance data (either a column for abundance or where each row represents an individual).

If you are able to find a good dataset you want to use but there is not a column for abundance counts, but each row is an individual (like in a dataset of mice species, each row is an individual mouse e.g. row 1 is Mickey and row 2 in Minnie, etc.), you can still use that dataset by creating a population count column like this:

{r library(dplyr) df_count <- df %>% group_by(species, time) %>% summarize(count = n(), .groups = "drop") %>% ungroup()

If your dataset has separate columns for each plot/habitat/region/etc. you will have to use pivot_longer() before you pivot_wider() while creating your community data matrix, like this:

{r pivot_longer(cols = <first site column name: last site column name>, names_to = "Sites", values_to = "Abundance", values_drop_na = TRUE)

If your dataset has an abundance column but also has repeated rows for some species/sites (if values are erroneously repeated, if if your dataset is over time, etc.), you can use the following to collapse your dataset:

{r df_out <- df_in %>% group_by(<species column>, <site column>) %>% summarize(cumulative_abundance = sum(<abundance column>, .groups = "drop") %>% ungroup()

2) Clean and wrangle your data, describing why you are conducting the cleaning steps you are taking.

Hint: it will be helpful to have 3 objects: your clean dataset in long format, your clean data in wide format, and your clean dataset set-up as a community data matrix

colnames(my_data)
 [1] "Species"                 "Yosemite Valley"        
 [3] "Big Sur Coast"           "Mojave Desert"          
 [5] "Sierra Foothills"        "Point Reyes"            
 [7] "Lake Tahoe"              "Death Valley"           
 [9] "Santa Monica Mountains"  "Channel Islands"        
[11] "Central Valley Wetlands" "San Gabriel Mountains"  
[13] "Anza-Borrego"            "Redwood National Park"  
[15] "Salton Sea"              "Lassen Volcanic Park"   
[17] "Elkhorn Slough"          "Carrizo Plain"          
[19] "Mount Shasta"            "San Diego Chaparral"    
[21] "Lake Berryessa"         
### Deletes sites not located in Southern California.
my_data <- my_data %>% select(-'Yosemite Valley', -'Big Sur Coast', -'Sierra Foothills', -'Point Reyes', -'Lake Tahoe', -'Central Valley Wetlands', -'Redwood National Park', -'Lassen Volcanic Park', -'Elkhorn Slough', -'Mount Shasta', -'Lake Berryessa')

### Deletes non-amphibian species.
my_data <- my_data %>%  filter(!row_number() %in% c(1:55,66:86))

### Inverts rows and columns.
my_data <- t(my_data)

### Converts matrix back into data frame.
my_data <- as.data.frame(my_data)

### Restores original column names.
colnames(my_data) <- my_data[1, ]
my_data <- my_data[-1, ]

### Restores integer type.
my_data <- my_data %>%
  mutate(across(where(is.character), as.integer))

###Prints data frame to check for mistakes.
head(my_data, n=85)
                       California Newt Pacific Tree Frog
Mojave Desert                        4                 9
Death Valley                         9                 2
Santa Monica Mountains               1                 4
Channel Islands                      5                 3
San Gabriel Mountains               12                 9
Anza-Borrego                        10                12
Salton Sea                           7                 2
Carrizo Plain                        9                 1
San Diego Chaparral                  1                 9
                       California Red-legged Frog Western Toad
Mojave Desert                                   3            8
Death Valley                                    9            9
Santa Monica Mountains                          6            8
Channel Islands                                 5            4
San Gabriel Mountains                           3            3
Anza-Borrego                                    1            6
Salton Sea                                      3            8
Carrizo Plain                                   4            6
San Diego Chaparral                             6            5
                       Sierra Nevada Yellow-legged Frog Arroyo Toad
Mojave Desert                                         7           8
Death Valley                                          3           4
Santa Monica Mountains                                6           2
Channel Islands                                       6           4
San Gabriel Mountains                                 3          11
Anza-Borrego                                          3           3
Salton Sea                                            1           7
Carrizo Plain                                        13           3
San Diego Chaparral                                   7           5
                       Foothill Yellow-legged Frog Ensatina Rough-skinned Newt
Mojave Desert                                    6        3                  5
Death Valley                                     6        3                 13
Santa Monica Mountains                           3        7                  3
Channel Islands                                  4        4                  5
San Gabriel Mountains                            2        5                  6
Anza-Borrego                                     5        3                  3
Salton Sea                                       8        8                  0
Carrizo Plain                                    4        0                  2
San Diego Chaparral                             11        4                  0
                       Long-toed Salamander
Mojave Desert                             2
Death Valley                              9
Santa Monica Mountains                    4
Channel Islands                           1
San Gabriel Mountains                     4
Anza-Borrego                              4
Salton Sea                                2
Carrizo Plain                            11
San Diego Chaparral                      13

As aforementioned, I remove columns of sites not belonging to southern California and rows of non-amphibian species. For easier handling, I switched the rows and columns so that the sites are rows and the species are columns. Switching rows and columns caused the data frame to turn into a matrix, so I converted the matrix back into a data frame. I also restored the column names and turned all the data into the data frame back into a numerical form.

3) Calculate and compare diversity metrics among at least 3 plots/sites/areas/etc. (Hint: there were 3 different diversity metrics in lab, with the 3rd having two options for its calculation). What do you observe? Does this align with what you expect from your plots/data above?

### Calculates species richness.
alpha_richness <- rowSums(my_data > 0)

### Calculates Shannon alpha richness.
alpha_shannon <- diversity(my_data, index = "shannon")

### Calculates Simpson alpha richness.
alpha_simpson <- diversity(my_data, index = "simpson")

### Combines alpha metrics into one data frame.
alpha_diversity <- data.frame(
  Richness = alpha_richness,
  Shannon = alpha_shannon,
  Simpson = alpha_simpson
)

alpha_diversity
                       Richness  Shannon   Simpson
Mojave Desert                10 2.207545 0.8819835
Death Valley                 10 2.164124 0.8736912
Santa Monica Mountains       10 2.174500 0.8760331
Channel Islands              10 2.241165 0.8899465
San Gabriel Mountains        10 2.136521 0.8650416
Anza-Borrego                 10 2.104603 0.8568000
Salton Sea                    9 2.019560 0.8544423
Carrizo Plain                 9 1.969929 0.8387326
San Diego Chaparral           9 2.053371 0.8594464

When measured in terms of Shannon alpha diversity, eight sites—with the exception of Carrizo Plain—are within a moderate diversity threshold of 2-3. When measured in terms of Simpson alpha diversity, all nine sites have high species evenness and high species diversity. In other words, no one amphibian species dominates the amphibian taxon that exists in any one of the nine sites in southern California.

### Calculates gamma diversity.
gamma_diversity <- sum(colSums(my_data > 0) > 0)
gamma_diversity
[1] 10

Gamma diversity across all nine sites is 10, which is supported by my earlier calculation of species richness.

### Calculates Whittaker beta diversity (β = γ / mean(α)).
beta_whittaker <- gamma_diversity / mean(alpha_richness)
beta_whittaker
[1] 1.034483
### Calculates pairwise beta diversity.

## Using Bray–Curtis.
beta_pairwise_bray <- vegdist(my_data, method = "bray")

## Using Jaccard (presence/absence).
beta_pairwise_jaccard <- vegdist(my_data, method = "jaccard", binary = TRUE)

### Print pairwise beta matrices.
beta_pairwise_bray
                       Mojave Desert Death Valley Santa Monica Mountains
Death Valley               0.3442623                                    
Santa Monica Mountains     0.2929293    0.3693694                       
Channel Islands            0.2291667    0.3333333              0.2470588
San Gabriel Mountains      0.2566372    0.3760000              0.4117647
Anza-Borrego               0.2571429    0.3333333              0.3617021
Salton Sea                 0.2871287    0.3628319              0.3555556
Carrizo Plain              0.4074074    0.3166667              0.4020619
San Diego Chaparral        0.2931034    0.3906250              0.3333333
                       Channel Islands San Gabriel Mountains Anza-Borrego
Death Valley                                                             
Santa Monica Mountains                                                   
Channel Islands                                                          
San Gabriel Mountains        0.3333333                                   
Anza-Borrego                 0.3406593             0.2407407             
Salton Sea                   0.3563218             0.3846154    0.3750000
Carrizo Plain                0.3617021             0.4594595    0.3592233
San Diego Chaparral          0.3725490             0.4285714    0.3873874
                       Salton Sea Carrizo Plain
Death Valley                                   
Santa Monica Mountains                         
Channel Islands                                
San Gabriel Mountains                          
Anza-Borrego                                   
Salton Sea                                     
Carrizo Plain           0.4545455              
San Diego Chaparral     0.4205607     0.3684211
beta_pairwise_jaccard
                       Mojave Desert Death Valley Santa Monica Mountains
Death Valley                     0.0                                    
Santa Monica Mountains           0.0          0.0                       
Channel Islands                  0.0          0.0                    0.0
San Gabriel Mountains            0.0          0.0                    0.0
Anza-Borrego                     0.0          0.0                    0.0
Salton Sea                       0.1          0.1                    0.1
Carrizo Plain                    0.1          0.1                    0.1
San Diego Chaparral              0.1          0.1                    0.1
                       Channel Islands San Gabriel Mountains Anza-Borrego
Death Valley                                                             
Santa Monica Mountains                                                   
Channel Islands                                                          
San Gabriel Mountains              0.0                                   
Anza-Borrego                       0.0                   0.0             
Salton Sea                         0.1                   0.1          0.1
Carrizo Plain                      0.1                   0.1          0.1
San Diego Chaparral                0.1                   0.1          0.1
                       Salton Sea Carrizo Plain
Death Valley                                   
Santa Monica Mountains                         
Channel Islands                                
San Gabriel Mountains                          
Anza-Borrego                                   
Salton Sea                                     
Carrizo Plain                 0.2              
San Diego Chaparral           0.0           0.2

Whittaker beta diversity for all nine sites is 1.034483. This calculation makes sense given that three sites—the Salton Sea, Carrizo Plain, and San Diego Chaparral—each had nine amphibian species. The other six sites had all ten species included in the analysis. My earlier calculation of species richness affirms that all nine sites have about the same species composition with respect to amphibian species.

Pairwise beta diversity also supports a similar conclusion. Between any two sites, Bray-Curtis pairwise beta diversity values generally range between 0.2 and 0.5. These values can be interpreted as any two sites having between very similar communities of amphibian species. Between any two sites, Jaccard pairwise beta diversity values range between 0 and 0.2. These values indicate that some communities have exactly identical communities of amphibian species using the given data set. Other sites are quite similar in species composition.

4) Calculate and compare Euclidean, Bray-Curtis, and Jaccard distances for your data (all species and all plots). Create an NMDS plot with all data for both Bray-Curtis and Jaccard distances for your data. What do you observe?

### Calculates Euclidean distance.
dist_euclidean <- dist(my_data, method = "euclidean")

### Calculates Bray–Curtis distance.
dist_bray <- vegdist(my_data, method = "bray")

### Calculates Jaccard distance.
dist_jaccard <- vegdist(my_data, method = "jaccard", binary = TRUE)

### Calculates Bray–Curtis NMDS.
nmds_bray <- metaMDS(my_data, distance = "bray", k = 2, trymax = 200)
Wisconsin double standardization
Run 0 stress 0.1030113 
Run 1 stress 0.1030113 
... Procrustes: rmse 1.649391e-06  max resid 2.815508e-06 
... Similar to previous best
Run 2 stress 0.2221589 
Run 3 stress 0.2221589 
Run 4 stress 0.1727647 
Run 5 stress 0.1727642 
Run 6 stress 0.1700058 
Run 7 stress 0.1839879 
Run 8 stress 0.1030113 
... New best solution
... Procrustes: rmse 7.630856e-07  max resid 1.132425e-06 
... Similar to previous best
Run 9 stress 0.1030113 
... Procrustes: rmse 1.322487e-06  max resid 2.253334e-06 
... Similar to previous best
Run 10 stress 0.1030113 
... Procrustes: rmse 1.262765e-06  max resid 1.803071e-06 
... Similar to previous best
Run 11 stress 0.1283011 
Run 12 stress 0.2546454 
Run 13 stress 0.1727642 
Run 14 stress 0.1727645 
Run 15 stress 0.1030113 
... New best solution
... Procrustes: rmse 9.104218e-07  max resid 1.275102e-06 
... Similar to previous best
Run 16 stress 0.1727647 
Run 17 stress 0.1030113 
... Procrustes: rmse 2.904402e-06  max resid 4.677304e-06 
... Similar to previous best
Run 18 stress 0.2505667 
Run 19 stress 0.1283011 
Run 20 stress 0.1553233 
*** Best solution repeated 2 times
### Calculates Jaccard NMDS.
nmds_jaccard <- metaMDS(my_data, distance = "jaccard", binary = TRUE, k = 2, trymax = 200)
Wisconsin double standardization
Run 0 stress 0 
Run 1 stress 0 
... Procrustes: rmse 0.1723011  max resid 0.3416931 
Run 2 stress 0 
... Procrustes: rmse 0.1873221  max resid 0.3788811 
Run 3 stress 0 
... Procrustes: rmse 0.1304087  max resid 0.3284987 
Run 4 stress 0 
... Procrustes: rmse 0.177781  max resid 0.3054488 
Run 5 stress 0 
... Procrustes: rmse 0.1316237  max resid 0.1894936 
Run 6 stress 0 
... Procrustes: rmse 0.1750605  max resid 0.3303937 
Run 7 stress 0.1112765 
Run 8 stress 0 
... Procrustes: rmse 0.1888713  max resid 0.3493822 
Run 9 stress 0 
... Procrustes: rmse 0.2161148  max resid 0.3572239 
Run 10 stress 0 
... Procrustes: rmse 0.1891079  max resid 0.3718968 
Run 11 stress 0 
... Procrustes: rmse 0.1324887  max resid 0.2204203 
Run 12 stress 0 
... Procrustes: rmse 0.1037938  max resid 0.1522454 
Run 13 stress 0 
... Procrustes: rmse 0.1032318  max resid 0.1993964 
Run 14 stress 0 
... Procrustes: rmse 0.09012288  max resid 0.118577 
Run 15 stress 0 
... Procrustes: rmse 0.1775074  max resid 0.3154987 
Run 16 stress 0 
... Procrustes: rmse 0.1497104  max resid 0.2946851 
Run 17 stress 0 
... Procrustes: rmse 0.1950373  max resid 0.392075 
Run 18 stress 0 
... Procrustes: rmse 0.1948997  max resid 0.3824213 
Run 19 stress 0 
... Procrustes: rmse 0.1909159  max resid 0.3819689 
Run 20 stress 0 
... Procrustes: rmse 0.1146302  max resid 0.1946343 
Run 21 stress 0 
... Procrustes: rmse 0.1176733  max resid 0.1971119 
Run 22 stress 0 
... Procrustes: rmse 0.2219948  max resid 0.3660763 
Run 23 stress 0 
... Procrustes: rmse 0.1552919  max resid 0.3195968 
Run 24 stress 0 
... Procrustes: rmse 0.0967415  max resid 0.1575495 
Run 25 stress 0 
... Procrustes: rmse 0.08950847  max resid 0.1600131 
Run 26 stress 0 
... Procrustes: rmse 0.1510266  max resid 0.2727565 
Run 27 stress 0 
... Procrustes: rmse 0.1570654  max resid 0.2818357 
Run 28 stress 0 
... Procrustes: rmse 0.1226466  max resid 0.2278339 
Run 29 stress 0 
... Procrustes: rmse 0.1984525  max resid 0.3901237 
Run 30 stress 0 
... Procrustes: rmse 0.07813139  max resid 0.1504685 
Run 31 stress 0 
... Procrustes: rmse 0.08108551  max resid 0.1277706 
Run 32 stress 0 
... Procrustes: rmse 0.1607984  max resid 0.2528353 
Run 33 stress 0 
... Procrustes: rmse 0.1212681  max resid 0.1962679 
Run 34 stress 0 
... Procrustes: rmse 0.1088096  max resid 0.1754801 
Run 35 stress 0 
... Procrustes: rmse 0.1368211  max resid 0.2677116 
Run 36 stress 0 
... Procrustes: rmse 0.1517133  max resid 0.2589135 
Run 37 stress 0 
... Procrustes: rmse 0.1468176  max resid 0.2418105 
Run 38 stress 0 
... Procrustes: rmse 0.08650734  max resid 0.1493651 
Run 39 stress 0 
... Procrustes: rmse 0.1958905  max resid 0.3496445 
Run 40 stress 0 
... Procrustes: rmse 0.2190045  max resid 0.3833833 
Run 41 stress 0 
... Procrustes: rmse 0.2341644  max resid 0.4313095 
Run 42 stress 0 
... Procrustes: rmse 0.1542514  max resid 0.288612 
Run 43 stress 0 
... Procrustes: rmse 0.1221988  max resid 0.2185146 
Run 44 stress 0 
... Procrustes: rmse 0.2065334  max resid 0.378049 
Run 45 stress 0 
... Procrustes: rmse 0.1581558  max resid 0.2690707 
Run 46 stress 0 
... Procrustes: rmse 0.2250046  max resid 0.4067181 
Run 47 stress 0 
... Procrustes: rmse 0.1306785  max resid 0.2163424 
Run 48 stress 0 
... Procrustes: rmse 0.1738696  max resid 0.3484356 
Run 49 stress 0 
... Procrustes: rmse 0.1770204  max resid 0.3124592 
Run 50 stress 0 
... Procrustes: rmse 0.1621013  max resid 0.2613035 
Run 51 stress 0 
... Procrustes: rmse 0.1281747  max resid 0.2102094 
Run 52 stress 0 
... Procrustes: rmse 0.1835776  max resid 0.3161724 
Run 53 stress 0 
... Procrustes: rmse 0.1909767  max resid 0.3632925 
Run 54 stress 0 
... Procrustes: rmse 0.1230479  max resid 0.1936035 
Run 55 stress 0 
... Procrustes: rmse 0.1391908  max resid 0.2565353 
Run 56 stress 0 
... Procrustes: rmse 0.1735262  max resid 0.384055 
Run 57 stress 0 
... Procrustes: rmse 0.2128004  max resid 0.380023 
Run 58 stress 0 
... Procrustes: rmse 0.06790271  max resid 0.1087982 
Run 59 stress 0 
... Procrustes: rmse 0.2150889  max resid 0.445877 
Run 60 stress 0 
... Procrustes: rmse 0.1143852  max resid 0.2082967 
Run 61 stress 0 
... Procrustes: rmse 0.1089323  max resid 0.1721933 
Run 62 stress 0 
... Procrustes: rmse 0.2392108  max resid 0.439171 
Run 63 stress 0 
... Procrustes: rmse 0.1511086  max resid 0.250018 
Run 64 stress 0 
... Procrustes: rmse 0.1747961  max resid 0.3115922 
Run 65 stress 0 
... Procrustes: rmse 0.1497829  max resid 0.2259779 
Run 66 stress 0 
... Procrustes: rmse 0.1749561  max resid 0.3479215 
Run 67 stress 0 
... Procrustes: rmse 0.1617656  max resid 0.3216252 
Run 68 stress 0 
... Procrustes: rmse 0.159254  max resid 0.2628277 
Run 69 stress 0 
... Procrustes: rmse 0.1318618  max resid 0.2508546 
Run 70 stress 0 
... Procrustes: rmse 0.1930992  max resid 0.3431224 
Run 71 stress 0 
... Procrustes: rmse 0.1893405  max resid 0.3660617 
Run 72 stress 0 
... Procrustes: rmse 0.1385233  max resid 0.2339338 
Run 73 stress 0 
... Procrustes: rmse 0.2332104  max resid 0.4293657 
Run 74 stress 0 
... Procrustes: rmse 0.158419  max resid 0.2850318 
Run 75 stress 0 
... Procrustes: rmse 0.1266286  max resid 0.1905093 
Run 76 stress 0 
... Procrustes: rmse 0.1393389  max resid 0.2529572 
Run 77 stress 0 
... Procrustes: rmse 0.1424109  max resid 0.2619465 
Run 78 stress 0 
... Procrustes: rmse 0.1885544  max resid 0.364259 
Run 79 stress 0 
... Procrustes: rmse 0.1810656  max resid 0.3125966 
Run 80 stress 0 
... Procrustes: rmse 0.2348132  max resid 0.4548021 
Run 81 stress 0 
... Procrustes: rmse 0.1559649  max resid 0.2740071 
Run 82 stress 0 
... Procrustes: rmse 0.1476816  max resid 0.2884853 
Run 83 stress 0 
... Procrustes: rmse 0.09177603  max resid 0.1835315 
Run 84 stress 4.019699e-06 
... Procrustes: rmse 0.2398567  max resid 0.4405795 
Run 85 stress 0 
... Procrustes: rmse 0.1272315  max resid 0.1616067 
Run 86 stress 0 
... Procrustes: rmse 0.1138798  max resid 0.1525792 
Run 87 stress 0 
... Procrustes: rmse 0.1626928  max resid 0.2641641 
Run 88 stress 0 
... Procrustes: rmse 0.1748628  max resid 0.3136481 
Run 89 stress 0 
... Procrustes: rmse 0.1453346  max resid 0.2941522 
Run 90 stress 0 
... Procrustes: rmse 0.1939504  max resid 0.3685492 
Run 91 stress 0 
... Procrustes: rmse 0.1546269  max resid 0.2989288 
Run 92 stress 0 
... Procrustes: rmse 0.1434984  max resid 0.2462027 
Run 93 stress 0 
... Procrustes: rmse 0.1801161  max resid 0.2795159 
Run 94 stress 0 
... Procrustes: rmse 0.2264783  max resid 0.3791312 
Run 95 stress 0 
... Procrustes: rmse 0.1698833  max resid 0.2778668 
Run 96 stress 0 
... Procrustes: rmse 0.1906635  max resid 0.3489261 
Run 97 stress 0 
... Procrustes: rmse 0.1939419  max resid 0.3295164 
Run 98 stress 0 
... Procrustes: rmse 0.09767407  max resid 0.1584018 
Run 99 stress 0 
... Procrustes: rmse 0.1800694  max resid 0.3287967 
Run 100 stress 0 
... Procrustes: rmse 0.1408675  max resid 0.2194813 
Run 101 stress 0 
... Procrustes: rmse 0.167404  max resid 0.2892761 
Run 102 stress 0 
... Procrustes: rmse 0.1679413  max resid 0.3528482 
Run 103 stress 0 
... Procrustes: rmse 0.1851028  max resid 0.3406752 
Run 104 stress 0 
... Procrustes: rmse 0.1536133  max resid 0.2691136 
Run 105 stress 0 
... Procrustes: rmse 0.1952917  max resid 0.3632978 
Run 106 stress 0 
... Procrustes: rmse 0.2158005  max resid 0.3906497 
Run 107 stress 0 
... Procrustes: rmse 0.1395992  max resid 0.2098852 
Run 108 stress 0 
... Procrustes: rmse 0.1544146  max resid 0.2958255 
Run 109 stress 0 
... Procrustes: rmse 0.205479  max resid 0.3815104 
Run 110 stress 0 
... Procrustes: rmse 0.1117115  max resid 0.1731132 
Run 111 stress 0 
... Procrustes: rmse 0.08129681  max resid 0.1450801 
Run 112 stress 0 
... Procrustes: rmse 0.08016943  max resid 0.1489736 
Run 113 stress 0 
... Procrustes: rmse 0.1884008  max resid 0.3272677 
Run 114 stress 0 
... Procrustes: rmse 0.1660439  max resid 0.3136988 
Run 115 stress 0 
... Procrustes: rmse 0.2350713  max resid 0.4299751 
Run 116 stress 0 
... Procrustes: rmse 0.108181  max resid 0.1684633 
Run 117 stress 0 
... Procrustes: rmse 0.1897832  max resid 0.360498 
Run 118 stress 0 
... Procrustes: rmse 0.1950873  max resid 0.353171 
Run 119 stress 0 
... Procrustes: rmse 0.1384504  max resid 0.1791324 
Run 120 stress 0 
... Procrustes: rmse 0.2399196  max resid 0.4063553 
Run 121 stress 0 
... Procrustes: rmse 0.1660816  max resid 0.2424532 
Run 122 stress 0 
... Procrustes: rmse 0.2379143  max resid 0.4364818 
Run 123 stress 0 
... Procrustes: rmse 0.1649293  max resid 0.3245005 
Run 124 stress 0 
... Procrustes: rmse 0.1790448  max resid 0.493402 
Run 125 stress 0 
... Procrustes: rmse 0.06314128  max resid 0.1031739 
Run 126 stress 0 
... Procrustes: rmse 0.07979371  max resid 0.1764463 
Run 127 stress 0 
... Procrustes: rmse 0.2119766  max resid 0.3840289 
Run 128 stress 0 
... Procrustes: rmse 0.1652723  max resid 0.3095308 
Run 129 stress 0 
... Procrustes: rmse 0.1937095  max resid 0.3534185 
Run 130 stress 0 
... Procrustes: rmse 0.2458519  max resid 0.3887849 
Run 131 stress 0 
... Procrustes: rmse 0.2359223  max resid 0.4323173 
Run 132 stress 0 
... Procrustes: rmse 0.1241097  max resid 0.2178969 
Run 133 stress 0 
... Procrustes: rmse 0.1661192  max resid 0.3243484 
Run 134 stress 0 
... Procrustes: rmse 0.2226366  max resid 0.409644 
Run 135 stress 0 
... Procrustes: rmse 0.2039977  max resid 0.4253956 
Run 136 stress 0 
... Procrustes: rmse 0.1635552  max resid 0.303503 
Run 137 stress 0 
... Procrustes: rmse 0.1067956  max resid 0.1757853 
Run 138 stress 0 
... Procrustes: rmse 0.1362082  max resid 0.2540947 
Run 139 stress 0 
... Procrustes: rmse 0.1941206  max resid 0.3538726 
Run 140 stress 0 
... Procrustes: rmse 0.2074302  max resid 0.4255871 
Run 141 stress 0 
... Procrustes: rmse 0.1848538  max resid 0.3614431 
Run 142 stress 0 
... Procrustes: rmse 0.1617569  max resid 0.2978839 
Run 143 stress 0 
... Procrustes: rmse 0.1044092  max resid 0.1410422 
Run 144 stress 0 
... Procrustes: rmse 0.1590149  max resid 0.2573654 
Run 145 stress 0 
... Procrustes: rmse 0.2301666  max resid 0.426861 
Run 146 stress 0 
... Procrustes: rmse 0.2092436  max resid 0.3995246 
Run 147 stress 0 
... Procrustes: rmse 0.213954  max resid 0.3974812 
Run 148 stress 0 
... Procrustes: rmse 0.1774807  max resid 0.348041 
Run 149 stress 0 
... Procrustes: rmse 0.2027567  max resid 0.3739031 
Run 150 stress 0 
... Procrustes: rmse 0.2080689  max resid 0.3980695 
Run 151 stress 0 
... Procrustes: rmse 0.1650613  max resid 0.2993782 
Run 152 stress 0 
... Procrustes: rmse 0.1186097  max resid 0.1996384 
Run 153 stress 0 
... Procrustes: rmse 0.1031755  max resid 0.1771772 
Run 154 stress 0 
... Procrustes: rmse 0.2219792  max resid 0.4319907 
Run 155 stress 0 
... Procrustes: rmse 0.1701753  max resid 0.3127951 
Run 156 stress 0 
... Procrustes: rmse 0.1710607  max resid 0.2484775 
Run 157 stress 0 
... Procrustes: rmse 0.1245709  max resid 0.1850934 
Run 158 stress 0 
... Procrustes: rmse 0.199444  max resid 0.3377757 
Run 159 stress 0 
... Procrustes: rmse 0.1126229  max resid 0.2120423 
Run 160 stress 0 
... Procrustes: rmse 0.1763013  max resid 0.3258008 
Run 161 stress 0 
... Procrustes: rmse 0.2237762  max resid 0.4644446 
Run 162 stress 0 
... Procrustes: rmse 0.1641632  max resid 0.2993733 
Run 163 stress 0 
... Procrustes: rmse 0.2092727  max resid 0.3787311 
Run 164 stress 0 
... Procrustes: rmse 0.1048631  max resid 0.1657795 
Run 165 stress 0 
... Procrustes: rmse 0.1083346  max resid 0.1927164 
Run 166 stress 0 
... Procrustes: rmse 0.1698484  max resid 0.304748 
Run 167 stress 0 
... Procrustes: rmse 0.1935799  max resid 0.3289335 
Run 168 stress 0 
... Procrustes: rmse 0.2235462  max resid 0.4625219 
Run 169 stress 0 
... Procrustes: rmse 0.1479533  max resid 0.271818 
Run 170 stress 0 
... Procrustes: rmse 0.1159853  max resid 0.1654196 
Run 171 stress 0 
... Procrustes: rmse 0.1661804  max resid 0.2927745 
Run 172 stress 0 
... Procrustes: rmse 0.1519085  max resid 0.215135 
Run 173 stress 0 
... Procrustes: rmse 0.09469221  max resid 0.1342093 
Run 174 stress 0 
... Procrustes: rmse 0.2031313  max resid 0.4484358 
Run 175 stress 0 
... Procrustes: rmse 0.1107904  max resid 0.1922726 
Run 176 stress 0 
... Procrustes: rmse 0.1720001  max resid 0.3152515 
Run 177 stress 0 
... Procrustes: rmse 0.1106624  max resid 0.1876663 
Run 178 stress 0 
... Procrustes: rmse 0.2015139  max resid 0.4344226 
Run 179 stress 0 
... Procrustes: rmse 0.1665344  max resid 0.2873467 
Run 180 stress 0 
... Procrustes: rmse 0.1304638  max resid 0.1776254 
Run 181 stress 0 
... Procrustes: rmse 0.1241058  max resid 0.2315967 
Run 182 stress 0 
... Procrustes: rmse 0.1471555  max resid 0.2523583 
Run 183 stress 0 
... Procrustes: rmse 0.1154162  max resid 0.1791856 
Run 184 stress 0 
... Procrustes: rmse 0.200802  max resid 0.3652897 
Run 185 stress 0 
... Procrustes: rmse 0.1502694  max resid 0.2658203 
Run 186 stress 0 
... Procrustes: rmse 0.1887121  max resid 0.3359342 
Run 187 stress 0 
... Procrustes: rmse 0.2296162  max resid 0.4227686 
Run 188 stress 0 
... Procrustes: rmse 0.2107212  max resid 0.3722037 
Run 189 stress 0 
... Procrustes: rmse 0.09518971  max resid 0.1758041 
Run 190 stress 0 
... Procrustes: rmse 0.1719319  max resid 0.3022874 
Run 191 stress 0 
... Procrustes: rmse 0.2311035  max resid 0.4090121 
Run 192 stress 0 
... Procrustes: rmse 0.1436968  max resid 0.3084712 
Run 193 stress 0 
... Procrustes: rmse 0.1772433  max resid 0.3253537 
Run 194 stress 0 
... Procrustes: rmse 0.1439853  max resid 0.214923 
Run 195 stress 0 
... Procrustes: rmse 0.1099131  max resid 0.1737243 
Run 196 stress 0 
... Procrustes: rmse 0.1579243  max resid 0.2884374 
Run 197 stress 0 
... Procrustes: rmse 0.1960812  max resid 0.3780235 
Run 198 stress 0 
... Procrustes: rmse 0.1284009  max resid 0.1899098 
Run 199 stress 0 
... Procrustes: rmse 0.1523886  max resid 0.2793082 
Run 200 stress 0 
... Procrustes: rmse 0.1178923  max resid 0.257088 
*** Best solution was not repeated -- monoMDS stopping criteria:
   199: stress < smin
     1: stress ratio > sratmax
Warning in metaMDS(my_data, distance = "jaccard", binary = TRUE, k = 2, :
stress is (nearly) zero: you may have insufficient data
dist_euclidean
                       Mojave Desert Death Valley Santa Monica Mountains
Death Valley               16.000000                                    
Santa Monica Mountains     10.630146    15.524175                       
Channel Islands             8.944272    14.142136               7.810250
San Gabriel Mountains      11.789826    16.522712              16.852300
Anza-Borrego               10.148892    17.349352              14.282857
Salton Sea                 12.206556    17.349352              11.747340
Carrizo Plain              16.062378    16.552945              15.198684
San Diego Chaparral        14.422205    19.131126              14.387495
                       Channel Islands San Gabriel Mountains Anza-Borrego
Death Valley                                                             
Santa Monica Mountains                                                   
Channel Islands                                                          
San Gabriel Mountains        12.767145                                   
Anza-Borrego                 12.288206             10.583005             
Salton Sea                   10.816654             14.282857    13.564660
Carrizo Plain                14.142136             18.466185    17.058722
San Diego Chaparral          16.552945             19.621417    16.217275
                       Salton Sea Carrizo Plain
Death Valley                                   
Santa Monica Mountains                         
Channel Islands                                
San Gabriel Mountains                          
Anza-Borrego                                   
Salton Sea                                     
Carrizo Plain           18.303005              
San Diego Chaparral     17.000000     15.684387
dist_bray
                       Mojave Desert Death Valley Santa Monica Mountains
Death Valley               0.3442623                                    
Santa Monica Mountains     0.2929293    0.3693694                       
Channel Islands            0.2291667    0.3333333              0.2470588
San Gabriel Mountains      0.2566372    0.3760000              0.4117647
Anza-Borrego               0.2571429    0.3333333              0.3617021
Salton Sea                 0.2871287    0.3628319              0.3555556
Carrizo Plain              0.4074074    0.3166667              0.4020619
San Diego Chaparral        0.2931034    0.3906250              0.3333333
                       Channel Islands San Gabriel Mountains Anza-Borrego
Death Valley                                                             
Santa Monica Mountains                                                   
Channel Islands                                                          
San Gabriel Mountains        0.3333333                                   
Anza-Borrego                 0.3406593             0.2407407             
Salton Sea                   0.3563218             0.3846154    0.3750000
Carrizo Plain                0.3617021             0.4594595    0.3592233
San Diego Chaparral          0.3725490             0.4285714    0.3873874
                       Salton Sea Carrizo Plain
Death Valley                                   
Santa Monica Mountains                         
Channel Islands                                
San Gabriel Mountains                          
Anza-Borrego                                   
Salton Sea                                     
Carrizo Plain           0.4545455              
San Diego Chaparral     0.4205607     0.3684211
dist_jaccard
                       Mojave Desert Death Valley Santa Monica Mountains
Death Valley                     0.0                                    
Santa Monica Mountains           0.0          0.0                       
Channel Islands                  0.0          0.0                    0.0
San Gabriel Mountains            0.0          0.0                    0.0
Anza-Borrego                     0.0          0.0                    0.0
Salton Sea                       0.1          0.1                    0.1
Carrizo Plain                    0.1          0.1                    0.1
San Diego Chaparral              0.1          0.1                    0.1
                       Channel Islands San Gabriel Mountains Anza-Borrego
Death Valley                                                             
Santa Monica Mountains                                                   
Channel Islands                                                          
San Gabriel Mountains              0.0                                   
Anza-Borrego                       0.0                   0.0             
Salton Sea                         0.1                   0.1          0.1
Carrizo Plain                      0.1                   0.1          0.1
San Diego Chaparral                0.1                   0.1          0.1
                       Salton Sea Carrizo Plain
Death Valley                                   
Santa Monica Mountains                         
Channel Islands                                
San Gabriel Mountains                          
Anza-Borrego                                   
Salton Sea                                     
Carrizo Plain                 0.2              
San Diego Chaparral           0.0           0.2

Euclidean distance is difficult to interpret without an absolute data scale, but some conclusions can be made using Bray-Curtis and Jaccard distance, which are both bounded. My values for Bray-Curtis distance lie between 0.2 and 0.5, which leads me to the conclusion that there exists moderate to no differences between any two sites. This same conclusion can be reached using Jaccard distance, whose values lie between 0 and 0.2 in this data set. Bray-Curtis and Jaccard NMDS are plotted.

### Extracts NMDS scores for Bray-Curtis and Jaccard distances.
scores_bray <- as.data.frame(scores(nmds_bray, display = "sites"))
scores_bray$Plot <- rownames(scores_bray)

scores_jaccard <- as.data.frame(scores(nmds_jaccard, display = "sites"))
scores_jaccard$Plot <- rownames(scores_jaccard)

### Plots Bray-Curtis NMDS.
ggplot(scores_bray, aes(x = NMDS1, y = NMDS2)) +
  geom_point(color = "steelblue", size = 4) +
  geom_text(aes(label = Plot), vjust = -0.5, hjust = 0.5, size = 3) +
  theme_minimal(base_size = 14) +
  labs(
    title = paste0("NMDS – Bray–Curtis (Stress = ", round(nmds_bray$stress, 3), ")"),
    x = "NMDS1",
    y = "NMDS2"
  ) +
  theme(
    panel.grid = element_blank(),
    plot.title = element_text(hjust = 0.5, face = "bold")
  )

### Plots Jaccard NMDS.
ggplot(scores_jaccard, aes(x = NMDS1, y = NMDS2)) +
  geom_point(color = "darkorange", size = 4) +
  geom_text(aes(label = Plot), vjust = -0.5, hjust = 0.5, size = 3) +
  theme_minimal(base_size = 14) +
  labs(
    title = paste0("NMDS – Jaccard (Stress = ", round(nmds_jaccard$stress, 3), ")"),
    x = "NMDS1",
    y = "NMDS2"
  ) +
  theme(
    panel.grid = element_blank(),
    plot.title = element_text(hjust = 0.5, face = "bold")
  )

My Bray-Curtis NMDS stress value is 0.103, which indicates that the data set is interpretable and can be used to find general patterns in the original distances of amphibian species in southern California. My Jaccard NMDS stress value is 0, which means that 2D distances approximate the original Jaccard distances between species very well.

5) Calculate Gini-Simpson Index, Simpson’s Evenness, and Shannon Index values for your data. What do you observe?

###Calculates Gini-Simpson Index.
diversity(my_data, index = "simpson")
         Mojave Desert           Death Valley Santa Monica Mountains 
             0.8819835              0.8736912              0.8760331 
       Channel Islands  San Gabriel Mountains           Anza-Borrego 
             0.8899465              0.8650416              0.8568000 
            Salton Sea          Carrizo Plain    San Diego Chaparral 
             0.8544423              0.8387326              0.8594464 

Calculations of Gini-Simpson Index range from 0.8 to 0.9 for this data set, indicating high diversity of amphibian species in southern California.

###Calculates Simpson's Evenness.
Gs_1 <- diversity(my_data, index = "simpson")

D_1 <- 1 - Gs_1

1 / (D_1 * ncol(my_data))
         Mojave Desert           Death Valley Santa Monica Mountains 
             0.8473389              0.7917108              0.8066667 
       Channel Islands  San Gabriel Mountains           Anza-Borrego 
             0.9086486              0.7409692              0.6983240 
            Salton Sea          Carrizo Plain    San Diego Chaparral 
             0.6870130              0.6200883              0.7114723 

Calculations of Simpson’s Evenness generally range from 0.7 to 0.8 for this data set, indicating high diversity of amphibian species in southern California. Interestingly, many sites that contained nine of the ten amphibian species mentioned in the analysis generally have lower Simpson’s Evenness values.

###Calculates Shannon Index.
diversity(my_data, index = "shannon")
         Mojave Desert           Death Valley Santa Monica Mountains 
              2.207545               2.164124               2.174500 
       Channel Islands  San Gabriel Mountains           Anza-Borrego 
              2.241165               2.136521               2.104603 
            Salton Sea          Carrizo Plain    San Diego Chaparral 
              2.019560               1.969929               2.053371 

All nine sites have Shannon Index values around 2, indicating moderate diversity, multiple species, and fairly balanced abundances. This statistic is supported by earlier conclusions.

6) What overall hypotheses or conclusions can you draw from your analysis of this dataset? Based on the flowchart from lab, which metric(s) do you think are most applicable for your dataset?

Considering amphibian species found in these nine sites in southern California, I can conclude that these nine sites have moderate to high diversity with respect to members of the amphibian taxon. This data is supported by my calculations of alpha diversity, gamma diversity, and beta diversity. I think that these statistics are most applicable for my data set because these statistics rely strictly on species abundances for their calculations. I choose to avoid considering distances and NMDS in reaching my conclusions because interpretations of these values may require some knowledge of the distances between the sites, which is not immediately available to me through the given data set.