Diversity.jl
A package for measuring and partitioning diversity
The main Diversity package measures the alpha, beta and gamma diversity of a metacommunity and of each of its subcommunities, for any notion of similarity between the individuals in it — taxonomic, phylogenetic, genetic, functional or phenotypic.
It provides numbers-equivalent diversity measures (Hill numbers), similarity-sensitive diversity measures generalising them, and the alpha, beta and gamma measures that partition those across subcommunities. The framework explains what each measure means and where it came from; start there if the names below are unfamiliar.
The diversity functions exist both with unicode names (e.g. ᾱ()), which are not automatically exported (as we feel they are too short) and with matching longer ASCII names (e.g. NormalisedAlpha()), which are. We also provide functions to calculate appropriate subdiv() and metadiv() values for each measure, and a general diversity() function to extract any diversity measure at a series of scales.
Accessing the main functionality in the package is simple:
julia> using Diversityjulia> pop = [1 1 0; 2 0 0; 3 1 4]3×3 Matrix{Int64}: 1 1 0 2 0 0 3 1 4julia> pop = pop ./ sum(pop)3×3 Matrix{Float64}: 0.0833333 0.0833333 0.0 0.166667 0.0 0.0 0.25 0.0833333 0.333333julia> meta = Metacommunity(pop)Metacommunity{Float64, Matrix{Float64}, Matrix{Float64}, UniqueTypes, Subcommunities} with 3 species in 3 subcommunities measuring Unique diversity. Species names: 1, 2, 3 Subcommunity names: 1, 2, 3julia> norm_meta_alpha(meta, [0, 1, 2, Inf])4×8 DataFrame Row │ div_type measure q type_level type_name partition_le ⋯ │ String String Float64 String String String ⋯ ─────┼────────────────────────────────────────────────────────────────────────── 1 │ Unique NormalisedAlpha 0.0 types metacommunit ⋯ 2 │ Unique NormalisedAlpha 1.0 types metacommunit 3 │ Unique NormalisedAlpha 2.0 types metacommunit 4 │ Unique NormalisedAlpha Inf types metacommunit 3 columns omitted
Every measure returns a DataFrame in the same format, whatever the measure and whatever the scale, so results can be compared and concatenated directly. The diversity column holds the answer; the rest say what was calculated and for what.
Adding a similarity matrix makes the measures similarity-sensitive — two types that resemble each other now contribute less diversity between them than two that do not:
julia> Z = [1.0 0 0; 0 1 1; 1 1 1]3×3 Matrix{Float64}: 1.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0 1.0julia> meta_z = Metacommunity(pop, Z)Metacommunity{Float64, Matrix{Float64}, Matrix{Float64}, GeneralTypes{Float64, Matrix{Float64}, Vector{Int64}}, Subcommunities} with 3 species in 3 subcommunities measuring Arbitrary Z diversity. Species names: 1, 2, 3 Subcommunity names: 1, 2, 3julia> subdiv(RawRho(meta_z), 2)3×8 DataFrame Row │ div_type measure q type_level type_name partition_level pa ⋯ │ String String Int64 String String String St ⋯ ─────┼────────────────────────────────────────────────────────────────────────── 1 │ Arbitrary Z RawRho 2 types subcommunity 1 ⋯ 2 │ Arbitrary Z RawRho 2 types subcommunity 2 3 │ Arbitrary Z RawRho 2 types subcommunity 3 2 columns omitted
Note that the abundances are relative to the whole metacommunity and must sum to one across it — not one per subcommunity. Counts are normalised for you, and floating point abundances that do not sum to one are corrected with a warning.
- Diversity.API
- Diversity.Ecology
- The framework
- Genetic diversity
- Diversity.Hill
- Diversity.jl
- Diversity.Jost
- Building a metacommunity
- Phylogenetic diversity
- Coming from vegan
Diversity.Diversity — Module
Diversity packageThe main Diversity package provides basic numbers-equivalent diversity measures (described in Hill, 1973), similarity-sensitive diversity measures (generalised from Hill, and described in Leinster and Cobbold, 2012), and related alpha, beta and gamma diversity measures at the level of the metacommunity and its component subcommunities (generalised in turn from Leinster and Cobbold, and described in Reeve et al, 2014). The diversity functions exist both with unicode names (e.g. ᾱ()), which are not automatically exported (as we feel they are too short) and with matching longer ASCII names (e.g. NormalisedAlpha()), which are. We also provide functions to calculate appropriate subcommunityDiversity() and metacommunityDiversity() values for each measure, and a general diversity() function to extract any diversity measure at a series of scales.
Diversity.individualDiversity — Constant
Generates the function to calculate individual diversities
Generates the function to calculate individual diversities for a series of orders, represented as a vector of qs.
Arguments:
dm: DiversityMeasure
Returns:
- Function which takes a single number or vector of values of parameter q, and returns the individual diversities for those values.
Diversity.metacommunityDiversity — Constant
Generates the function to calculate metacommunity diversity
Generates the function to calculate metacommunity diversity for a series of orders, represented as a vector of qs.
Arguments:
dm: DiversityMeasure
Returns:
- Function which takes a single number or vector of values of parameter q, and returns the metacommunity diversities for those values.
Diversity.subcommunityDiversity — Constant
Generates the function to calculate subcommunity diversity
Generates the function to calculate subcommunity diversity for a series of orders, represented as a vector of qs.
Arguments:
dm: DiversityMeasure
Returns:
- Function which takes a single number or vector of values of parameter q, and returns the subcommunity diversities for those values.
Diversity.AbstractGenetic — Type
AbstractGeneticAbstract supertype for genetic similarity types, whose similarity is derived from pairwise genetic distances between sequences (FASTA) or genotyped samples (VCF). Concrete subtypes are provided by the DiversityBioSequencesExt extension (when BioSequences is loaded) and the DiversityPopGenExt extension (when PopGen is loaded).
Diversity.AbstractPhyloTypes — Type
AbstractPhyloTypes{Tree}Abstract supertype for types whose similarity comes from a phylogeny Tree, so that diversity is measured over evolutionary history rather than over species treated as wholly distinct. Concrete subtypes are provided by the DiversityPhyloExt extension, when Phylo is loaded.
Diversity.DiversityLevel — Type
Enumeration of levels that can exist / be calculated for a metacommunity.
Diversity.DiversityMeasure — Type
DiversityMeasureThis type is the abstract supertype of all diversity measure types. DiversityMeasure subtypes allow you to calculate and cache any kind of diversity of a metacommunity.
Diversity.Gamma — Type
GammaCalculates gamma diversity (γ) of all of the individuals in a metacommunity, and caches them for subsequent analysis. This is a subtype of PowerMeanMeasure, meaning that all composite diversity measures are simple powermeans of the individual measures.
The two scales read differently here, and the difference matters. Per subcommunity, it is the contribution per individual toward metacommunity diversity, combining a subcommunity's own diversity with the rarity of its types in the metacommunity — so a subcommunity of a few very rare types contributes heavily however dull it looks in isolation. Averaged over the subcommunities it gives the metacommunity's own similarity-sensitive diversity, the diversity of the whole taken without regard to how it is divided.
Constructor arguments:
meta: a Metacommunity
Diversity.GeneralTypes — Type
GeneralTypes{FP, M, LABELS}An AbstractTypes subtype with a general similarity matrix. This subtype simply holds a matrix with similarities between individuals.
Members:
zA two-dimensional matrix representing similarity between
individuals.
namesVector of type names.
Diversity.GeneralTypes — Method
GeneralTypes(zmatrix::M)
GeneralTypes(zmatrix::M, names::LABELS)Constructors for GeneralTypes. Creates an instance of the GeneralTypes class, with an arbitrary zmatrix similarity matrix and an optional vector of type names.
Diversity.Metacommunity — Type
Metacommunity{FP, ARaw, AProcessed, Part, Sim}Metacommunity type, representing a whole metacommunity containing a single community or a collection of subcommunities. The metacommunity of individuals may be further partitioned into smaller groups. For instance this may be an ecosystem, which consists of a series of subcommunities. The AbstractPartition subtype within it stores relative abundances of different types, e.g. species, and also allows for similarity between individuals.
Constructor:
Metacommunity(abundances::AbstractArray, part::AbstractPartition, types::AbstractTypes)
Members:
abundancesthe abundance matrix for the metacommunity.partitionthe instance of the AbstractPartition subtype, containing the subcommunities.typesThe instance of the AbstractTypes subtype, from which similarities between individuals can be calculated.ordinarinessA cache of the ordinariness of the individuals in the Partition. Should only be accessed through getordinariness!(::Metacommunity), which will populate the cache if it has not yet been calculated.
Diversity.NormalisedAlpha — Type
NormalisedAlphaCalculates normalised alpha diversity (ᾱ) of all of the individuals in a metacommunity, and caches them for subsequent analysis. This is a subtype of PowerMeanMeasure, meaning that all composite diversity measures are simple powermeans of the individual measures.
Per subcommunity, it is the similarity-sensitive diversity of that subcommunity in isolation — what its diversity would be if it were the whole community. Averaged over the subcommunities it gives their average diversity, which is invariant under shattering.
Constructor arguments:
meta: a Metacommunity
Diversity.NormalisedBeta — Type
NormalisedBetaCalculates normalised beta diversity (β̄) of all of the individuals in a metacommunity, and caches them for subsequent analysis. This is a subtype of RelativeEntropyMeasure, meaning that subcommunity and type composite diversity measures are relative entropies, and their composite types are powermeans of those measures.
Per subcommunity, it is an estimate of the effective number of distinct subcommunities, and is high when a subcommunity is both distinctive and small. Averaged over the subcommunities it gives the effective number of distinct subcommunities itself, which is at most the number of subcommunities — reaching that maximum when they are completely distinct and of equal size — and which is invariant under shattering. It is the reciprocal of NormalisedRho.
Constructor arguments:
meta: a Metacommunity
Diversity.NormalisedRho — Type
NormalisedRhoCalculates representativeness (ρ̄, normalised beta diversity) of all of the individuals in a metacommunity, and caches them for subsequent analysis. This is a subtype of PowerMeanMeasure, meaning that all composite diversity measures are simple powermeans of the individual measures.
Per subcommunity, it is the representativeness of that subcommunity: how typical it is of the metacommunity as a whole. Where all types are equally abundant, a subcommunity holding a fraction r of them has representativeness exactly r — whatever fraction of the individuals it holds, since being the normalised measure it has the subcommunity's weight divided out. Averaged over the subcommunities it gives their average representativeness. In the naive-type case representativeness is at most 1, attained when the subcommunity has the same type distribution as the metacommunity — but that bound does not hold for a general similarity matrix. It is the reciprocal of NormalisedBeta.
Constructor arguments:
meta: a Metacommunity
Diversity.Onecommunity — Type
OnecommunityAbstractPartition subtype containing only one subcommunity.
Diversity.PhyloBranches — Type
PhyloBranches{Tree} <: AbstractPhyloTypes{Tree}Abstract supertype for phylogenetic types that expand a tree into the ancestral branches leading to each species, and measure diversity over those branches. The concrete type is supplied by the DiversityPhyloExt extension, so PhyloBranches(tree) works once Phylo is loaded.
Diversity.PowerMeanMeasure — Type
PowerMeanMeasureThis abstract DiversityMeasure subtype is the supertype of all diversity measures which are straight power means. PowerMeanMeasure subtypes allow you to calculate and cache any kind of diversity of a metacommunity.
Diversity.RawAlpha — Type
RawAlphaCalculates raw alpha diversity (α) of all of the individuals in a metacommunity, and caches them for subsequent analysis. This is a subtype of PowerMeanMeasure, meaning that all composite diversity measures are simple powermeans of the individual measures.
Per subcommunity, it is an estimate of naive-community metacommunity diversity — the diversity the whole metacommunity would have if this subcommunity shared no types, and no similarity, with any other. Averaged over the subcommunities it gives naive-community metacommunity diversity itself, which is an upper bound on the true metacommunity diversity Gamma. It is NormalisedAlpha measured per individual rather than per subcommunity.
Constructor arguments:
meta: a Metacommunity
Diversity.RawBeta — Type
RawBetaCalculates distinctiveness (β, raw beta diversity) of all of the individuals in a metacommunity, and caches them for subsequent analysis. This is a subtype of RelativeEntropyMeasure, meaning that subcommunity and type composite diversity measures are relative entropies, and their composite types are powermeans of those measures.
Per subcommunity, it is the distinctiveness of that subcommunity: how much of it is unlike the rest of the metacommunity, whether through types found nowhere else or through low similarity to the types that are. It reaches its maximum of 1 when every individual in the subcommunity is completely dissimilar to every individual outside it, and is small when the subcommunity has much in common with the rest. Averaged over the subcommunities it gives their average distinctiveness, which can be read as a kind of turnover. It is the reciprocal of RawRho.
Constructor arguments:
meta: a Metacommunity
Diversity.RawRho — Type
RawRhoCalculates redundancy (ρ, raw beta diversity) of all of the individuals in a metacommunity, and caches them for subsequent analysis. This is a subtype of PowerMeanMeasure, meaning that all composite diversity measures are simple powermeans of the individual measures.
Per subcommunity, it is the redundancy of that subcommunity: the extent to which the diversity of the metacommunity would be preserved if the subcommunity were lost. It takes its minimum of 1 when nothing resembling the subcommunity remains elsewhere, so that losing it would lose its diversity entirely. Averaged over the subcommunities it gives their average redundancy, which rises towards the effective number of subcommunities — the Hill number of their weights — as they become more alike, reaching the number of subcommunities itself only when they are also of equal size. It is the reciprocal of RawBeta.
Constructor arguments:
meta: a Metacommunity
Diversity.RelativeEntropyMeasure — Type
RelativeEntropyMeasureThis abstract DiversityMeasure subtype is the supertype of all diversity measures which are relative entropy-based diversity measures. RelativeEntropyMeasure subtypes allow you to calculate and cache any kind of diversity of a metacommunity.
Diversity.Species — Type
SpeciesA subtype of AbstractTypes where all species are completely distinct. This type is the simplest AbstractTypes subtype, which identifies all species as unique and completely distinct from each other.
Diversity.Subcommunities — Type
Subcommunities(num)AbstractPartition subtype with multiple subcommunities.
Diversity.Taxonomy — Type
TaxonomyA subtype of AbstractTypes with similarity between related taxa, creating taxonomic similarity matrices.
Diversity.UniqueTypes — Type
UniqueTypesA subtype of AbstractTypes where all individuals are completely distinct. This type is the simplest AbstractTypes subtype, which identifies all individuals as unique and completely distinct from each other.
Diversity.GeneticType — Function
GeneticType(dat; distance, transform, k, normalise)Construct a genetic similarity type from genetic data dat. With BioSequences loaded, dat may be a vector of BioSequences (the sequence path); with PopGen loaded, dat may be a PopGen.PopData object (the VCF path). distance selects the pairwise distance method and transform (:linear or :exponential), k and normalise control the distance-to-similarity conversion.
Diversity.addedoutputcols — Function
addedoutputcols(m::AbstractAssemblage)
addedoutputcols(t::AbstractTypes)Returns the name of any additional columns needed to disambiguate the diversity type used.
Diversity.calcsimilarity — Method
calcsimilarity(t::AbstractTypes, scale::Real)Retrieves (and possibly calculates) a similarity matrix from t.
Diversity.countsubcommunities — Function
countsubcommunities(m::AbstractAssemblage)
countsubcommunities(p::AbstractPartition)Returns number of subcommunities in an AbstractPartition object or the AbstractAssemblage containing it.
Diversity.counttypes — Function
counttypes(m::AbstractAssemblage[, raw::Bool = false])
counttypes(t::AbstractTypes[, raw::Bool = false])Returns number of types in an AbstractTypes object or the AbstractAssemblage containing it. raw determines whether to count the number of raw or processed types, which varies, for instance, when the types are determined by a phylogeny.
Diversity.diversity — Method
Calculates subcommunity and metacommunity diversities
Calculates any diversity of a Metacommunity for a series of orders, repesented as one or a vector of qs.
Arguments:
dls: an iterable collection of DiversityLevelsdms: an iterable collection of DiversityMeasuresmeta: a Metacommunityqs: single number or vector of values of parameter q
Returns:
A vector containing all of the diversity levels of all of the requested diversities.
Diversity.getASCIIName — Method
getASCIIName(dm::DiversityMeasure)Return the ASCII name of the DiversityMeasure
Arguments:
dm: DiversityMeasure
Returns:
- String containing simple ASCII name of DiversityMeasure
Diversity.getFullName — Function
getFullName(dm::DiversityMeasure)Return the full name of the DiversityMeasure.
Arguments:
dm: DiversityMeasure
Returns:
- String containing full descriptive name of DiversityMeasure
Diversity.getName — Function
getName(dm::DiversityMeasure)Return the character corresponding to the DiversityMeasure.
Arguments:
dm: DiversityMeasure
Returns:
- String containing unicode (greek) name of DiversityMeasure.
Diversity.getabundance — Function
getabundance(m::AbstractAssemblage, raw::Bool)Returns the abundances array of the metacommunity.
Diversity.getaddedoutput — Function
getaddedoutput(::AbstractTypes)Returns the contents of any additional columns to be added to outputs.
Diversity.getdiversityname — Function
getdiversityname(m::AbstractAssemblage)
getdiversityname(t::AbstractTypes)Returns the name of the diversity type used.
Diversity.getmetaabundance — Function
getmetaabundance(m::AbstractAssemblage)Returns the metacommunity abundances of the metacommunity.
Diversity.getmetaordinariness! — Method
getmetaordinariness!(m::AbstractAssemblage)Returns (and possibly calculates) the ordinariness of the metacommunity as a whole.
Diversity.getordinariness! — Method
getordinariness!(m::AbstractAssemblage)Returns (and possibly calculates) the ordinariness array of the subcommunities.
Diversity.getpartition — Method
getpartition(m::AbstractAssemblage)Returns the AbstractPartition component of the metacommunity.
Diversity.getsubcommunitynames — Function
getsubcommunitynames(m::AbstractAssemblage)
getsubcommunitynames(p::AbstractPartition)Returns the names of the subcommunities in an AbstractPartition object or the AbstractAssemblage containing it.
Diversity.gettypenames — Function
gettypenames(m::AbstractAssemblage[, raw::Bool = false])
gettypenames(t::AbstractTypes[, raw::Bool = false])Returns the names of the types of the AbstractTypes object or the AbstractAssemblage containing it. raw determines whether to count the number of raw or processed types, which varies, for instance, when the types are determined by a phylogeny.
Diversity.gettypes — Method
gettypes(m::AbstractAssemblage)Returns the AbstractTypes component of the metacommunity.
Diversity.getweight — Method
getweight(m::AbstractAssemblage)Returns the subcommunity weights of the metacommunity.
Diversity.hassimilarity — Function
hassimilarity(t::AbstractAssemblage)
hassimilarity(t::AbstractThings)Is there similarity of some non-trivial type in the object?
Diversity.inddiv — Function
inddiv(measure::DiversityMeasure, q::Real)
inddiv(measure::DiversityMeasure, qs::AbstractVector{Real})Takes a diversity measure and single order or vector of orders, and returns a DataFrame containing the individual diversities for those values.
Arguments:
dm: DiversityMeasureq/qs: a single order or a vector of orders
Returns:
- Returns individual diversities of
dmfor a single orderqor a vector of orderqs.
Diversity.meta_gamma — Method
meta_gamma(meta::AbstractAssemblage, qs)Calculates metacommunity similarity-sensitive diversity — the diversity of the metacommunity taken as a whole, ignoring how it is divided. It is the average of the subcommunity contributions sub_gamma.
Arguments:
meta: a Metacommunityqs: a single order or a vector of orders
Returns:
- A DataFrame of diversities, one row per order.
Diversity.metadiv — Function
metadiv(measure::DiversityMeasure, q::Real)
metadiv(measure::DiversityMeasure, qs::AbstractVector{Real})Takes a diversity measure and single order or vector of orders, and calculates and returns the metacommunity diversities for those values.
Arguments:
dm: DiversityMeasureq/qs: a single order or a vector of orders
Returns:
- Returns metacommunity diversities of
dmfor a single orderqor a vector of orderqs.
Diversity.norm_meta_alpha — Method
norm_meta_alpha(meta::AbstractAssemblage, qs)Calculates the average similarity-sensitive diversity of the subcommunities, each taken in isolation. It is invariant under shattering — subdividing a subcommunity into identical parts does not change it.
Arguments:
meta: a Metacommunityqs: a single order or a vector of orders
Returns:
- A DataFrame of diversities, one row per order.
Diversity.norm_meta_beta — Method
norm_meta_beta(meta::AbstractAssemblage, qs)Calculates the effective number of distinct subcommunities. When they are completely distinct it reaches qD(w, q), the Hill number of their weights — which is the number of subcommunities itself only when they are also of equal size. It is invariant under shattering.
Arguments:
meta: a Metacommunityqs: a single order or a vector of orders
Returns:
- A DataFrame of diversities, one row per order.
Diversity.norm_meta_rho — Method
norm_meta_rho(meta::AbstractAssemblage, qs)Calculates the average representativeness of the subcommunities.
Arguments:
meta: a Metacommunityqs: a single order or a vector of orders
Returns:
- A DataFrame of diversities, one row per order.
Diversity.norm_sub_alpha — Method
norm_sub_alpha(meta::AbstractAssemblage, qs)Calculates the similarity-sensitive diversity of each subcommunity in isolation — the diversity each subcommunity would have if it were the whole of the community.
Arguments:
meta: a Metacommunityqs: a single order or a vector of orders
Returns:
- A DataFrame of diversities, one row per subcommunity per order.
Diversity.norm_sub_beta — Method
norm_sub_beta(meta::AbstractAssemblage, qs)Calculates the per-subcommunity estimate of the effective number of distinct subcommunities. It is high when a subcommunity is both distinctive and small, and is the reciprocal of norm_sub_rho.
Arguments:
meta: a Metacommunityqs: a single order or a vector of orders
Returns:
- A DataFrame of diversities, one row per subcommunity per order.
Diversity.norm_sub_rho — Method
norm_sub_rho(meta::AbstractAssemblage, qs)Calculates the representativeness of individual subcommunities — how typical each subcommunity is of the metacommunity as a whole. A subcommunity holding a fixed fraction of equally abundant types has representativeness equal to that fraction.
Arguments:
meta: a Metacommunityqs: a single order or a vector of orders
Returns:
- A DataFrame of diversities, one row per subcommunity per order.
Diversity.qD — Function
qDCalculates Hill / naive-similarity diversity of order(s) qs of a population with given relative proportions.
Arguments:
proportions: relative proportions of different types in populationqs: single number or vector of orders of diversity measurement
Returns:
- Diversity of order qs (single number or vector of diversities)
Diversity.qDZ — Function
qDZCalculates Leinster-Cobbold / similarity-sensitive diversity of >= 1 order(s) qs of a population with given relative proportions, and similarity matrix Z.
Arguments:
proportions: relative proportions of different types in a populationqs: single number or vector of orders of diversity measurementZ: similarity matrix
Returns:
Diversity of order qs (single number or vector of diversities)
Diversity.raw_meta_alpha — Method
raw_meta_alpha(meta::AbstractAssemblage, qs)Calculates naive-community metacommunity diversity — the diversity the metacommunity would have if its subcommunities shared no types and no similarity. It is an upper bound on the true metacommunity diversity meta_gamma.
Arguments:
meta: a Metacommunityqs: a single order or a vector of orders
Returns:
- A DataFrame of diversities, one row per order.
Diversity.raw_meta_beta — Method
raw_meta_beta(meta::AbstractAssemblage, qs)Calculates the average distinctiveness of the subcommunities. It can be read as a kind of turnover between each subcommunity and the rest of the metacommunity.
Arguments:
meta: a Metacommunityqs: a single order or a vector of orders
Returns:
- A DataFrame of diversities, one row per order.
Diversity.raw_meta_rho — Method
raw_meta_rho(meta::AbstractAssemblage, qs)Calculates the average redundancy of the subcommunities. It takes its minimum of 1 when the subcommunities have nothing in common, and rises towards the effective number of subcommunities — the Hill number of their weights — as they become more alike, reaching the number of subcommunities itself only when they are also of equal size.
Arguments:
meta: a Metacommunityqs: a single order or a vector of orders
Returns:
- A DataFrame of diversities, one row per order.
Diversity.raw_sub_alpha — Method
raw_sub_alpha(meta::AbstractAssemblage, qs)Calculates the per-subcommunity estimate of naive-community metacommunity diversity — the diversity of the metacommunity that this subcommunity alone would imply, if no type were shared with any other subcommunity. It is norm_sub_alpha per individual, rescaled by the size of the subcommunity.
Arguments:
meta: a Metacommunityqs: a single order or a vector of orders
Returns:
- A DataFrame of diversities, one row per subcommunity per order.
Diversity.raw_sub_beta — Method
raw_sub_beta(meta::AbstractAssemblage, qs)Calculates the distinctiveness of individual subcommunities — how much of each subcommunity is unlike the rest of the metacommunity, whether through types found nowhere else or through low similarity to the types that are. It is the reciprocal of raw_sub_rho.
Arguments:
meta: a Metacommunityqs: a single order or a vector of orders
Returns:
- A DataFrame of diversities, one row per subcommunity per order.
Diversity.raw_sub_rho — Method
raw_sub_rho(meta::AbstractAssemblage, qs)Calculates the redundancy of individual subcommunities — the extent to which the diversity of the metacommunity would survive the loss of each subcommunity. It takes its minimum of 1 when nothing resembling the subcommunity remains elsewhere.
Arguments:
meta: a Metacommunityqs: a single order or a vector of orders
Returns:
- A DataFrame of diversities, one row per subcommunity per order.
Diversity.sub_gamma — Method
sub_gamma(meta::AbstractAssemblage, qs)Calculates the contribution per individual in a subcommunity toward metacommunity diversity. It combines the subcommunity's own diversity with the rarity of its types in the metacommunity, so a subcommunity of a few very rare types contributes heavily however dull it looks in isolation.
Arguments:
meta: a Metacommunityqs: a single order or a vector of orders
Returns:
- A DataFrame of diversities, one row per subcommunity per order.
Diversity.subdiv — Function
subdiv(measure::DiversityMeasure, q::Real)
subdiv(measure::DiversityMeasure, qs::AbstractVector{Real})Takes a diversity measure and single order or vector of orders, and calculates and returns the subcommunity diversities for those values.
Arguments:
dm: DiversityMeasureq/qs: a single order or a vector of orders
Returns:
- Returns subcommunity diversities of
dmfor a single orderqor a vector of orderqs.
Diversity.vcf_dataframe — Function
vcf_dataframe(dat)Convert genetic data dat (a PopGen.PopData object) into a DataFrame laid out like the body of a VCF file (a FORMAT column followed by one genotype column per sample). A method is provided by the DiversityPopGenExt extension. This is the structure consumed by rdiversity's gen2dist(), so the same PopData can drive both Julia and R genetic diversity calculations.
Diversity.ShortNames — Module
Diversity.ShortNames submoduleWe do not directly export ᾱ, α, β̄, β, ρ̄, ρ, γ as they're too short. γ actually can't be exported like this - it'll always just be Shortnames.γ, so we export Γ instead.
All of these can only be accessed via Diversity.ShortNames.
Private functions in module Diversity:
Diversity.SubAssemblage — Type
SubAssemblage(types, partition, occurrences)A subset of a metacommunity, as returned by view. It is an EcoBase AbstractAssemblage rather than a Metacommunity, which is what lets it be a genuine view: it aliases the parent's abundances rather than copying them, and it carries them unnormalised, since only a Metacommunity requires them to sum to one. The diversity measures still work on it, because abundances are normalised when they are read.
Diversity._getmeta — Method
_getmeta(dm::DiversityMeasure)Return the metacommunity belonging to the DiversityMeasure.
Diversity.powermean — Function
powermeanCalculates the weighted powermean of a series of numbers
Calculates orderth power mean of values, weighted by weights. By default, weights are equal and order is 1, so this is just the arithmetic mean.
Arguments:
values: values for which to calculate meanorder[s]: order[s] of power meanweights: weights of elements, normalised to 1 inside function
Returns:
- weighted power mean(s)
Diversity.APIDiversity.DiversityDiversity.EcologyDiversity.HillDiversity.JostDiversity.ShortNamesDiversity.individualDiversityDiversity.metacommunityDiversityDiversity.subcommunityDiversityDiversity.API.AbstractMetacommunityDiversity.API.AbstractPartitionDiversity.API.AbstractTypesDiversity.AbstractGeneticDiversity.AbstractPhyloTypesDiversity.DiversityLevelDiversity.DiversityMeasureDiversity.GammaDiversity.GeneralTypesDiversity.GeneralTypesDiversity.MetacommunityDiversity.NormalisedAlphaDiversity.NormalisedBetaDiversity.NormalisedRhoDiversity.OnecommunityDiversity.PhyloBranchesDiversity.PowerMeanMeasureDiversity.RawAlphaDiversity.RawBetaDiversity.RawRhoDiversity.RelativeEntropyMeasureDiversity.SpeciesDiversity.SubAssemblageDiversity.SubcommunitiesDiversity.TaxonomyDiversity.UniqueTypesDiversity.API._addedoutputcolsDiversity.API._calcabundanceDiversity.API._calcordinarinessDiversity.API._calcsimilarityDiversity.API._countsubcommunitiesDiversity.API._counttypesDiversity.API._getabundanceDiversity.API._getaddedoutputDiversity.API._getdiversitynameDiversity.API._getmetaabundanceDiversity.API._getmetaordinariness!Diversity.API._getordinariness!Diversity.API._getpartitionDiversity.API._getscaleDiversity.API._getsubcommunitynamesDiversity.API._gettypenamesDiversity.API._gettypesDiversity.API._getweightDiversity.API._subsetpartitionDiversity.API._subsettypesDiversity.API.floattypesDiversity.API.mcmatchDiversity.API.typematchDiversity.Ecology.faith_pdDiversity.Ecology.generalisedfaith_pdDiversity.Ecology.generalisedjaccardDiversity.Ecology.generalisedrichnessDiversity.Ecology.generalisedshannonDiversity.Ecology.generalisedsimpsonDiversity.Ecology.gowerDiversity.Ecology.jaccardDiversity.Ecology.pielouDiversity.Ecology.richnessDiversity.Ecology.shannonDiversity.Ecology.simpsonDiversity.GeneticTypeDiversity.Hill.hillnumberDiversity.Jost.jostalphaDiversity.Jost.jostbetaDiversity._getmetaDiversity.addedoutputcolsDiversity.calcsimilarityDiversity.countsubcommunitiesDiversity.counttypesDiversity.diversityDiversity.getASCIINameDiversity.getFullNameDiversity.getNameDiversity.getabundanceDiversity.getaddedoutputDiversity.getdiversitynameDiversity.getmetaabundanceDiversity.getmetaordinariness!Diversity.getordinariness!Diversity.getpartitionDiversity.getsubcommunitynamesDiversity.gettypenamesDiversity.gettypesDiversity.getweightDiversity.hassimilarityDiversity.inddivDiversity.meta_gammaDiversity.metadivDiversity.norm_meta_alphaDiversity.norm_meta_betaDiversity.norm_meta_rhoDiversity.norm_sub_alphaDiversity.norm_sub_betaDiversity.norm_sub_rhoDiversity.powermeanDiversity.qDDiversity.qDZDiversity.raw_meta_alphaDiversity.raw_meta_betaDiversity.raw_meta_rhoDiversity.raw_sub_alphaDiversity.raw_sub_betaDiversity.raw_sub_rhoDiversity.sub_gammaDiversity.subdivDiversity.vcf_dataframe