Diversity.Ecology
In 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 = community ./ sum(community); # Convert counts to proportions
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 = 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(Metacommunity(ecosystem))
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 Jaccard types metacommunity 0.333333
julia> generalisedjaccard(ecosystem, Matrix(1.0I, 3, 3))
1×7 DataFrame
Row │ div_type measure type_level type_name partition_level partition_name diversity
│ String String String String String String Float64
─────┼─────────────────────────────────────────────────────────────────────────────────────────
1 │ Arbitrary Z Jaccard types metacommunity 0.333333
julia> community = [0.7, 0.2, 0.1];
julia> pielou(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 Pielou types subcommunity 1 0.729847
julia> communitymat = [10 20 30 20 0; #5 sites/subcommunities (columns) and 6 species (rows)
10 0 50 80 10;
60 10 90 0 0;
10 10 10 10 10;
70 70 70 70 70;
10 0 0 90 0];
julia> generalisedpielou(subcommunityDiversity, communitymat)
5×7 DataFrame
Row │ div_type measure type_level type_name partition_level partition_name diversity
│ String String String String String String Float64
─────┼─────────────────────────────────────────────────────────────────────────────────────────
1 │ Arbitrary Z Pielou types subcommunity 1 0.781115
2 │ Arbitrary Z Pielou types subcommunity 2 0.745557
3 │ Arbitrary Z Pielou types subcommunity 3 0.888073
4 │ Arbitrary Z Pielou types subcommunity 4 0.864562
5 │ Arbitrary Z Pielou types subcommunity 5 0.622366
julia> generalisedpielou(metacommunityDiversity, communitymat)
1×7 DataFrame
Row │ div_type measure type_level type_name partition_level partition_name diversity
│ String String String String String String Float64
─────┼─────────────────────────────────────────────────────────────────────────────────────────
1 │ Arbitrary Z Pielou types metacommunity 0.510146
Diversity.Ecology
— ModuleDiversity.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).
Diversity.Ecology.generalisedjaccard
— Functiongeneralisedjaccard(proportions::AbstractArray, qs, Z::AbstractMatrix)
generalisedjaccard(proportions::AbstractArray, qs, sim::AbstractTypes)
generalisedjaccard(meta::AbstractAssemblage, qs)
Calculates a generalisation of the Jaccard similarity 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 proportionsmeta
: metacommunity / assemblageZ
: similarity matrix orsim
: instance of AbstractTypes
Returns:
- Jaccard-related distinctivess measures
Diversity.Ecology.generalisedrichness
— Functiongeneralisedrichness(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 proportionsZ
: similarity matrix orsim
: instance of AbstractTypes
Returns:
- diversity (at ecosystem level) or diversities (of subcommunities)
Diversity.Ecology.generalisedshannon
— Functiongeneralisedshannon(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 proportionsZ
: similarity matrix orsim
: instance of AbstractTypes
Returns:
- entropy (at metacommunity level) or entropies (of subcommunities)
Diversity.Ecology.generalisedsimpson
— Functiongeneralisedsimpson(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 proportionsZ
: similarity matrix orsim
: instance of AbstractTypes
Returns:
- concentration (at ecosystem level) or concentrations (of subcommunities)
Diversity.Ecology.gower
— Functiongower(proportions::AbstractMatrix; countzeros::Bool = false, logscale::Bool = true)
gower(asm::AbstractAssemblage; countzeros::Bool = false, logscale::Bool = true)
Calculates Gower's dissimarity of up to two columns representing independent subcommunity counts.
Arguments:
proportions
: population proportions; orcount
: population counts; orasm
: Abstract Assemblage- ``
Returns:
- Gower dissimilarity of the subcommunities
Diversity.Ecology.jaccard
— Methodjaccard(proportions::AbstractMatrix)
jaccard(asm::AbstractAssemblage)
Calculates Jaccard similarity coefficient of two columns representing independent subcommunity counts
Arguments:
proportions
: population proportionsasm
: assemblage / metacommunity
Returns:
- the Jaccard index
Diversity.Ecology.pielou
— Methodpielou(proportions::AbstractMatrix)
pielou(asm::AbstractAssemblage)
Calculates Pielou's evenness of a series of columns representing independent subcommunity counts.
Arguments:
proportions
: population proportions
Returns:
- evenness of subcommunities
Example:
communitymat = [10 20 30 20 0;
10 0 50 80 10;
60 10 90 0 0;
10 10 10 10 10;
70 70 70 70 70;
10 0 0 90 0];
pielou(communitymat)
Diversity.Ecology.richness
— Methodrichness(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
— Methodshannon(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
Diversity.Ecology.simpson
— Methodsimpson(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.API
Diversity.Diversity
Diversity.Ecology
Diversity.Hill
Diversity.Jost
Diversity.ShortNames
Diversity.individualDiversity
Diversity.metacommunityDiversity
Diversity.subcommunityDiversity
Diversity.API.AbstractMetacommunity
Diversity.API.AbstractPartition
Diversity.API.AbstractTypes
Diversity.DiversityLevel
Diversity.DiversityMeasure
Diversity.Gamma
Diversity.GeneralTypes
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._addedoutputcols
Diversity.API._calcabundance
Diversity.API._calcordinariness
Diversity.API._calcsimilarity
Diversity.API._countsubcommunities
Diversity.API._counttypes
Diversity.API._getabundance
Diversity.API._getaddedoutput
Diversity.API._getdiversityname
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.gower
Diversity.Ecology.jaccard
Diversity.Ecology.pielou
Diversity.Ecology.richness
Diversity.Ecology.shannon
Diversity.Ecology.simpson
Diversity.Hill.hillnumber
Diversity.Jost.jostalpha
Diversity.Jost.jostbeta
Diversity._getmeta
Diversity.addedoutputcols
Diversity.calcsimilarity
Diversity.countsubcommunities
Diversity.counttypes
Diversity.diversity
Diversity.getASCIIName
Diversity.getFullName
Diversity.getName
Diversity.getabundance
Diversity.getaddedoutput
Diversity.getdiversityname
Diversity.getmetaabundance
Diversity.getmetaordinariness!
Diversity.getordinariness!
Diversity.getpartition
Diversity.getsubcommunitynames
Diversity.gettypenames
Diversity.gettypes
Diversity.getweight
Diversity.hassimilarity
Diversity.inddiv
Diversity.metadiv
Diversity.powermean
Diversity.qD
Diversity.qDZ
Diversity.subdiv