NetCoMi (Network Construction and Comparison for Microbiome Data) is an R package designed to facilitate the construction, analysis, and comparison of networks tailored to microbial compositional data. It implements a comprehensive workflow introduced in Peschel et al. (2020), which guides users through each step of network generation and analysis with a strong emphasis on reproducibility and computational efficiency.
With NetCoMi, users can construct microbial association or dissimilarity networks directly from sequencing data, typically provided as a read count matrix. The package includes a broad selection of methods for handling zeros, normalizing data, computing associations between microbial taxa, and sparsifying the resulting matrices. By offering these components in a modular format, NetCoMi allows users to tailor the workflow to their specific research needs, creating highly customizable microbial networks.
The package supports both the construction, analysis, and visualization of a single network and the comparison of two networks through graphical and quantitative approaches, including statistical testing. Additionally, NetCoMi offers the capability of constructing differential networks, where only differentially associated taxa are connected.
Exemplary network comparison using soil microbiome data (‘soilrep’ data from phyloseq package). Microbial associations are compared between the two experimantal settings ‘warming’ and ‘non-warming’ using the same layout in both groups.
Here is an overview of methods available for network construction, together with some information on their implementation in R:
Association measures:
- Pearson coefficient
(
cor()
fromstats
package) - Spearman coefficient
(
cor()
fromstats
package) - Biweight Midcorrelation
bicor()
fromWGCNA
package - SparCC
(
sparcc()
fromSpiecEasi
package) - CCLasso (R code on GitHub)
- CCREPE
(
ccrepe
package) - SpiecEasi (
SpiecEasi
package) - SPRING (
SPRING
package) - gCoda (R code on GitHub)
- propr
(
propr
package)
Dissimilarity measures:
- Euclidean distance
(
vegdist()
fromvegan
package) - Bray-Curtis dissimilarity
(
vegdist()
fromvegan
package) - Kullback-Leibler divergence (KLD)
(
KLD()
fromLaplacesDemon
package) - Jeffrey divergence (own code using
KLD()
fromLaplacesDemon
package) - Jensen-Shannon divergence (own code using
KLD()
fromLaplacesDemon
package) - Compositional KLD (own implementation following Martin-Fernández et al. (1999))
- Aitchison distance
(
vegdist()
andclr()
fromSpiecEasi
package)
Methods for zero replacement:
- Add a predefined pseudo count to the count table
- Replace only zeros in the count table by a predefined pseudo count (ratios between non-zero values are preserved)
- Multiplicative replacement
(
multRepl
fromzCompositions
package) - Modified EM alr-algorithm
(
lrEM
fromzCompositions
package) - Bayesian-multiplicative replacement
(
cmultRepl
fromzCompositions
package)
Normalization methods:
- Total Sum Scaling (TSS) (own implementation)
- Cumulative Sum Scaling (CSS) (
cumNormMat
frommetagenomeSeq
package) - Common Sum Scaling (COM) (own implementation)
- Rarefying (
rrarefy
fromvegan
package) - Variance Stabilizing Transformation (VST)
(
varianceStabilizingTransformation
fromDESeq2
package) - Centered log-ratio (clr) transformation
(
clr()
fromSpiecEasi
package))
TSS, CSS, COM, VST, and the clr transformation are described in (Badri et al. 2020).
# Required packages
install.packages("devtools")
install.packages("BiocManager")
# Since two of NetCoMi's dependencies are only available on GitHub,
# it is recommended to install them first:
devtools::install_github("zdk123/SpiecEasi")
devtools::install_github("GraceYoon/SPRING")
# Install NetCoMi
devtools::install_github("stefpeschel/NetCoMi",
repos = c("https://cloud.r-project.org/",
BiocManager::repositories()))
If there are any errors during installation, please install the missing dependencies manually.
Packages that are optionally required in certain settings are not installed together with NetCoMi. These can be installed automatically using:
installNetCoMiPacks()
If not installed via installNetCoMiPacks()
, the required package is
installed by the respective NetCoMi function when needed.
Thanks to daydream-boost, NetCoMi can also be installed from conda bioconda channel with
# You can install an individual environment firstly with
# conda create -n NetCoMi
# conda activate NetCoMi
conda install -c bioconda -c conda-forge r-netcomi
Everyone who wants to use new features not included in any releases is invited to install NetCoMi’s development version:
devtools::install_github("stefpeschel/NetCoMi",
ref = "develop",
repos = c("https://cloud.r-project.org/",
BiocManager::repositories()))
Please check the NEWS document for features implemented on develop branch.
Badri, Michelle, Zachary D. Kurtz, Richard Bonneau, and Christian L. Müller. 2020. “Shrinkage Improves Estimation of Microbial Associations Under Different Normalization Methods.” NAR Genomics and Bioinformatics 2 (December). https://doi.org/10.1093/NARGAB/LQAA100.
Martin-Fernández, Josep A, M Bren, Carles Barceló-Vidal, and Vera Pawlowsky-Glahn. 1999. “A Measure of Difference for Compositional Data Based on Measures of Divergence.” In Proceedings of IAMG, 99:211–16.
Peschel, Stefanie, Christian L Müller, Erika von Mutius, Anne-Laure Boulesteix, and Martin Depner. 2020. “NetCoMi: network construction and comparison for microbiome data in R.” Briefings in Bioinformatics 22 (4): bbaa290. https://doi.org/10.1093/bib/bbaa290.