Ecology
In the Diversity.Ecology package, 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 julia> community = [10, 20, 20]; julia> community /= sum(community); julia> diversity = simpson(community) 1×7 DataFrames.DataFrame │ Row │ measure │ q │ type_level │ type_name │ partition_level │ ├─────┼───────────┼───┼────────────┼───────────┼─────────────────┤ │ 1 │ "Simpson" │ 2 │ "types" │ "" │ "subcommunity" │ │ Row │ partition_name │ diversity │ ├─────┼────────────────┼───────────┤ │ 1 │ "1" │ 0.36 │ julia> ecosystem = [2 2 0.; 0 2 2]'; julia> ecosystem /= sum(ecosystem); julia> jaccard(ecosystem) 1×7 DataFrames.DataFrame │ Row │ measure │ q │ type_level │ type_name │ partition_level │ ├─────┼───────────┼───┼────────────┼───────────┼─────────────────┤ │ 1 │ "Jaccard" │ 0 │ "types" │ "" │ "metacommunity" │ │ Row │ partition_name │ diversity │ ├─────┼────────────────┼───────────┤ │ 1 │ "" │ 0.333333 │ julia> generalisedjaccard(ecosystem, [0, 1, 2]) 3×7 DataFrames.DataFrame │ Row │ measure │ q │ type_level │ type_name │ partition_level │ ├─────┼───────────┼───┼────────────┼───────────┼─────────────────┤ │ 1 │ "Jaccard" │ 0 │ "types" │ "" │ "metacommunity" │ │ 2 │ "Jaccard" │ 1 │ "types" │ "" │ "metacommunity" │ │ 3 │ "Jaccard" │ 2 │ "types" │ "" │ "metacommunity" │ │ Row │ partition_name │ diversity │ ├─────┼────────────────┼───────────┤ │ 1 │ "" │ 0.333333 │ │ 2 │ "" │ 0.414214 │ │ 3 │ "" │ 0.5 │ julia> generalisedjaccard(ecosystem, [0, 1, 2], eye(3)) 3×7 DataFrames.DataFrame │ Row │ measure │ q │ type_level │ type_name │ partition_level │ ├─────┼───────────┼───┼────────────┼───────────┼─────────────────┤ │ 1 │ "Jaccard" │ 0 │ "types" │ "" │ "metacommunity" │ │ 2 │ "Jaccard" │ 1 │ "types" │ "" │ "metacommunity" │ │ 3 │ "Jaccard" │ 2 │ "types" │ "" │ "metacommunity" │ │ Row │ partition_name │ diversity │ ├─────┼────────────────┼───────────┤ │ 1 │ "" │ 0.333333 │ │ 2 │ "" │ 0.414214 │ │ 3 │ "" │ 0.5 │
#
Diversity.Ecology
— Module.
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).
#
Diversity.Ecology.generalisedjaccard
— Function.
generalisedjaccard(proportions::AbstractArray, qs, Z::AbstractMatrix)
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 proportionsqs
: single number or vector of values of parameter qZ
: similarity matrix
Returns:
- Jaccard-related distinctivess measures
#
Diversity.Ecology.generalisedrichness
— Function.
generalisedrichness(level::DiversityLevel, proportions::AbstractArray, Z::AbstractMatrix)
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 proportionsZ
: similarity matrix
Returns:
- diversity (at ecosystem level) or diversities (of subcommunities)
#
Diversity.Ecology.generalisedshannon
— Function.
generalisedshannon(level::DiversityLevel, proportions::AbstractArray, Z::AbstractMatrix)
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 proportionsZ
: similarity matrix
Returns:
- entropy (at metacommunity level) or entropies (of subcommunities)
#
Diversity.Ecology.generalisedsimpson
— Function.
Calculate a generalised version of Simpson's index
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 proportionsZ
: similarity matrix
Returns:
- concentration (at ecosystem level) or concentrations (of subcommunities)
#
Diversity.Ecology.jaccard
— Method.
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
#
Diversity.Ecology.richness
— Method.
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
#
Diversity.Ecology.shannon
— Method.
Calculate Shannon entropy of populations
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
#
Diversity.Ecology.simpson
— Method.
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
Diversity
Diversity.API
Diversity.Ecology
Diversity.Hill
Diversity.Jost
Diversity.individualDiversity
Diversity.metacommunityDiversity
Diversity.subcommunityDiversity
Diversity.API.AbstractMetacommunity
Diversity.API.AbstractPartition
Diversity.API.AbstractTypes
Diversity.DiversityLevel
Diversity.DiversityMeasure
Diversity.Gamma
Diversity.GeneralTypes
Diversity.Metacommunity
Diversity.NormalisedAlpha
Diversity.NormalisedBeta
Diversity.NormalisedRho
Diversity.Onecommunity
Diversity.PowerMeanMeasure
Diversity.RawAlpha
Diversity.RawBeta
Diversity.RawRho
Diversity.RelativeEntropyMeasure
Diversity.Species
Diversity.Subcommunities
Diversity.Taxonomy
Diversity.UniqueTypes
Diversity.API._calcabundance
Diversity.API._calcordinariness
Diversity.API._calcsimilarity
Diversity.API._countsubcommunities
Diversity.API._counttypes
Diversity.API._getabundance
Diversity.API._getmetaabundance
Diversity.API._getmetaordinariness!
Diversity.API._getordinariness!
Diversity.API._getpartition
Diversity.API._getscale
Diversity.API._getsubcommunitynames
Diversity.API._gettypenames
Diversity.API._gettypes
Diversity.API._getweight
Diversity.API.floattypes
Diversity.API.mcmatch
Diversity.API.typematch
Diversity.Ecology.generalisedjaccard
Diversity.Ecology.generalisedrichness
Diversity.Ecology.generalisedshannon
Diversity.Ecology.generalisedsimpson
Diversity.Ecology.jaccard
Diversity.Ecology.richness
Diversity.Ecology.shannon
Diversity.Ecology.simpson
Diversity.Hill.hillnumber
Diversity.Jost.jostalpha
Diversity.Jost.jostbeta
Diversity.calcsimilarity
Diversity.countsubcommunities
Diversity.counttypes
Diversity.diversity
Diversity.getASCIIName
Diversity.getFullName
Diversity.getName
Diversity.getabundance
Diversity.getmetaabundance
Diversity.getmetaordinariness!
Diversity.getordinariness!
Diversity.getpartition
Diversity.getsubcommunitynames
Diversity.gettypenames
Diversity.gettypenames
Diversity.gettypes
Diversity.getweight
Diversity.inddiv
Diversity.metadiv
Diversity.qD
Diversity.qDZ
Diversity.subdiv