# Analysis of biodiversity patterns

#### Felix May

#### 2024-12-05

This introduction shows the list of biodiversity patterns that can be derived using `mobsim`. In this vignette the patterns are evaluated on a simulated data set, but of course the same patterns can be also derived from real data.

# 1 Simulate and explore data

First, we generate community data by simulating 1,000 individuals from 30 species with a cluster size of `sigma = 0.01` and one cluster per species (`mother_points = 1`). For more information on the simulation of communities see the vignette Simulating communities with `mobsim`.

    library(mobsim)
    sim_dat1 <- sim_thomas_community(s_pool = 30,  n_sim = 1000, sad_type = "lnorm",
                                     sad_coef = list("meanlog" = 2, "sdlog" = 1),
                                     sigma = 0.1, mother_points = 1)

Then we explore the generated community object. In the plot each dot represents one individual and the colour indicates the species identity.

    plot(sim_dat1)

    summary(sim_dat1)

    ## No. of individuals:  1000
    ## No. of species:  30
    ## x-extent:  0 1
    ## y-extent:  0 1
    ##
    ##        x                y               species
    ##  Min.   :0.0016   Min.   :0.008   species_01:185
    ##  1st Qu.:0.2311   1st Qu.:0.270   species_02:148
    ##  Median :0.6301   Median :0.393   species_03:101
    ##  Mean   :0.5308   Mean   :0.449   species_04: 57
    ##  3rd Qu.:0.7754   3rd Qu.:0.633   species_05: 55
    ##  Max.   :0.9990   Max.   :0.990   species_06: 50
    ##                                   (Other)   :404

    str(sim_dat1)

    ## List of 3
    ##  $ census   :'data.frame':   1000 obs. of  3 variables:
    ##   ..$ x      : num [1:1000] 0.603 0.802 0.533 0.619 0.851 ...
    ##   ..$ y      : num [1:1000] 0.482 0.369 0.437 0.317 0.353 ...
    ##   ..$ species: Factor w/ 30 levels "species_01","species_02",..: 1 1 1 1 1 1 1 1 1 1 ...
    ##  $ x_min_max: num [1:2] 0 1
    ##  $ y_min_max: num [1:2] 0 1
    ##  - attr(*, "class")= chr "community"

# 2 Non-spatial patterns

## 2.1 Species abundance distribution (SAD)

A fundamental non-spatial pattern of a community is the abundance distribution, i.e. the distribution of commonness and rarity in a community. The abundance distribution can be extracted from a community object using the function `communtiy_to_sad()`

    abund1 <- community_to_sad(sim_dat1)

A standard plot in community ecology is the rank-abundance plot, where the abundance of each species is plotted vs. its rank from highest to lowest abundance. As a standard log-scaling is used for the abundance axis in this plot.

    plot(abund1, method = "rank")

Of course the abundance distribution can be also visualized as a histogram. By tradition for the binning of species abundances logarithms with base 2 are used, following the suggestion of Preston (1948). This means the first abundance class includes species with just one individual, the second class with two individuals, the third class with 3-4, the fourth with 5-8 etc. These abundance classes are called “octaves”.

    plot(abund1, method = "octave")

## 2.2 Rarefaction curve

Another important biodiversity pattern is the rarefaction curve, which estimates how the number of observed species increases with sample size of individuals. The rarefaction curve assumes that individuals are sampled randomly and independently (Gotelli & Colwell 2001). The rarefaction curve only depends on the abundance distribution of species.

    rare1 <- spec_sample_curve(sim_dat1, method = "rarefaction")
    str(rare1)

    ## Classes 'spec_sample_curve' and 'data.frame':    1000 obs. of  2 variables:
    ##  $ n            : int  1 2 3 4 5 6 7 8 9 10 ...
    ##  $ spec_rarefied: num  1 1.92 2.76 3.54 4.27 ...

    plot(rare1)

# 3 Spatial patterns

The main strengths of `mobsim` are the simulation and analysis of spatial biodiversity patterns. In the following all functions for spatial pattern evaluation included in `mobsim` are introduced.

## 3.1 Species-accumulation curve

Closely related to the rarefaction curve is the spatial species accumulation curve. In contrast to the rarefaction curve for the derivation of the species accumulation curve individuals are not sampled randomly, but starting from a focal individual always the closest neighbour individual is sampled and the number of encountered species is counted. The resulting curve is derived as the average of the curves for each focal individual. The species accumulation curve is influenced by the abundance distribution, but also by the spatial distribution of individuals and species. Therefore the species accumulation curves requires individual’s positions in addition to species abundances.

Due to the close relationship of the accumulation and rarefaction curves they are calculated and plotted with the same function.

It is comprehensive to plot the rarefaction and the species accumulation curve together. The difference between the two curves indicates aggregation or overdispersion of conspecific individuals.

    spec_curves1 <- spec_sample_curve(sim_dat1, method = c("accumulation", "rarefaction"))
    plot(spec_curves1)

## 3.2 Diversity-area relationships

The most well-known spatial biodiversity pattern is the species-area relationship (SAR). In `mobsim` the function `divar` (diversity-area relationships) calculates the species richness in randomly located subplots (quadrats or rectangles) of different sizes. However, the function `divar` calculates additional indices, including the Shannon and Simpson diversity indices for each subplot, as well as the number of endemic species, which are the species that only occur within, but not outside the subplot. See `?div_rect` for detailed information on the diversity indices.

For the Shannon and Simpson diversity indices also the corresponding Effective Number of Species (ENS) is calculated (Jost 2006). This measure corresponds to the species number in a community of equally abundant species, which results in the same Shannon and Simpson indices as the observed community (with unequal abundances).

The endemics-area relationship (EAR) has been suggested as important tool to investigate the consequences of habitat loss for biodiversity (He & Hubbell 2011, Keil et al. 2015). For the evaluation of the diversity-area relationships a vector with subplot sizes measured as proportion of the total community size has to be defined.

    subplot_size <- c(0.01, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5,
                       0.6, 0.7, 0.8, 0.9, 0.95, 0.99, 1)
    divar1 <- divar(sim_dat1, prop_area = subplot_size)
    head(divar1)

    ##   prop_area m_species sd_species m_endemics sd_endemics m_shannon sd_shannon
    ## 1      0.01  3.574468   1.744357  0.0106383   0.1031421 0.9833722  0.5241875
    ## 2      0.05  7.480000   2.739461  0.0700000   0.2564324 1.5079151  0.4719644
    ## 3      0.10 10.920000   2.654061  0.0900000   0.2876235 1.8089774  0.3899409
    ## 4      0.20 16.010000   2.022575  0.4800000   0.6432242 2.1177115  0.2863033
    ## 5      0.30 19.770000   1.927237  1.7100000   0.9670845 2.3219676  0.2784640
    ## 6      0.40 22.760000   2.094341  3.5800000   1.0168281 2.4398376  0.2330140
    ##   m_ens_shannon sd_ens_shannon m_simpson sd_simpson m_ens_simpson
    ## 1      3.034723       1.508466 0.5673025 0.21252741      2.852739
    ## 2      4.967691       2.013140 0.7073997 0.14577708      4.099734
    ## 3      6.532086       2.271665 0.7683012 0.11165380      5.125710
    ## 4      8.637797       2.295673 0.8207728 0.06514580      6.285871
    ## 5     10.587277       2.878109 0.8475027 0.05485026      7.455286
    ## 6     11.790195       2.842868 0.8608045 0.04138812      7.969307
    ##   sd_ens_simpson
    ## 1       1.331772
    ## 2       1.705094
    ## 3       2.033211
    ## 4       2.052570
    ## 5       2.605386
    ## 6       2.780649

    plot(divar1)

## 3.3 Distance decay of community similarity

The last spatial pattern provided by `mobsim` is the distance decay of community similarity, which quantifies how quickly the similarity in species composition between two subplots decreases with the distance between two subplots. The function `dist_decay` distributes non-overlapping subplots with user-defined size and number in the community and calculates all pairwise similarities.

The function `dist_decay` makes use of the function `vegdist` from the package vegan. Therefore you can consult `?vegdist` for a list of available similarity indices.

Here is a demonstration how the distance decay can be estimated and visualized

    dd1 <- dist_decay(sim_dat1, prop_area = 0.01, n_samples = 20, method = "bray")
    head(dd1)

    ##      distance similarity
    ## 146 0.1442020  0.3333333
    ## 111 0.1493456  0.1818182
    ## 133 0.1498697  0.4000000
    ## 75  0.1508368  0.0000000
    ## 8   0.1516697  0.3225806
    ## 63  0.1697544  0.6666667

    plot(dd1)

# 4 References

1. F. W. Preston 1948. The Commonness, and Rarity, of Species. Ecology 29:254-283.

2. Gotelli & Colwell 2001. Quantifying biodiversity: procedures and pitfalls in the measurement and comparison of species richness. Ecology Letters 4: 379–391.

3. He & Hubbell 2001. Species-area relationships always overestimate extinction rates from habitat loss. Nature 473:368–371

4. Jost 2006. Entropy and diversity. Oikos, 113:363–375.

5. Keil et al. 2015. On the decline of biodiversity due to area loss. Nature communications 6.

6. Morlon et al. 2008. A general framework for the distance–decay of similarity in ecological communities. Ecology Letters 9:904–917.