Skip to content
/ mmir Public

This R package provides tools to aid in the development of Multi-Metric Indices (MMI) of biotic integrity.

License

Notifications You must be signed in to change notification settings

zsmith27/mmir

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mmir

CRAN status Lifecycle: maturing Travis build status Codecov test coverage

It is common practice for regulatory agencies to use biological communities, such as macroinvertebrate, fish, or diatoms, to evaluate water quality condition. Multi-Metric Indices (MMI) or Indices of Biotic Integrity are the standard models for biological assessment, yet there is no package in R specifically dedicated to calculating common or exploratory biological community metrics. The mmir (Multi-Metrics Indices in R) package is intended to simplify and standardize the production of biological community metrics within R. The package provides a straightforward syntax for calculating richness, diversity (e.g., Shannon-Wiener and Simpsons), relative abundance, dominance, functional feeding group, habit, and tolerance value metrics. Building on this base functionality for calculating these individual metrics, there are built in functions for iterating through each metric type to provide a large suite of exploratory metrics; for example, with a single call relative abundance metrics for all orders, families, genera, and species in a dataset can be generated. These exploratory metrics must be reviewed for ecological context, but the limitation of calculating new metrics or evaluating new aspects of the community has been substantially reduced.

Installation

You can install the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("zsmith27/mmir")

Metrics

Below is a list of functions provided by mmir for calculating biological metrics: 1. taxa_rich()calculates taxonomic richness. 2. taxa_pct_rich() calculates relative taxonomic richness. 3. taxa_div() calculates taxonomic diversity indices. 4. taxa_abund() calculates taxonomic abundance. 5. taxa_pct() calculates relative taxonomic abundance. 6. taxa_dom() calculates relative taxonomic dominance. 7. taxa_tol() calculates taxonomic tolerance indices.

Usage

This is a basic example which shows you how to call each of biological metric functions.

library(mmir)

data("nrsa_nap_0809")

taxa_rich(.dataframe = nrsa_nap_0809,
          .key_col = uid,
          .counts_col = total,
          .group_col = target_taxon)
#>   [1]  47  54  48  36  37  36  53  54  79  17  98  29  41  45  65  65  42  33
#>  [19]  67  64  73  47  63  77  86  45  35  64  65  49  33  43  52  61  51  55
#>  [37]  69  67  79  65  77  74  49  53  36  34  58  70  58  74  55  52  41  55
#>  [55]  64  26  37  57  72  26  37  59  52  29  67  57  58  35  77   4  66  69
#>  [73]  40  45  58  75  64  40  74  66  72  15  66  66  54  52  50  68  58  69
#>  [91]  29  45  53  58  57  68  45  26  69  60  69  43  28  42  38  69  89  82
#> [109]  62  67  41  54  42  44  56  68  61  37  47  41  85  67  70  97  87  49
#> [127]  58  40  49  53  40  36  74 106  68  50  70  74  69  57  62  45  60  61
#> [145]  92  48  67  36  92  15  10  45  27  47  58  68  57  55  27  72  23  79
#> [163]  47  64  65  47  19  64  97  30  41  86  53  33  32  29  38  51  53  93
#> [181]  35  89  67  60  71  50  70  92  57  47  34  38  47  77  46  86  75  64
#> [199]  61  44  57  68  47  72  58  48  37  75   9  63  73  95  47 101  79  56
#> [217]  33  46  44  46  32  50  24  39  51

taxa_pct_rich(.dataframe = nrsa_nap_0809,
              .key_col = uid,
              .counts_col = total,
              .group_col = target_taxon,
              .filter = order %in% c("ephemeroptera",
                                     "plecoptera",
                                     "trichoptera"))
#>   [1] 44.680851 46.296296 45.833333 58.333333 43.243243  8.333333 13.207547
#>   [8] 14.814815 21.518987  5.882353 31.632653 27.586207 14.634146  6.666667
#>  [15] 16.923077 24.615385 14.285714  6.060606 40.298507 17.187500 28.767123
#>  [22]  8.510638 20.634921 25.974026 22.093023  4.444444  2.857143 18.750000
#>  [29] 33.846154  8.163265 18.181818 18.604651 28.846154 18.032787 19.607843
#>  [36]  1.818182 28.985507 44.776119 24.050633 52.307692 18.181818 40.540541
#>  [43] 38.775510 30.188679  2.777778 38.235294  8.620690 22.857143 34.482759
#>  [50] 44.594595 12.727273  9.615385  9.756098 21.818182 35.937500 15.384615
#>  [57] 24.324324 22.807018 48.611111 23.076923 10.810811 13.559322  1.923077
#>  [64]  6.896552 28.358209 14.035088 15.517241 34.285714 48.051948 25.000000
#>  [71] 48.484848 27.536232 57.500000 22.222222 25.862069 37.333333 46.875000
#>  [78] 40.000000 40.540541 51.515152 51.388889 13.333333 48.484848 33.333333
#>  [85] 24.074074 40.384615 32.000000 35.294118 27.586207 24.637681 10.344828
#>  [92] 13.333333 43.396226 31.034483 22.807018 17.647059 57.777778 15.384615
#>  [99] 33.333333 41.666667 43.478261 55.813953 46.428571 57.142857 47.368421
#> [106] 46.376812 41.573034 35.365854 40.322581 49.253731  9.756098 14.814815
#> [113] 19.047619  9.090909 25.000000 29.411765 39.344262 43.243243 51.063830
#> [120] 31.707317 41.176471 37.313433 40.000000 41.237113 32.183908 24.489796
#> [127] 46.551724 50.000000 42.857143 24.528302 50.000000 44.444444 45.945946
#> [134] 41.509434 33.823529 20.000000 25.714286 48.648649 43.478261 19.298246
#> [141] 40.322581 11.111111 36.666667 32.786885 38.043478 41.666667 29.850746
#> [148] 27.777778 41.304348 20.000000 10.000000 51.111111  3.703704  8.510638
#> [155] 44.827586 47.058824 36.842105 32.727273  3.703704 27.777778  4.347826
#> [162] 34.177215 42.553191 15.625000 46.153846 25.531915 21.052632 54.687500
#> [169] 43.298969 16.666667 21.951220 24.418605 24.528302 27.272727 25.000000
#> [176]  6.896552 21.052632 47.058824 39.622642 33.333333  5.714286 35.955056
#> [183] 46.268657  5.000000 18.309859  6.000000 28.571429 31.521739 21.052632
#> [190] 25.531915 17.647059 23.684211 21.276596 32.467532 26.086957 16.279070
#> [197] 33.333333 23.437500 36.065574  2.272727 14.035088 26.470588  2.127660
#> [204] 19.444444 18.965517 10.416667 35.135135 16.000000 33.333333 31.746032
#> [211] 28.767123 40.000000 48.936170 15.841584 20.253165 16.071429  6.060606
#> [218] 15.217391 22.727273 23.913043 21.875000 22.000000  4.166667 20.512821
#> [225]  9.803922

taxa_abund(.dataframe = nrsa_nap_0809,
           .key_col = uid,
           .counts_col = total,
           .filter = order %in% c("ephemeroptera",
                                  "plecoptera",
                                  "trichoptera"))
#>   [1]  78 241 137 121  96  12 147  17  59   0 197  26  19  13  31  35  40   2
#>  [19] 283 148 530  10 143 169 358   7   1  51  97  12  35  61  44  45  39   1
#>  [37] 166 173  78 381 124 285 191 150   0 312  24 101 269 380  16  18   7 189
#>  [55] 234 140  68 129 304  19  36  12   1   2  93  22  36  33 431   0 323 185
#>  [73] 437  95 123 219 216  61 141 338 286   2 340 157  88 193  60 198  42  42
#>  [91]   5  30 100  62  90  50 249   8 322 301 203 356  23 201 148 321 518 236
#> [109] 256 365   7  47 140   7 125 101  80 147 236  57 139 151 458 532 174  73
#> [127] 415 330 533 353 211 287 313 614 238  41 201 367 250  66 242  16 279 230
#> [145] 605 182  87  81 461   4   0 216   0   7 281 247 199  66   0  74   0 468
#> [163] 212  41 369  42   6 337 805  13  29  87  35  10  83   2  46 115 241 589
#> [181]   4 461 250   6  47   6  68 135  31  85  11  56 121 201 405 407 304 181
#> [199] 252   1 122  79   1 116 266   5  26  29   3 242 277 230 212  55  54  27
#> [217]   2  77 197 132 106 233   0 113  12

taxa_pct(.dataframe = nrsa_nap_0809,
         .key_col = uid,
         .counts_col = total,
         .filter = order %in% c("ephemeroptera",
                                "plecoptera",
                                "trichoptera"))
#>   [1] 17.9310345 60.4010025 41.5151515 77.0700637 26.4462810  2.3437500
#>   [7] 12.9973475  6.7729084  5.2678571  0.0000000 18.3597390 10.0000000
#>  [13]  3.5447761  2.2413793  5.7090239  9.3833780  7.7071291  0.3584229
#>  [19] 54.4230769 28.2442748 49.3482309  1.9120459 13.4020619 31.5298507
#>  [25] 33.5834897  1.4028056  0.1821494  8.5427136 18.0970149  2.4340771
#>  [31]  6.6162571 12.0553360  8.4291188  6.8078669  3.6516854  0.1490313
#>  [37] 30.1270417 28.8333333 14.4712430 69.7802198 23.5294118 53.6723164
#>  [43] 44.1108545 29.7029703  0.0000000 62.0278330  4.7619048 19.4230769
#>  [49] 48.1216458 70.5009276  3.1620553  3.2667877  1.4256619 36.4864865
#>  [55] 45.6140351 37.1352785 13.2038835 21.8644068 62.1676892 32.7586207
#>  [61]  6.4748201  3.4188034  0.1848429  0.3984064 17.8502879  4.4000000
#>  [67]  6.8702290 37.0786517 38.2431233  0.0000000 39.9258344 34.1328413
#>  [73] 90.8523909 17.7902622 10.9430605 41.9540230 60.3351955 53.0434783
#>  [79] 26.0147601 62.5925926 71.1442786  9.0909091 70.6860707 32.6403326
#>  [85] 16.3873371 40.2922756 31.4136126 57.2254335  8.6597938  7.9545455
#>  [91]  4.2016807  5.3380783 28.6532951 19.6202532 16.2162162  4.6816479
#>  [97] 88.9285714  5.7553957 41.1764706 57.2243346 39.1136802 85.7831325
#> [103] 34.8484848 84.1004184 35.4066986 65.6441718 45.7193292 46.3654224
#> [109] 46.6302368 62.6072041  1.3059701  9.6707819 24.7349823  1.3257576
#> [115] 23.2342007 17.2354949 18.6915888 37.8865979 71.2990937 29.0816327
#> [121] 24.3859649 29.2635659 42.7238806 50.4265403 33.5907336 13.8783270
#> [127] 74.5062837 71.2742981 60.2259887 66.1048689 52.6184539 81.7663818
#> [133] 57.8558226 61.5847543 46.0348162  8.2164329 35.5752212 68.4701493
#> [139] 43.4027778 12.5000000 48.7903226  4.6647230 57.7639752 44.9218750
#> [145] 60.5000000 62.7586207  8.7174349 22.6256983 46.0539461  9.0909091
#> [151]  0.0000000 46.9565217  0.0000000  1.1200000 46.5231788 47.3180077
#> [157] 37.9047619 20.3076923  0.0000000 11.0612855  0.0000000 42.8179323
#> [163] 41.3255361  7.9922027 69.4915254  8.9552239 13.0434783 62.5231911
#> [169] 73.9210285  4.6931408 20.8633094 16.5399240  6.5666041 10.5263158
#> [175] 37.5565611  1.5151515  8.4870849 40.3508772 44.9626866 51.2173913
#> [181]  0.7532957 43.7381404 54.3478261  0.5000000  9.3625498  1.1406844
#> [187] 11.4478114 26.7857143  6.2248996 16.1904762  6.0773481 12.4444444
#> [193] 22.0000000 37.8531073 75.2788104 28.1660900 53.1468531 33.6431227
#> [199] 45.5696203  0.0984252 23.4165067 14.3115942  0.2267574 21.6417910
#> [205] 48.2758621  0.9900990  5.1587302  5.4409006 25.0000000 43.2915921
#> [211] 52.1657250 49.0405117 40.4580153  5.4455446 10.3250478  5.0751880
#> [217]  0.3717472 15.1277014 37.7394636 38.8235294 63.4730539 44.8076923
#> [223]  0.0000000 34.7692308  2.3346304

taxa_dom(.dataframe = nrsa_nap_0809,
         .key_col = uid,
         .counts_col = total,
         .group_col = target_taxon,
         .dom_level = 1)
#>   [1] 21.379310 18.045113 23.333333 40.127389 55.647383 42.773438 34.305924
#>   [8] 11.952191 31.428571 44.594595 11.556384 60.769231 22.201493 25.517241
#>  [15] 31.123389 13.672922 51.445087 43.906810 18.461538 16.412214 14.990689
#>  [22] 16.826004 28.116214  9.328358 15.103189 15.831663 43.897996 19.597990
#>  [29] 28.544776 20.689655 42.911153 30.830040 50.766284 29.652042 45.037453
#>  [36] 35.916542 10.163339 40.500000 25.602968 26.373626 11.005693  9.604520
#>  [43] 34.411085 22.376238 51.650485 38.767396 22.023810  9.423077 15.563506
#>  [50] 17.068646 18.774704 35.753176 28.309572 25.675676 12.475634 22.546419
#>  [57] 62.718447 25.084746 17.995910 18.965517 29.676259  9.686610 24.399261
#>  [64] 34.462151 18.618042 26.000000 15.648855 14.606742 34.871340 57.142857
#>  [71] 35.599506 13.468635 19.334719 56.179775 38.078292 18.773946 10.614525
#>  [78] 11.304348 23.247232  8.148148 16.666667 27.272727 23.908524 27.234927
#>  [85] 20.297952 35.699374  8.900524 11.271676 20.206186 17.613636 19.327731
#>  [92] 24.021352 17.478510 14.873418 49.909910 39.138577 16.428571 48.201439
#>  [99] 21.355499 32.319392 22.350674 47.469880 13.636364 28.451883 29.425837
#> [106] 14.519427 11.032657  8.055010 19.489982 10.120069 22.014925 27.160494
#> [113] 22.791519 21.022727 19.702602 15.870307 34.579439 31.185567 20.543807
#> [120] 27.040816 34.385965 15.891473 15.764925 12.890995  7.335907 39.543726
#> [127] 29.982047 31.965443 32.429379 59.550562 17.955112 23.076923  9.796673
#> [134]  8.525577  7.736944 20.240481 15.398230 13.246269 17.187500 16.856061
#> [141] 12.500000 19.533528 13.457557 12.890625 15.400000 10.344828 43.987976
#> [148] 14.804469 10.889111 27.272727 51.724138 26.086957 15.053763 17.760000
#> [155] 16.887417 17.241379 17.333333 16.000000 51.298701 17.040359 23.300971
#> [162] 16.376944 19.493177 13.450292 25.423729 45.202559 17.391304 20.779221
#> [169] 20.844812 31.046931 12.230216  8.935361 30.956848 31.578947 33.031674
#> [176] 46.212121 47.047970 15.087719 12.500000 11.565217 22.975518 14.705882
#> [183]  9.347826 31.000000 17.131474 27.756654 15.993266 17.261905  8.232932
#> [190] 17.523810 27.071823 39.333333 38.909091 13.747646 51.301115 16.055363
#> [197] 11.713287 12.825279 18.264014 37.795276 12.476008 21.195652 26.530612
#> [204] 11.194030 18.511797 11.683168 79.563492 10.506567 25.000000 13.774597
#> [211] 17.325800 15.138593 27.290076 23.762376  9.177820 21.616541 59.293680
#> [218] 19.646365 30.459770 14.411765 58.682635 17.307692 44.923858 14.461538
#> [225] 30.350195

taxa_tol_index(.dataframe = nrsa_nap_0809,
               .key_col = uid,
               .counts_col = total,
               .tol_col = ptv)
#>   [1] 5.263962 3.940503 4.895283 3.135256 4.962291 5.670858 5.290982 6.351948
#>   [9] 6.857101 7.072973 6.090415 5.852140 6.872505 6.774558 6.919109 6.403022
#>  [17] 5.994220 6.555856 5.136811 4.955391 4.778470 6.388803 5.690170 5.517782
#>  [25] 5.603062 6.429218 6.044526 6.793761 5.020489 6.001639 6.667362 6.443601
#>  [33] 6.930830 6.776645 6.929611 7.565353 4.223616 4.608651 5.225145 3.792800
#>  [41] 5.123404 4.852834 5.319444 5.683402 7.819298 5.192060 7.015768 6.287056
#>  [49] 4.491434 3.062818 6.861458 6.845255 6.095238 6.439726 4.679332 5.995868
#>  [57] 5.767843 6.319828 3.614419 5.220370 5.830864 6.098058 5.395785 7.919478
#>  [65] 5.194456 6.069980 6.675150 4.243529 4.673033 5.300000 3.706157 5.349310
#>  [73] 3.442796 5.796395 6.199550 4.358058 3.815569 3.658491 4.531275 3.417893
#>  [81] 3.571309 6.457143 4.440848 5.270981 6.480075 3.125325 5.277095 4.982803
#>  [89] 6.277684 6.290996 6.409009 6.201081 4.386364 4.781373 6.910727 6.996513
#>  [97] 3.556296 5.694444 5.461628 4.227291 4.569592 2.580403 4.834426 3.132314
#> [105] 4.548655 4.038210 4.141087 4.825576 4.087078 3.837649 6.682863 6.586344
#> [113] 5.058198 7.282520 5.580098 6.559792 4.947002 4.242614 3.789655 3.997765
#> [121] 4.701818 4.474681 4.036765 3.973473 4.817364 6.262933 3.680153 3.547461
#> [129] 3.857913 3.369231 4.390076 3.271304 3.753571 3.629808 4.518432 3.867200
#> [137] 5.032143 3.048282 3.652424 6.727011 4.274689 6.899620 3.150827 4.452479
#> [145] 4.126270 3.940714 5.612272 5.809742 4.851526 5.897368 7.640741 4.594626
#> [153] 6.089730 7.041653 4.534545 4.086874 4.352588 5.523270 6.433987 5.489274
#> [161] 6.667742 4.161029 4.070156 6.275983 3.446365 5.781081 6.740000 3.455842
#> [169] 3.402335 7.096324 5.497600 5.318164 5.621146 6.853846 6.022785 5.993600
#> [177] 6.950864 4.608127 4.927837 4.011235 6.890000 4.513554 4.215259 6.766412
#> [185] 5.716331 6.182819 5.896552 5.433551 6.023156 5.611776 5.728902 5.980365
#> [193] 5.824635 5.029459 3.926286 5.523746 4.545471 5.671429 4.479920 7.233986
#> [201] 4.464892 5.110638 6.740698 6.330871 4.121547 6.105988 5.727510 6.512317
#> [209] 5.758333 5.092322 3.009055 3.942082 3.991684 6.525688 6.198406 6.099426
#> [217] 5.887833 5.790574 6.165900 4.648780 5.950610 4.863405 8.226463 4.733754
#> [225] 7.078008

About

This R package provides tools to aid in the development of Multi-Metric Indices (MMI) of biotic integrity.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages