Learn R Programming

⚠️There's a newer version (3.0.0) of this package.Take me there.

mobr

Measurement of Biodiversity in R

This repository hosts an R package that is actively being developed for estimating biodiversity and the components of its change. The key innovations of this R package over other R packages that also carry out rarefaction (e.g., vegan, iNext) is that mobr is focused on 1) making empirical comparisons between treatments or gradients, and 2) our framework emphasizes how changes in biodiversity are linked to changes in community structure: the SAD, total abundance, and spatial aggregation.

The concepts and methods behind this R package are described in three publications.

McGlinn, D.J. X. Xiao, F. May, N.J Gotelli, T. Engel, S.A Blowes, T.M. Knight, O. Purschke, J.M Chase, and B.J. McGill. 2019. MoB (Measurement of Biodiversity): a method to separate the scale-dependent effects of species abundance distribution, density, and aggregation on diversity change. Methods in Ecology and Evolution. 10:258–269. https://doi.org/10.1111/2041-210X.13102

McGlinn, D.J. T. Engel, S.A. Blowes, N.J. Gotelli, T.M. Knight, B.J. McGill, N. Sanders, and J.M. Chase. accepted. A multiscale framework for disentangling the roles of evenness, density, and aggregation on diversity gradients. Ecology. https://doi.org/10.1101/851717

Chase, J.M., B. McGill, D.J. McGlinn, F. May, S.A. Blowes, X. Xiao, T. Knight. 2018. Embracing scale-dependence to achieve a deeper understanding of biodiversity and its change across communities. Ecology Letters. 21: 1737–1751. https://doi.org/10.1111/ele.13151

Installation

The easiest option is to install the package directly from GitHub using the package devtools. If you do not already have devtools installed then need to install it.

install.packages('devtools')
library(devtools)

Now that devtools is installed you can install `mobr using the following R code:

install_github('MoBiodiv/mobr')

Note: the installation may take some time due to numerous dependencies. We are working on reducing the number of dependencies.

Examples

The package vignette provides a useful walk-through the package tools, but below is some example code that uses the two key analyses and related graphics.

library(mobr)
data(inv_comm)
data(inv_plot_attr)
inv_mob_in = make_mob_in(inv_comm, inv_plot_attr, coord_names = c('x', 'y'))
inv_stats = get_mob_stats(inv_mob_in, 'group')
plot(inv_stats)
inv_deltaS = get_delta_stats(inv_mob_in, 'group', ref_level='uninvaded',
                             type='discrete', log_scale=TRUE, n_perm = 5)
plot(inv_deltaS, 'b1')

Meta

  • Please report any issues or bugs.
  • License: MIT
  • Get citation information for mobr in R doing citation(package = 'mobr')
  • Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

Thanks

  • Gregor Seyer for providing a constructive review of our CRAN submission

Copy Link

Version

Install

install.packages('mobr')

Monthly Downloads

178

Version

2.0.0

License

MIT + file LICENSE

Maintainer

Daniel McGlinn

Last Published

September 21st, 2020

Functions in mobr (2.0.0)

avg_nn_dist

Compute average nearest neighbor distance
calc_chao1

Estimation of species richness
fire_comm

Fire data set
calc_biodiv

Calculate biodiversity statistics from sites by species table.
centroid_accumulate

Internal function used by kNCN_average to compute the k-NCN algorithm starting with a specified focal sample
get_delta_curves

Auxiliary function for computing S and the effect on S of the three components of community structure: SAD, N, and aggregation
get_null_comm

Generate a null community matrix
get_ind_dens

Auxiliary function for get_delta_stats() Returns the "assumed" density of individuals in a plot given whether min, max or mean is used
get_group_delta

Get gamma-scale differences
inv_comm

Invasive plants dataset
plot_N

Plot the relationship between the number of plots and the number of individuals
get_delta_stats

Conduct the MoB tests on drivers of biodiversity across scales.
get_mob_stats

Calculate sample based and group based biodiversity statistics.
get_overall_p

Auxiliary function for effect_ functions Compute an overall p-value for one factor in the discrete case p-value is based on mean squared difference from zero summed across the scales Method developed by Loosmore and Ford 2006 but algebraic simplifications used as developed by Baddeley et al. 2014 Ecological Archives M084-017-A1
get_rand_sad

Randomly sample of a relative abundance distribution (RAD) to produce an expected species abundance distribution (SAD)
get_inds

Auxiliary function for get_delta_stats() Returns a vector of abundances where individual-based rarefaction will be performed
groups_panel2

Panel function for gamma-scale results with confidence intervals
plot_abu

Plot distributions of species abundance
ind_rare_perm

Compute permutation derived individual-based rarefaction curves
plot.mob_stats

Plot alpha- and gamma-scale biodiversity statistics for a MoB analysis
mod_sum

Extract coefficients and metrics of fit from model
plotStacked

Stacked plot by Marc Taylor (@marchtaylor on gitHub)
plot.mob_out

Plot the multiscale MoB analysis output generated by get_delta_stats.
tank_comm

Cattle tank data set
subset.mob_in

Subset the rows of the mob data input object
make_mob_in

Create the 'mob_in' object.
mobr

Measurement of Biodiversity in R
rarefaction

Rarefied Species Richness
samples_panel1

Panel function for alpha-scale results
sphere_dist

Internal function for distance matrix assuming inputs are longitude and latitudes on a spherical Earth.
groups_panel1

Panel function for gamma-scale results
kNCN_average

Construct spatially constrained sample-based rarefaction (sSBR) curve using the k-Nearest-Centroid-neighbor (k-NCN) algorithm
plot_rarefaction

Plot rarefaction curves for each treatment group
print.mob_in

Print a shortened version of the mob_in object
calc_PIE

Calculate probability of interspecific encounter (PIE)
get_F_values

Get F statistics from diversity indices and grouping vector
compare_samp_rarefaction

Compare all sample-based curves (random, spatially constrained-k-NN, spatially constrained-k-NCN)