This package contains R functions to calculate taxonomic, functional, and phylogenetic diversity and site similarity through Hill Numbers. The underlying methods are based on Chao, Chiu and Jost 2014, Chiu & Chao 2014, and Chao, Chiu and Jost 2010 (phylogenetic diversity).
For each facet of diversity there are three functions: one for the
diversity of each site (alpha diversity), one for the decomposition of
diversity across all sites into gamma, alpha and beta diversity (with
site similarity), and one for all pairwise comparisons of sites. The
argument q sets how much weight is given to species
abundance: q = 0 ignores abundance (e.g., species
richness), q = 1 weighs species by their abundance
(exponential of Shannon entropy), and q = 2 gives more
weight to abundant species (inverse Simpson).
To install this package, run the following code:
install.packages("hillR")
# or install the development version (built from GitHub) from r-universe
install.packages("hillR", repos = c('https://daijiang.r-universe.dev', 'https://cloud.r-project.org'))dummy = FD::dummy
comm = dummy$abun
traits = dummy$trait
set.seed(123)
tree = ape::rtree(n = ncol(comm), tip.label = paste0("sp", 1:ncol(comm)))
library(hillR)hill_taxa(comm, q = 0) # taxonomic alpha diversity
## com1 com2 com3 com4 com5 com6 com7 com8 com9 com10
## 4 3 3 2 3 5 3 4 5 4
hill_func(comm, traits, q = 0) # functional alpha diversity
## com1 com2 com3 com4 com5 com6 com7
## Q 0.4214846 0.2848834 0.3254045 0.2620026 0.3984715 0.4427648 0.3228745
## FDis 0.3481687 0.1670560 0.2375808 0.1146261 0.3211366 0.3302330 0.2532751
## D_q 4.0000000 3.0000000 3.0000000 2.0000000 3.0000000 5.0000000 3.0000000
## MD_q 1.6859383 0.8546501 0.9762135 0.5240052 1.1954145 2.2138241 0.9686236
## FD_q 6.7437533 2.5639502 2.9286406 1.0480104 3.5862436 11.0691207 2.9058708
## com8 com9 com10
## Q 0.4045563 0.4515567 0.4177331
## FDis 0.2877931 0.3421687 0.3503927
## D_q 4.0000000 5.0000000 4.0000000
## MD_q 1.6182251 2.2577835 1.6709326
## FD_q 6.4729004 11.2889174 6.6837303
hill_phylo(comm, tree, q = 0) # phylogenetic alpha diversity
## com1 com2 com3 com4 com5 com6 com7 com8
## 5.430079 4.684280 4.461773 2.551395 5.830078 6.088533 4.763594 6.046474
## com9 com10
## 6.262164 5.080340hill_phylo() measures all sites on one shared reference
tree, the phylogeny of all species in comm, so values are
comparable across sites. To measure each site on the subtree of its own
species instead (the same as analyzing that site on its own), use
trim_to_site = TRUE:
hill_phylo(comm, tree, q = 0, trim_to_site = TRUE)
## com1 com2 com3 com4 com5 com6 com7 com8
## 5.430079 2.999013 4.461773 2.551395 5.727154 5.985609 4.763594 5.943549
## com9 com10
## 6.262164 4.977415hill_phylo_parti() and
hill_phylo_parti_pairwise() measure each comparison on the
phylogeny of the species in the sites being compared. See
?hill_phylo for details.
hill_taxa_parti(comm, q = 0) # taxonomic diversity across all sites
## q TD_gamma TD_alpha TD_beta M_homog local_similarity region_similarity
## 1 0 8 3.6 2.222222 0.45 0.8641975 0.3888889
hill_func_parti(comm, traits, q = 0) # functional diversity across all sites
## q raoQ_gamma FD_gamma FD_alpha FD_beta local_similarity region_similarity
## 1 0 0.4529152 29.66099 14.15941 2.09479 0.9889415 0.4720957
hill_phylo_parti(comm, tree, q = 0) # phylogenetic diversity across all sites
## q PD_gamma PD_alpha PD_beta local_similarity region_similarity
## 1 0 8.292885 5.119871 1.619745 0.9311395 0.574868# pairwise taxonomic diversity
hill_taxa_parti_pairwise(comm, q = 0, show_warning = FALSE, .progress = FALSE)
## # A tibble: 45 × 8
## q site1 site2 TD_gamma TD_alpha TD_beta local_similarity
## <dbl> <chr> <chr> <dbl> <dbl> <dbl> <dbl>
## 1 0 com1 com2 6 3.5 1.71 0.286
## 2 0 com1 com3 5 3.5 1.43 0.571
## 3 0 com2 com3 5 3 1.67 0.333
## 4 0 com1 com4 5 3 1.67 0.333
## 5 0 com2 com4 5 2.5 2 0
## 6 0 com3 com4 4 2.5 1.6 0.4
## 7 0 com1 com5 6 3.5 1.71 0.286
## 8 0 com2 com5 4 3 1.33 0.667
## 9 0 com3 com5 6 3 2 0
## 10 0 com4 com5 4 2.5 1.6 0.4
## # ℹ 35 more rows
## # ℹ 1 more variable: region_similarity <dbl>
# pairwise functional diversity
hill_func_parti_pairwise(comm, traits, q = 0, show_warning = FALSE, .progress = FALSE)
## # A tibble: 45 × 8
## q site1 site2 FD_gamma FD_alpha FD_beta local_similarity
## <dbl> <chr> <chr> <dbl> <dbl> <dbl> <dbl>
## 1 0 com1 com2 15.3 9.98 1.53 0.822
## 2 0 com1 com3 9.98 7.41 1.35 0.884
## 3 0 com2 com3 10.5 6.64 1.59 0.805
## 4 0 com1 com4 10.7 7.28 1.46 0.845
## 5 0 com2 com4 10.6 6.22 1.71 0.763
## 6 0 com3 com4 5.73 3.86 1.48 0.839
## 7 0 com1 com5 17.2 11.2 1.54 0.821
## 8 0 com2 com5 6.37 4.72 1.35 0.884
## 9 0 com3 com5 15.9 9.60 1.66 0.780
## 10 0 com4 com5 7.04 4.68 1.50 0.832
## # ℹ 35 more rows
## # ℹ 1 more variable: region_similarity <dbl>
# pairwise phylogenetic diversity
hill_phylo_parti_pairwise(comm, tree, q = 0, show_warning = FALSE, .progress = FALSE)
## # A tibble: 45 × 8
## q site1 site2 PD_gamma PD_alpha PD_beta local_similarity
## <dbl> <chr> <chr> <dbl> <dbl> <dbl> <dbl>
## 1 0 com1 com2 6.79 5.06 1.34 0.657
## 2 0 com1 com3 6.14 4.95 1.24 0.759
## 3 0 com2 com3 6.75 4.57 1.48 0.523
## 4 0 com1 com4 6.38 3.99 1.60 0.400
## 5 0 com2 com4 7.13 3.62 1.97 0.0284
## 6 0 com3 com4 5.42 3.51 1.54 0.455
## 7 0 com1 com5 7.04 5.63 1.25 0.750
## 8 0 com2 com5 6.44 5.15 1.25 0.751
## 9 0 com3 com5 7.71 5.15 1.50 0.502
## 10 0 com4 com5 6.42 4.19 1.53 0.467
## # ℹ 35 more rows
## # ℹ 1 more variable: region_similarity <dbl>Licensed under the MIT license. (More information here.)
Please cite this package if you use it. The citation information can
be obtained by running citation('hillR') in R.
Li, (2018). hillR: taxonomic, functional, and phylogenetic diversity and similarity through Hill Numbers. Journal of Open Source Software, 3(31), 1041. https://doi.org/10.21105/joss.01041
@Article{,
title = {hillR: taxonomic, functional, and phylogenetic diversity and similarity through Hill Numbers},
author = {Daijiang Li},
journal = {Journal of Open Source Software},
year = {2018},
volume = {3},
number = {31},
pages = {1041},
url = {https://doi.org/10.21105/joss.01041},
}Contributions are welcome. You can provide comments and feedback or ask questions by filing an issue on GitHub here or making pull requests.