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.

How reliable is each row?

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:

  1. Beta diversity is not pairwise here. There is no dist object to get back.
  2. Abundances are relative to the whole metacommunity, not normalised per site.
  3. α × β = γ does not hold, except at q = 1. There is no adipart/multipart equivalent, on purpose.

Everything below makes more sense once those are in place.

Alpha diversity of single communities

veganhere
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, specaccumNo equivalent — this package measures diversity, it does not estimate unseen richness
julia> using Diversity, Diversity.Ecology, Diversity.Hill
julia> community = [10, 20, 20, 0, 3];
julia> richness(community).diversity1-element Vector{Int64}: 4
julia> shannon(community).diversity1-element Vector{Float64}: 1.2127262769841136
julia> 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.

veganhere
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 methodsnot provided
julia> two = [2 2; 2 0; 0 2] ./ 83×2 Matrix{Float64}:
 0.25  0.25
 0.25  0.0
 0.0   0.25
julia> jaccard(two).diversity1-element Vector{Float64}: 0.3333333333333333
julia> gower(two, countzeros = true).diversity1-element Vector{Float64}: 0.6666666666666666
julia> 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.

veganhere
adipart (additive α + β = γ)deliberately absent
multipart (multiplicative α × β = γ)deliberately absent except at q = 1
betadiver(x, method)no equivalent — pairwise beta
betadisperno 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  5
julia> 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, 4
julia> norm_sub_rho(mc, 1).diversity # the last site is the most representative4-element Vector{Float64}: 0.48412291827592707 0.625 0.48412291827592707 0.9682458365518543
julia> 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.

veganhere
taxa2dist + taxondivea similarity matrix Z, via GeneralTypes
treedive, treedistPhylogenetic 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

veganhere
decostand(x, "total")not needed — abundances are normalised on construction
sites as rowstypes as rows, subcommunities as columns — the transpose of vegan
countspassed 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.