Thursday, July 5, 2012

addbinary: an R function for converting an abundance table (x) into its additive binary form

Here's a function I have written for the R statistical environment that converts a table of species abundances into its additive binary form. That is, each column of abundance data (representing a single species across multiple sites) is converted into a number of columns equal to the maximum abundance of that species, with each new column representing an abundance value ranging from 1 to maximum abundance. Species abundance per site is recorded as a "1" in each column for which the abundance value is equal to or less than the site abundance.

If that makes no sense, let me attempt a simple example below with an abundance vector for a single species:

0 --> 000
3 --> 111
1 --> 100
0 --> 000
2 --> 110

The purpose for doing this, at least from my point of view, is to allow for the calculation of abundance-based forms of resemblance (similarity/dissimilarity) measures with R functions that only calculate the incidence-based, or binary, form. Tamas et al. (2001) have shown that any incidence-based resemblance measure calculated from the 2 x 2 contingency table can be transformed into its abundance-based equivalent by this method. So, for example, functions available in the simba and GDM packages can be "fooled" into accepting abundance-weighted data for calculating resemblance measures. Hopefully, this will be useful to somebody other than me.

I am providing this function for free and without warranty under the GNU General Public License. You need to be familiar with R to use this function.

addbinary (x)
x is a community data table (as in the vegan package) with species/OTUs as columns and samples/sites as rows. Columns are labelled with the names of the species/OTUs. Rows are labelled with the names of the samples/sites. Data are abundances of species/OTUs per sample/site.
addbinary converts a community data table to its additive binary form (see discussion above).
addbinary returns a matrix object being the additive binary form of x.
Tamas et al. (2001) An extension of presence/absence coefficients to abundance data: a new look at absence. Journal of Vegetation Science 12: 401-410.

No comments:

Post a Comment