macroeco.empirical.sad

macroeco.empirical.sad(patch, cols, splits, clean=True)

Calculates an empirical species abundance distribution

Parameters:

patch : Patch obj

Patch object containing data for analysis

cols : str

Indicates which column names in patch data table are associated with species identifiers, counts, energy, and mass. See Notes.

splits : str

If multiple analyses for subsets of patch data table are desired, specifies how columns should be split. See Notes.

clean : bool

If True, all species with zero abundance are removed from SAD results. Default False.

Returns:

list :

List of tuples containing results, where the first element of each tuple is a string indicating the split values used for that result and second element is a dataframe giving the result. Result has two columns: spp (species identifier) and y (individuals of

that species). :

Notes

The parameter cols is a string describing which column in the data table should be used for which “special columns” in analysis. The five possible special columns are

  • spp_col - Unique species identifiers
  • count_col - Number of individuals at a location
  • x_col - x coordinate of location
  • y_col - y coordinate of location
  • energy_col - Energetic requirements of individual(s) at a location

For example, setting cols to spp_col: spp: count_col: number will use the column named “spp” in the data table to represent the unique species identifiers, and the column “number” in the data table to represent the count of individuals at a point.

Different special columns are required for different analyses. count_col is used when multiple individuals of a species may be found at a single recorded location, as is the case in gridded censuses where all individuals in a quadrat are “assigned” to a single point. If count_col is not specified, each record in the data table will be presumed to represent a single individual (i.e., a count of 1).

Note that the value of spp_col may be set to a columm in the data table giving the genus, family, functional group, etc., which allows for analysis of this metric by those groups.

The parameter splits is a semicolon-separated string in the form of “column: value”, where column is a name of a column in the patch data table and value is either (a) an integer giving the number of equally-spaced divisions of a column, or (b) the special keyword ‘split’, which evaluates all unique levels of a column.

For example, presume a data table has columns for x and y spatial coordinates and a column for year, of which there are three. The string “x:2; y:2; year:split” will perform the analysis separately for each of four subplots of the patch (created by dividing the x and y coordinates each into two equally sized divisions) within each of the three years, for a total of 12 separate analyses. Note that if you pass in the x split you MUST also pass in a y split (even if it is just “y:1”) or vice versa. Otherwise, the computed areas will be incorrect.

Examples

>>> # Using the ANBO data provided in demo_files_ANBO.zip found at
>>> # https://github.com/jkitzes/macroeco/releases/
>>> import macroeco as meco
>>> # Pass in path to metadata in order to make patch object
>>> pat = meco.empirical.Patch('~/Desktop/ANBO.txt')
>>> # Get the SAD of the full plot
>>> sad = meco.empirical.sad(pat, 'spp_col:spp; count_col:count', '')
>>> # Extract the SAD
>>> sad_df = sad[0][1]
>>> sad_df
       spp     y
0    arsp1     2
1     cabr    31
2   caspi1    58
3     chst     1
4    comp1     5
5     cran     4
6     crcr    65
7    crsp2    79
8     enfa     1
9     gnwe    41
10   grass  1110
11   lesp1     1
12    magl     1
13    mesp     6
14    mobe     4
15    phdi   210
16   plsp1     1
17    pypo    73
18    sasp     2
19    ticr   729
20   unsh1     1
21   unsp1    18
22   unsp3     1
23   unsp4     1
>>> # Get SAD for 4 subplots within the full plot and keep absent species
>>> # using clean = False
>>> sad_subplots = meco.empirical.sad(pat, 'spp_col:spp; count_col:count', splits = "row:2; column:2", clean=False)
>>> len(sad_subplots)
4
>>> # Look at SAD in one of the 4 cells
>>> sad_subplots[0]
('row>=-0.5; row<1.5; column>=-0.5; column<1.5',
       spp    y
0    arsp1    0
1     cabr    7
2   caspi1    0
3     chst    1
4    comp1    1
5     cran    3
6     crcr   21
7    crsp2   16
8     enfa    0
9     gnwe    8
10   grass  236
11   lesp1    0
12    magl    0
13    mesp    4
14    mobe    0
15    phdi   33
16   plsp1    1
17    pypo    8
18    sasp    2
19    ticr  317
20   unsh1    1
21   unsp1    0
22   unsp3    1
23   unsp4    1)

See http://www.macroeco.org/tutorial_macroeco.html for additional examples and explanation