Diversity.Ecology

n the Diversity.Ecology submodule, we replicate old ecological diversity measures and generalised versions of them that relate to our general measures of alpha, beta and gamma diversity at subcommunity and ecosystem measures. The generalisations of the richness, Shannon and Simpson are the only standard measures we are aware of whose subcommunity components sum directly to the corresponding ecosystem measure (although note that Simpson's index decreases for increased diversity, so small components are more diverse).

Usage

Accessing the functionality in the package is simple:

julia> using Diversity.Ecology, LinearAlgebra

julia> community = [10, 20, 20];

julia> community /= sum(community);

julia> diversity = simpson(community)
1×7 DataFrame
│ Row │ div_type │ measure │ type_level │ type_name │ partition_level │ partition_name │ diversity │
│     │ String   │ String  │ String     │ String    │ String          │ String         │ Float64   │
├─────┼──────────┼─────────┼────────────┼───────────┼─────────────────┼────────────────┼───────────┤
│ 1   │ Unique   │ Simpson │ types      │           │ subcommunity    │ 1              │ 0.36      │

julia> ecosystem = [2 2 0.; 0 2 2]';

julia> ecosystem /= sum(ecosystem);

julia> jaccard(ecosystem)
1×8 DataFrame
│ Row │ div_type │ measure │ q     │ type_level │ type_name │ partition_level │ partition_name │ diversity │
│     │ String   │ String  │ Int64 │ String     │ String    │ String          │ String         │ Float64   │
├─────┼──────────┼─────────┼───────┼────────────┼───────────┼─────────────────┼────────────────┼───────────┤
│ 1   │ Unique   │ Jaccard │ 0     │ types      │           │ metacommunity   │                │ 0.333333  │

julia> generalisedjaccard(ecosystem, [0, 1, 2])
3×8 DataFrame
│ Row │ div_type    │ measure │ q     │ type_level │ type_name │ partition_level │ partition_name │ diversity │
│     │ String      │ String  │ Int64 │ String     │ String    │ String          │ String         │ Float64   │
├─────┼─────────────┼─────────┼───────┼────────────┼───────────┼─────────────────┼────────────────┼───────────┤
│ 1   │ Arbitrary Z │ Jaccard │ 0     │ types      │           │ metacommunity   │                │ 0.333333  │
│ 2   │ Arbitrary Z │ Jaccard │ 1     │ types      │           │ metacommunity   │                │ 0.414214  │
│ 3   │ Arbitrary Z │ Jaccard │ 2     │ types      │           │ metacommunity   │                │ 0.5       │

julia> generalisedjaccard(ecosystem, [0, 1, 2], Matrix(1.0I, 3, 3))
3×8 DataFrame
│ Row │ div_type    │ measure │ q     │ type_level │ type_name │ partition_level │ partition_name │ diversity │
│     │ String      │ String  │ Int64 │ String     │ String    │ String          │ String         │ Float64   │
├─────┼─────────────┼─────────┼───────┼────────────┼───────────┼─────────────────┼────────────────┼───────────┤
│ 1   │ Arbitrary Z │ Jaccard │ 0     │ types      │           │ metacommunity   │                │ 0.333333  │
│ 2   │ Arbitrary Z │ Jaccard │ 1     │ types      │           │ metacommunity   │                │ 0.414214  │
│ 3   │ Arbitrary Z │ Jaccard │ 2     │ types      │           │ metacommunity   │                │ 0.5       │
Diversity.EcologyModule
Diversity.Ecology submodule

The Diversity.Ecology module replicates old ecological diversity measures and generalised versions of them that relate to our general measures of alpha, beta and gamma diversity at subcommunity and metacommunity levels. The generalisations of the richness, Shannon and Simpson are the only standard measures we are aware of whose subcommunity components sum directly to the corresponding ecosystem measure (although note that Simpson's index decreases for increased diversity, so small components are more diverse).

source
Diversity.Ecology.generalisedjaccardFunction
generalisedjaccard(proportions::AbstractArray, qs, Z::AbstractMatrix)
generalisedjaccard(proportions::AbstractArray, qs, sim::AbstractTypes)

Calculates a generalisation of the Jaccard index of two columns representing the counts of two subcommunities. This evaluates to raw alpha / gamma - 1 for a series of orders, repesented as a vector of qs (or a single number). It also includes an optional similarity matrix for the species. This gives a measure of the distinctness of the subcommunities, though we believe that beta and normalised beta have better properties.

Arguments:

  • proportions: population proportions

  • qs: single number or vector of values of parameter q

  • Z: similarity matrix or

  • sim: instance of AbstractTypes

Returns:

  • Jaccard-related distinctivess measures
source
Diversity.Ecology.generalisedrichnessFunction
generalisedrichness(level::DiversityLevel, proportions::AbstractArray,
                    Z::AbstractMatrix)
generalisedrichness(level::DiversityLevel, proportions::AbstractArray,
                    sim::AbstractTypes)

Calculates species richness (diversity at q = 0) of a series of columns representing subcommunity counts, allowing a similarity matrix for the types / species.

Arguments:

  • level: DiversityLevel to calculate at (e.g. subcommunityDiversity)

  • proportions: population proportions

  • Z: similarity matrix or

  • sim: instance of AbstractTypes

Returns:

  • diversity (at ecosystem level) or diversities (of subcommunities)
source
Diversity.Ecology.generalisedshannonFunction
generalisedshannon(level::DiversityLevel, proportions::AbstractArray,
                   Z::AbstractMatrix)
generalisedshannon(level::DiversityLevel, proportions::AbstractArray,
                   sim::AbstractTypes)

Calculates Shannon entropy (log of diversity at q = 1) of a series of columns representing independent subcommunity counts, allowing a similarity matrix for the types / species.

Arguments:

  • level: DiversityLevel to calculate at (e.g. subcommunityDiversity)

  • proportions: population proportions

  • Z: similarity matrix or

  • sim: instance of AbstractTypes

Returns:

  • entropy (at metacommunity level) or entropies (of subcommunities)
source
Diversity.Ecology.generalisedsimpsonFunction
generalisedsimpson(level::DiversityLevel, proportions::AbstractArray,
                   Z::AbstractMatrix)
generalisedsimpson(level::DiversityLevel, proportions::AbstractArray,
                   sim::AbstractTypes)

Calculates Simpson's index (1 / diversity at q = 2) of a series of columns representing independent subcommunity counts, allowing a similarity matrix for the types / species.

Arguments:

  • level: DiversityLevel to calculate at (e.g. subcommunityDiversity)

  • proportions: population proportions

  • Z: similarity matrix or

  • sim: instance of AbstractTypes

Returns:

  • concentration (at ecosystem level) or concentrations (of subcommunities)
source
Diversity.Ecology.jaccardMethod
jaccard(proportions::AbstractMatrix)

Calculates Jaccard index (Jaccard similarity coefficient) of two columns representing independent subcommunity counts, which is normmetaalpha(proportions, 0) / metagamma(proportions, 0) - 1

Arguments:

  • proportions: population proportions

Returns:

  • the Jaccard index
source
Diversity.Ecology.richnessMethod
richness(proportions::AbstractMatrix)

Calculates species richness (diversity at q = 0) of a series of columns representing independent subcommunity counts.

Arguments:

  • proportions: population proportions

Returns:

  • diversities of subcommunities
source
Diversity.Ecology.shannonMethod
shannon(proportions::AbstractVecOrMat)

Calculates shannon entropy (log of diversity at q = 1) of a series of columns representing independent subcommunity counts.

Arguments:

  • proportions: population proportions

Returns:

  • entropies of subcommunities
source
Diversity.Ecology.simpsonMethod
simpson(proportions::AbstractMatrix)

Calculates Simpson's index (1 / diversity at q = 2) of a series of columns representing independent subcommunity counts.

Arguments:

  • proportions: population proportions

Returns:

  • concentrations of subcommunities
source