Coming from vegan
Many people arriving here already measure diversity with R's vegan. This page maps what you know onto what is here, and — as importantly — says what is deliberately absent and why.
Rows marked ✅ are checked by the test suite on every run: test/run_rcall.jl computes both sides and asserts they agree. Rows marked ○ are our reading of vegan's documentation and have not been machine-checked — if one is wrong, please tell us.
Before the table: three differences that matter more
Read What this package does differently first if you have not. In short:
- Beta diversity is not pairwise here. There is no
distobject to get back. - Abundances are relative to the whole metacommunity, not normalised per site.
α × β = γdoes not hold, except atq = 1. There is noadipart/multipartequivalent, on purpose.
Everything below makes more sense once those are in place.
Alpha diversity of single communities
| vegan | here | |
|---|---|---|
specnumber(x) | richness(x) | ○ |
diversity(x, "shannon") | shannon(x) — returns the entropy, as vegan does | ○ |
diversity(x, "simpson") | simpson(x) | ○ |
diversity(x, "invsimpson") | meta_gamma(mc, 2), or hillnumber(x, 2) | ○ |
renyi(x, scales, hill = TRUE) | hillnumber(x, qs), or any measure over a vector of q | ○ |
renyi(x, scales) | log.(hillnumber(x, qs).diversity) | ○ |
fisher.alpha, rarefy, specaccum | No equivalent — this package measures diversity, it does not estimate unseen richness |
julia> using Diversity, Diversity.Ecology, Diversity.Hilljulia> community = [10, 20, 20, 0, 3];julia> richness(community).diversity1-element Vector{Int64}: 4julia> shannon(community).diversity1-element Vector{Float64}: 1.2127262769841136julia> hillnumber(community, [0, 1, 2]).diversity3-element Vector{Float64}: 3.999999999999999 3.362639654438873 3.090209020902091
richness counts the types actually present, so the zero above does not contribute — the answer is 4, not 5. That is q = 0 behaving as it should.
Dissimilarity between two communities
These are the genuinely pairwise measures, and they behave as vegan's do — but they take exactly two subcommunities rather than returning a matrix over many.
| vegan | here | |
|---|---|---|
vegdist(x, "jaccard") | jaccard(x) | ✅ |
vegdist(x, "gower") (pre-2.7) | gower(x, countzeros = true) | ✅ |
vegdist(x, "altGower") | gower(x, countzeros = false) | ✅ |
vegdist with other methods | not provided |
julia> two = [2 2; 2 0; 0 2] ./ 83×2 Matrix{Float64}: 0.25 0.25 0.25 0.0 0.0 0.25julia> jaccard(two).diversity1-element Vector{Float64}: 0.3333333333333333julia> gower(two, countzeros = true).diversity1-element Vector{Float64}: 0.6666666666666666julia> gower(two, countzeros = false).diversity1-element Vector{Float64}: 0.16666666666666666
Note: vegan 2.7 changed method = "gower", range-standardising columns first and dropping tied columns from the denominator — which returns NA for two identical samples. This package keeps the classic Gower (1971) reading, so countzeros = true matches old vegan. The cross-validation in test/run_rcall.jl reproduces old vegan explicitly for this reason.
Partitioning across many subcommunities
This is where the packages genuinely diverge, and where the extra capability is.
| vegan | here | |
|---|---|---|
adipart (additive α + β = γ) | deliberately absent | |
multipart (multiplicative α × β = γ) | deliberately absent except at q = 1 | |
betadiver(x, method) | no equivalent — pairwise beta | |
betadisper | no equivalent | |
| — | norm_sub_rho — how representative each subcommunity is | |
| — | raw_sub_beta — how distinctive each subcommunity is | |
| — | raw_sub_rho — how redundant each subcommunity is | |
| — | sub_gamma — each subcommunity's contribution to the whole |
The four rows with no vegan equivalent are the point of the package. Rather than one number for "how much turnover is there overall", you get a value per subcommunity, comparable across subcommunities, telling you which sites are distinctive, which are representative, and which contribute most to the diversity of the whole. See Building a metacommunity for a worked example that picks out each in turn.
julia> sites = [10 0 0 5; 10 10 0 5; 0 10 10 5; 0 0 10 5]4×4 Matrix{Int64}: 10 0 0 5 10 10 0 5 0 10 10 5 0 0 10 5julia> mc = Metacommunity(sites)Metacommunity{Float64, Matrix{Int64}, Matrix{Float64}, UniqueTypes, Subcommunities} with 4 species in 4 subcommunities measuring Unique diversity. Species names: 1, 2, 3, 4 Subcommunity names: 1, 2, 3, 4julia> norm_sub_rho(mc, 1).diversity # the last site is the most representative4-element Vector{Float64}: 0.48412291827592707 0.625 0.48412291827592707 0.9682458365518543julia> raw_sub_beta(mc, 1).diversity # and the least distinctive4-element Vector{Float64}: 0.5163977794943222 0.4 0.5163977794943222 0.25819888974716115
Similarity between types
vegan treats species as wholly distinct, then handles functional or phylogenetic structure through separate machinery. Here it is one argument.
| vegan | here | |
|---|---|---|
taxa2dist + taxondive | a similarity matrix Z, via GeneralTypes | ○ |
treedive, treedist | Phylogenetic diversity with PhyloBranches | ○ |
| — | Genetic diversity from sequences or a VCF |
Every measure in the package takes similarity, so there is no separate set of functions for "functional diversity" or "phylogenetic diversity" — the same norm_sub_rho answers the taxonomic, functional, phylogenetic and genetic version of the question depending only on the Z you supply.
Data preparation
| vegan | here | |
|---|---|---|
decostand(x, "total") | not needed — abundances are normalised on construction | |
| sites as rows | types as rows, subcommunities as columns — the transpose of vegan | |
| counts | passed directly; integers are normalised silently |
Note: The orientation is transposed relative to vegan, which is the single most common early mistake. vegan wants sites × species; a Metacommunity wants types × subcommunities. If your diversity values look implausible, check that first.
- Diversity.API
- Diversity.Ecology
- The framework
- Genetic diversity
- Diversity.Hill
- Diversity.jl
- Diversity.Jost
- Building a metacommunity
- Phylogenetic diversity
- Coming from vegan
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