Diversity.jl
Provides functionality for measuring alpha, beta and gamma diversity of metacommunities (e.g. ecosystems) and their constituent subcommunities.
https://github.com/ecojulia/diversity.jl
Category: Biosphere
Sub Category: Biodiversity Analysis and Metrics
Keywords
biodiversity diversity-measurement ecology julia partitioning-diversity phylogenetic-diversity
Keywords from Contributors
parallel transforms measurements numerical controls optimize hybrid-differential-equations dataframes units ida
Last synced: about 17 hours ago
JSON representation
Repository metadata
Julia package for diversity measurement
- Host: GitHub
- URL: https://github.com/ecojulia/diversity.jl
- Owner: EcoJulia
- License: bsd-2-clause
- Created: 2014-08-31T14:30:13.000Z (over 10 years ago)
- Default Branch: dev
- Last Pushed: 2024-11-18T18:20:49.000Z (5 months ago)
- Last Synced: 2025-04-22T12:05:01.235Z (5 days ago)
- Topics: biodiversity, diversity-measurement, ecology, julia, partitioning-diversity, phylogenetic-diversity
- Language: Julia
- Homepage: http://docs.ecojulia.org/Diversity.jl/
- Size: 2.42 MB
- Stars: 33
- Watchers: 4
- Forks: 9
- Open Issues: 7
- Releases: 25
-
Metadata Files:
- Readme: README.md
- Changelog: NEWS.md
- License: LICENSE
- Citation: CITATION.bib
- Codemeta: codemeta.json
- Zenodo: .zenodo.json
README.md
Diversity
A package for measuring and partitioning diversity
Documentation | Build Status | DOI |
---|---|---|
Summary
Diversity is a Julia package that
provides functionality for measuring alpha, beta and gamma diversity
of metacommunities (e.g. ecosystems) and their constituent
subcommunities. It uses the diversity measures described in the arXiv
paper arXiv:1404.6520 (q-bio.QM),
How to partition diversity. It also provides a series of other
older diversity measures through sub-modules. Currently
these are all ecological diversity measures, but this will be
expanded through interfacing to EcoJulia and BioJulia.
This package is in beta now, but is cross-validated against our R
package boydorr/rdiversity, which is developed
independently, so please raise an issue if you find any
problems. We now use a DataFrame as the common output format for all
of the diversity calculations to provide consistency with our R
package rdiversity. The code is not
optimised for speed at the moment due to the substantial changes that
have happened to it under the hood, and the Phylogenetics submodule is
also recently revised, and may need further improvements.
Installation
The package is registered in the General
registry on v1.x and so can be
installed with add
. For example on Julia v1.10:
(@v1.10) pkg> add Diversity
Resolving package versions...
Updating `~/.julia/environments/v1.10/Project.toml`
[d3d5718d] + Diversity v0.5.15
Updating `~/.julia/environments/v1.10/Manifest.toml`
[d3d5718d] + Diversity v0.5.15
(@v1.10) pkg>
Project Status
The package is confirmed to build and work against Julia v1.9 and the current
release and the latest release on Linux, macOS, and Windows. It is also tested
against nightly.
Contributing and Questions
Contributions are very welcome, as are feature requests and suggestions.
Please open an issue if you encounter any problems or would
just like to ask a question.
Usage
Diversity Measures
The main 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
arXiv:1404.6520 (q-bio.QM)). 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 ascii names
(e.g. NormalisedAlpha()), which are. We also provide a general
function for extract any diversity measure for a series of
subcommunity relative abundances.
Getting started
Before calculating diversity a Metacommunity
object must be created. This object contains all the information needed to calculate diversity.
# Load the package into Julia
using Diversity
# Example population
pop = [1 1 0; 2 0 0; 3 1 4]
pop = pop / sum(pop)
# Create Metacommunity object
meta = Metacommunity(pop)
Calculating diversity
First we need to calculate the low-level diversity component seperately, by passing a metacommunity
object to the appropriate function; RawAlpha()
, NormalisedAlpha()
, RawBeta()
, NormalisedBeta()
, RawRho()
, NormalisedRho()
, or Gamma()
.
# First, calculate the normalised alpha component
component = NormalisedAlpha(meta)
Afterwhich, subdiv()
or metadiv()
are used to calculate subcommunity or metacommunity diversity, respectively (since both subcommunity and metacommunity diversity measures are transformations of the same low-level components, this is computationally more efficient).
# Then, calculate species richness of the subcommunities
subdiv(component, 0)
# or the average (alpha) species richness across the whole population
metadiv(component, 0)
# We can also generate a diversity profile by calculating multiple q-values simultaneously
df = subdiv(component, 0:30)
In some instances, it may be useful to calculate all subcommunity (or metacommunity) measures. In which case, a Metacommunity
object may be passed directly to subdiv()
or metadiv()
:
# To calculate all subcommunity diversity measures
subdiv(meta, 0:2)
# To calculate all metacommunity diversity measures
metadiv(meta, 0:2)
Alternatively, if computational efficiency is not an issue, a single measure of diversity may be calculated directly by calling a wrapper function:
norm_sub_alpha(meta, 0:2)
A complete list of these functions is shown below:
raw_sub_alpha()
: per-subcommunity estimate of naive-community metacommunity diversitynorm_sub_alpha()
: similarity-sensitive diversity of each subcommunity in isolationraw_sub_rho()
: redundancy of individual subcommunitiesnorm_sub_rho()
: representativeness of individual subcommunitiesraw_sub_beta()
: distinctiveness of individual subcommunitiesnorm_sub_beta()
: per-subcommunity estimate of effective number of distinct subcommunitiessub_gamma()
: contribution per individual in a subcommunity toward metacommunity diversityraw_meta_alpha()
: naive-community metacommunity diversitynorm_meta_alpha()
: average similarity-sensitive diversity of subcommunitiesraw_meta_rho()
: average redundancy of subcommunitiesnorm_meta_rho()
: average representativeness of subcommunitiesraw_meta_beta()
: average distinctiveness of subcommunitiesnorm_meta_beta()
: effective number of distinct subcommunitiesmeta_gamma()
: metacommunity similarity-sensitive diversity
Phylogenetic diversity
Phylogenetic diversity (described here) is
automatically included in the Diversity module when the Phylo
package
is loaded. Documentation for these diversity measures can be found
here.
The phylogenetics code relies on the Phylo package to
generate trees to incorporate into the diversity code, and the
ppropriate code will be created when both main packages are loaded:
julia> using Diversity, Phylo
julia> communities = [4 1; 3 2; 1 0; 0 1] / 12;
julia> nt = rand(Nonultrametric(4))
RootedTree with 4 tips, 7 nodes and 6 branches.
Leaf names are tip 1, tip 2, tip 4 and tip 3
julia> metaphylo = Metacommunity(communities, PhyloBranches(nt));
julia> raw_meta_rho(metaphylo, [1, 2])
2×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 │ Phylogenetic Branch │ RawRho │ 1 │ types │ │ metacommunity │ │ 1.7787 │
│ 2 │ Phylogenetic Branch │ RawRho │ 2 │ types │ │ metacommunity │ │ 1.66749 │
The package also provides some other sub-modules for related measures:
Diversity.Ecology
Many existing ecological diversity measures can be derived from our
diversity measures, and so we provide them in the Diversity.Ecology
submodule along with generalised versions of them that relate to our
general measures of alpha, beta and gamma diversity at subcommunity
and metacommunity levels. The generalisations of species richness,
Shannon entropy and Simpson's index are the only standard measures we
are aware of whose subcommunity components sum directly to the
corresponding metacommunity measure (although note that Simpson's
index decreases for increased diversity, so small components are more
diverse). Documentation for these diversity measures can be found
here.
Diversity.Hill
Hill numbers are found in the
Diversity.Hill sub-module.
Documentation for these diversity measures can be found
here.
Diversity.Jost
Lou Jost's
diversity
measures are
found in the Diversity.Jost sub-module.
Documentation for these diversity measures is
here.
Documentation
Documentation is generated by the Base documentation in Julia and
online via the
Documenter package.
Using the docs
Accessing the documentation in Julia is easy:
using Diversity
# Returns any documentation for the subdiv() function
?subdiv
The documentation is also available online.
Latest release
The online documentation for the current stable release is
here.
Development branch
The online documentation for the latest dev (unreleased) branch is
here.
Citation (CITATION.bib)
@article{Diversity.jl-2016, author = {Reeve, Richard and Leinster, Tom and Cobbold, Christina A and Thompson, Jill and Brummitt, Neil A and Mitchell, Sonia N and Matthews, Louise}, title = {How to partition diversity}, journal = {ArXiv e-prints}, archivePrefix = "arXiv", eprint = {1404.6520}, eprinttype = {arxiv}, primaryClass = "q-bio.QM", keywords = {Quantitative Biology - Quantitative Methods}, year = 2016, month = dec } @phdthesis{Diversity.jl-2019, author = {Mitchell, Sonia N}, title = {The measurement, dynamics, and interpretation of biological diversity}, school = {University of Glasgow}, year = 2019, address = {Glasgow, UK} }
Owner metadata
- Name: EcoJulia
- Login: EcoJulia
- Email:
- Kind: organization
- Description:
- Website: https://ecojulia.org/
- Location:
- Twitter:
- Company:
- Icon url: https://avatars.githubusercontent.com/u/22506369?v=4
- Repositories: 16
- Last ynced at: 2024-06-24T12:50:03.448Z
- Profile URL: https://github.com/EcoJulia
GitHub Events
Total
- Issue comment event: 1
- Pull request event: 1
- Create event: 1
Last Year
- Issue comment event: 1
- Pull request event: 1
- Create event: 1
Committers metadata
Last synced: 6 days ago
Total Commits: 814
Total Committers: 10
Avg Commits per committer: 81.4
Development Distribution Score (DDS): 0.154
Commits in past year: 85
Committers in past year: 2
Avg Commits per committer in past year: 42.5
Development Distribution Score (DDS) in past year: 0.012
Name | Commits | |
---|---|---|
Richard Reeve | g****t@r****t | 689 |
richardreeve | r****e@g****k | 90 |
Isaac Peetoom Heida | i****a@g****m | 12 |
Tony Kelman | t****y@k****t | 9 |
Claire Harris | c****s@b****k | 7 |
Michael Krabbe Borregaard | m****d@s****k | 2 |
github-actions[bot] | 4****] | 2 |
Michael Hatherly | m****y@g****m | 1 |
Elliot Saba | s****t@g****m | 1 |
dependabot[bot] | 4****] | 1 |
Committer domains:
- snm.ku.dk: 1
- bioss.ac.uk: 1
- kelman.net: 1
- glasgow.ac.uk: 1
- richardreeve.net: 1
Issue and Pull Request metadata
Last synced: 1 day ago
Total issues: 19
Total pull requests: 34
Average time to close issues: 7 months
Average time to close pull requests: about 2 months
Total issue authors: 6
Total pull request authors: 11
Average comments per issue: 4.95
Average comments per pull request: 4.09
Merged pull request: 30
Bot issues: 0
Bot pull requests: 4
Past year issues: 0
Past year pull requests: 2
Past year average time to close issues: N/A
Past year average time to close pull requests: about 11 hours
Past year issue authors: 0
Past year pull request authors: 1
Past year average comments per issue: 0
Past year average comments per pull request: 0.5
Past year merged pull request: 1
Past year bot issues: 0
Past year bot pull requests: 2
Top Issue Authors
- richardreeve (13)
- PeetoomHeida (2)
- mkborregaard (1)
- peter1000 (1)
- kescobo (1)
- JuliaTagBot (1)
Top Pull Request Authors
- richardreeve (21)
- github-actions[bot] (2)
- dependabot[bot] (2)
- tkelman (2)
- mkborregaard (1)
- claireh93 (1)
- PeetoomHeida (1)
- soniamitchell (1)
- MichaelHatherly (1)
- staticfloat (1)
- EvoArt (1)
Top Issue Labels
- enhancement (4)
- testing (1)
- bug (1)
Top Pull Request Labels
- enhancement (2)
- dependencies (2)
- API (1)
- testing (1)
Package metadata
- Total packages: 1
-
Total downloads:
- julia: 3 total
- Total dependent packages: 1
- Total dependent repositories: 4
- Total versions: 19
juliahub.com: Diversity
Julia package for diversity measurement
- Homepage: http://docs.ecojulia.org/Diversity.jl/
- Documentation: https://docs.juliahub.com/General/Diversity/stable/
- Licenses: BSD-2-Clause
- Latest release: 0.5.15 (published 10 months ago)
- Last Synced: 2025-04-25T13:33:44.507Z (1 day ago)
- Versions: 19
- Dependent Packages: 1
- Dependent Repositories: 4
- Downloads: 3 Total
-
Rankings:
- Dependent repos count: 5.615%
- Forks count: 14.479%
- Average: 15.152%
- Stargazers count: 18.871%
- Dependent packages count: 21.644%
Dependencies
- julia-actions/setup-julia latest composite
- JuliaRegistries/TagBot v1 composite
- actions/checkout v2 composite
- julia-actions/setup-julia v1 composite
- actions/checkout v2 composite
- julia-actions/julia-buildpkg latest composite
- julia-actions/julia-runtest latest composite
- julia-actions/setup-julia v1 composite
- actions/checkout v2 composite
- codecov/codecov-action v1 composite
- coverallsapp/github-action master composite
- julia-actions/julia-buildpkg master composite
- julia-actions/julia-processcoverage v1 composite
- julia-actions/julia-runtest master composite
- julia-actions/setup-julia v1 composite
- r-lib/actions/setup-r master composite
- actions/checkout v2 composite
Score: 8.070906088787819