Learn R Programming

corncob

Count Regression for Correlated Observations with the Beta-binomial

corncob is an R package for modeling relative abundance and testing hypotheses about the effect of covariates on relative abundance. The corncob methodology was specifically developed for modelling microbial abundances based on high throughput sequencing data, such as 16S or whole-genome sequencing.

Installation

To install the corncob package, use the code below to download the development version from Github.

# install.packages("remotes")
remotes::install_github("statdivlab/corncob")
library(corncob)

Docker

Instead of installing corncob to your local system, you can use corncob via the pre-compiled Docker image: quay.io/fhcrc-microbiome/corncob.

Use

The vignettes demonstrate example usage of all main functions (they go over the same analysis, one with phyloseq objects and one without phyloseq objects). Please file an issue if you have a request for a tutorial that is not currently included. You can see the vignette by using the following code:

library(corncob)
# Use this to view the vignette in the corncob HTML help
help(package = "corncob", help_type = "html")
# Use this to view the vignette as an isolated HTML file
utils::browseVignettes(package = "corncob")

Note that R does not allow variable names to start with numbers. Sometimes, when going directly from QIIME2 to phyloseq objects, taxa names will be a large string starting with numbers. To clean these taxa names for use with corncob, use clean_taxa_names(my_phyloseq_object), see ?clean_taxa_names for details.

Documentation

We additionally have a pkgdown website that contains pre-built versions of our function documentation, vignette, and a version of the vignette without phyloseq.

Citation

If you use corncob for your analysis, please cite our manuscript:

Bryan D. Martin, Daniela Witten, and Amy D. Willis. (2020). Modeling microbial abundances and dysbiosis with beta-binomial regression. Annals of Applied Statistics, Volume 14, Number 1, pages 94-115.

An open-access preprint is available on arXiv here.

Bug Reports / Change Requests

If you encounter a bug or would like make a change request, please file it as an issue here.

Copy Link

Version

Install

install.packages('corncob')

Monthly Downloads

578

Version

0.4.2

License

GPL (>= 2)

Issues

Pull Requests

Stars

Forks

Maintainer

Amy D Willis

Last Published

March 29th, 2025

Functions in corncob (0.4.2)

invlogit

Inverse logit transformation
getRestrictionTerms

Get index of restricted terms for Wald test
pbRao

Parametric bootstrap Rao test
pbWald

Parametric bootstrap Wald test
invfishZ

Inverse Fisher's z transformation
print.bbdml

Print function
ibd_phylo_taxa

IBD data, taxonomy data frame.
plot.differentialTest

differentialTest plot function
raotest

Rao-type chi-squared test (model-based or robust)
logit

Logit transformation
qbetabinom

Get quantiles of beta binom
otu_to_taxonomy

Transform OTUs to their taxonomic label
soil_phylum_contrasts_otu

Small soil phylum data for contrasts examples, otu table as data frame
waldchisq

Wald-type chi-squared test
summary.bbdml

Summary function
pbLRT

Parametric bootstrap likelihood ratio test
plot.bbdml

Plotting function
lrtest

Likelihood ratio test
%>%

Pipe operator
soil_phylum_small_sample

Small soil phylum data for examples, sample data as data frame
soil_phylum_small_otu1

Small soil phylum data for examples, sample data as data frame combined with counts for OTU 1 and sequencing depth.
soil_phylo_taxa

Soil data, taxa table as data frame.
warn_phyloseq

Function to throw error if the `phyloseq` package is called but it is not installed
objfun

Objective function
print.differentialTest

differentialTest print function
soil_phylo_otu

Soil data, otu table as data frame.
print.summary.bbdml

Print summary function
soil_phylum_contrasts_sample

Small soil phylum data for contrasts examples, sample data as data frame
soil_phylo_sample

Soil data, sample data.
sandSE

Compute sandwich standard errors. Legacy function. Use sand_vcov instead.
sand_vcov

Compute sandwich estimate of variance-covariance matrix
simulate.bbdml

Simulate from beta-binomial model
score

Compute score at the MLE
soil_phylum_small_otu

Small soil phylum data for examples, otu table as data frame
waldchisq_test

Wald-type chi-squared test statistic (model-based or robust)
waldt

Wald-type t test (model-based or robust)
bbdml

Maximum Likelihood for the Beta-binomial Distribution
dbetabin

Betabinomial density
dbetabin_neg

Negative betabinomial density
coth

Hyperbolic cotangent transformation
convert_phylo

Function to subset and convert phyloseq data
checkNested

Check for nested models
contrastsTest

Identify differentially-abundant and differentially-variable taxa using contrasts
corncob-package

Corncob package documentation.
hessian

Compute Hessian matrix at the MLE
gr_full

Parameter Gradient Vector
clean_taxa_names

Rename taxa
doBoot

Function to run a bootstrap iteration
HDIbetabinom

Get highest density interval of beta-binomial
dbetabinom_cts

Densities of beta binomial distributions, permitting non integer x and size
genInits

Generate initialization for optimization
fishZ

Fisher's z transformation
ibd_phylo_otu

IBD data, OTU count data frame.
ibd_phylo_sample

IBD data, sample data frame.
differentialTest

Identify differentially-abundant and differentially-variable taxa