Skip to contents

fastbiom provides the fastest implementations of several alpha- and beta-diversity metrics for R, including phylogenetic metrics such as Faith’s PD and 5 variants of UniFrac. It is compatible with phyloseq, rbiom, and BioConductor objects. Zero dependencies, making it quick to install and ideal for package developers.

Installation

The latest stable version can be installed from CRAN.

install.packages('fastbiom')

The development version is available on GitHub.

install.packages('pak')
pak::pak('cmmr/fastbiom')

Usage

Calculate alpha diverity

ex_counts
#>      A B C  D
#> OTU1 4 0 0  0
#> OTU2 0 8 9 10
#> OTU3 3 0 0  0
#> OTU4 2 0 0  0
#> OTU5 6 5 7  1

shannon(ex_counts)
#>         A         B         C         D 
#> 1.3095258 0.6662784 0.6853142 0.3046361 

faith(ex_counts, tree = ex_tree)
#>   A   B   C   D 
#> 3.4 2.2 2.2 2.2

Calculate beta diverity

bray_curtis(ex_counts)
#>           A         B         C
#> B 0.6428571                    
#> C 0.6129032 0.1034483          
#> D 0.9230769 0.2500000 0.2592593

generalized_unifrac(ex_counts, tree = ex_tree, alpha = 0.5)
#>            A          B          C
#> B 0.61036006                      
#> C 0.60260471 0.04873043           
#> D 0.75764452 0.25262174 0.29851111

Documentation

The online manual for fastbiom is available at https://cmmr.github.io/fastbiom/. It includes a getting started guide, articles that explore specific use cases, and reference pages for each function.

Automated tests

The following commands will check if fastbiom passes the bundled testing suite.

install.packages('testthat')
testthat::test_check('fastbiom')

Community guidelines

Support

Bug reports, feature requests, and general questions can be submitted at https://github.com/cmmr/fastbiom/issues.

Contributing

Pull requests are welcome. Please ensure contributed code is covered by tests and documentation (add additional tests and documentation as needed) and passes all automated tests.