An Introduction to the MetaLonDA Package

Introduction

MetaLonDA (METAgenomic LONgitudinal Differential Abundance method) is a method that identifies significant time intervals of microbial features in longitudinal studies. MetaLonDA has the ability to handle inconsistencies and common challenges associated with human studies, such as variable sample collection times and uneven number of time points along the subjects’ longitudinal study. The method employs a negative binomial distribution in conjunction with a semi-parametric SS-ANOVA to model the count reads. Then, it performs the significance testing based on unit time intervals using permutation testing procedure.

Example

library(MetaLonDA)

## Load read counts of 8 features from 100 samples. Samples are from 2 groups, 5 subjects per group, and 10 time points per subject.
data(metalonda_test_data)

Test one feature

## Create Group, Time, and ID annotation vectors
n.group = 2
n.sample = 5 
n.timepoints = 10
Group = factor(c(rep("A", n.sample*n.timepoints), rep("B",n.sample*n.timepoints)))
Time = rep(rep(1:n.timepoints, times = n.sample), 2)
ID = factor(rep(1:(2*n.sample), each = n.timepoints))

## Define the prediction timeponits 
points = seq(1, 10, length.out = 100)
output.metalonda.f5 = metalonda(Count = metalonda_test_data[5,], Time = Time, Group = Group,
                                ID = ID, n.perm = 20, fit.method = "nbinomial", points = points,
                                text = rownames(metalonda_test_data)[5], parall = FALSE, pvalue.threshold = 0.05,     
                                adjust.method = "BH", time.unit = "hours", ylabel = "Read Counts", col = c("chartreuse",
                                                                                                           "blue4"))
## Start MetaLonDA 
## Visualizing Feature =  OTU_5
## Start Curve Fitting 
## Fitting: NB SS 
## Visualizing Splines of Feature =  OTU_5
## Warning: The `<scale>` argument of `guides()` cannot be `FALSE`. Use "none" instead as
## of ggplot2 3.3.4.
## ℹ The deprecated feature was likely used in the MetaLonDA package.
##   Please report the issue at <https://github.com/aametwally/MetaLonDA/issues>.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## Calculate Area Under the Fitted Curves 
## Start Permutation 
##   |                                                                              |                                                                      |   0%  |                                                                              |====                                                                  |   5%  |                                                                              |=======                                                               |  10%  |                                                                              |==========                                                            |  15%  |                                                                              |==============                                                        |  20%  |                                                                              |==================                                                    |  25%  |                                                                              |=====================                                                 |  30%  |                                                                              |========================                                              |  35%  |                                                                              |============================                                          |  40%  |                                                                              |================================                                      |  45%  |                                                                              |===================================                                   |  50%  |                                                                              |======================================                                |  55%  |                                                                              |==========================================                            |  60%  |                                                                              |==============================================                        |  65%  |                                                                              |=================================================                     |  70%  |                                                                              |====================================================                  |  75%  |                                                                              |========================================================              |  80%  |                                                                              |============================================================          |  85%  |                                                                              |===============================================================       |  90%  |                                                                              |==================================================================    |  95%  |                                                                              |======================================================================| 100%
## p-value Adjustment Method =  BH 
## Visualizing Significant Intervals of Feature =  OTU_5

In our example, we used 20 permutations just to showcase how MetaLonDA works. In real analysis, this number should be at least 1000.

Test all features

## Identify significant time intervals for all features: 
output.metalonda.all = metalondaAll(Count = metalonda_test_data, Time = Time, Group = Group,
                                    ID = ID, n.perm = 20, fit.method = "nbinomial", num.intervals = 100, 
                                    parall = FALSE, pvalue.threshold = 0.05, adjust.method = "BH", time.unit = "hours", 
                                    norm.method = "none", prefix = "Test", ylabel = "Read Counts", col = c("chartreuse",
                                                                                                           "blue4"))
## Dimensionality check passed
## Prediction Points =   [1]  1.00  1.09  1.18  1.27  1.36  1.45  1.54  1.63  1.72  1.81  1.90  1.99
##  [13]  2.08  2.17  2.26  2.35  2.44  2.53  2.62  2.71  2.80  2.89  2.98  3.07
##  [25]  3.16  3.25  3.34  3.43  3.52  3.61  3.70  3.79  3.88  3.97  4.06  4.15
##  [37]  4.24  4.33  4.42  4.51  4.60  4.69  4.78  4.87  4.96  5.05  5.14  5.23
##  [49]  5.32  5.41  5.50  5.59  5.68  5.77  5.86  5.95  6.04  6.13  6.22  6.31
##  [61]  6.40  6.49  6.58  6.67  6.76  6.85  6.94  7.03  7.12  7.21  7.30  7.39
##  [73]  7.48  7.57  7.66  7.75  7.84  7.93  8.02  8.11  8.20  8.29  8.38  8.47
##  [85]  8.56  8.65  8.74  8.83  8.92  9.01  9.10  9.19  9.28  9.37  9.46  9.55
##  [97]  9.64  9.73  9.82  9.91 10.00
## 
## Feature  =  OTU_1 
## Start MetaLonDA 
## Visualizing Feature =  OTU_1
## Start Curve Fitting 
## Fitting: NB SS 
## Visualizing Splines of Feature =  OTU_1
## Calculate Area Under the Fitted Curves 
## Start Permutation 
##   |                                                                              |                                                                      |   0%  |                                                                              |====                                                                  |   5%  |                                                                              |=======                                                               |  10%  |                                                                              |==========                                                            |  15%  |                                                                              |==============                                                        |  20%  |                                                                              |==================                                                    |  25%  |                                                                              |=====================                                                 |  30%  |                                                                              |========================                                              |  35%  |                                                                              |============================                                          |  40%  |                                                                              |================================                                      |  45%  |                                                                              |===================================                                   |  50%  |                                                                              |======================================                                |  55%  |                                                                              |==========================================                            |  60%  |                                                                              |==============================================                        |  65%  |                                                                              |=================================================                     |  70%  |                                                                              |====================================================                  |  75%  |                                                                              |========================================================              |  80%  |                                                                              |============================================================          |  85%  |                                                                              |===============================================================       |  90%  |                                                                              |==================================================================    |  95%  |                                                                              |======================================================================| 100%
## p-value Adjustment Method =  BH 
## Visualizing Significant Intervals of Feature =  OTU_1
## 
## 
## Feature  =  OTU_2 
## Start MetaLonDA 
## Visualizing Feature =  OTU_2
## Start Curve Fitting 
## Fitting: NB SS 
## Visualizing Splines of Feature =  OTU_2
## Calculate Area Under the Fitted Curves 
## Start Permutation 
##   |                                                                              |                                                                      |   0%  |                                                                              |====                                                                  |   5%  |                                                                              |=======                                                               |  10%  |                                                                              |==========                                                            |  15%  |                                                                              |==============                                                        |  20%  |                                                                              |==================                                                    |  25%  |                                                                              |=====================                                                 |  30%  |                                                                              |========================                                              |  35%  |                                                                              |============================                                          |  40%  |                                                                              |================================                                      |  45%  |                                                                              |===================================                                   |  50%  |                                                                              |======================================                                |  55%  |                                                                              |==========================================                            |  60%  |                                                                              |==============================================                        |  65%  |                                                                              |=================================================                     |  70%  |                                                                              |====================================================                  |  75%  |                                                                              |========================================================              |  80%  |                                                                              |============================================================          |  85%  |                                                                              |===============================================================       |  90%  |                                                                              |==================================================================    |  95%  |                                                                              |======================================================================| 100%
## p-value Adjustment Method =  BH 
## Visualizing Significant Intervals of Feature =  OTU_2
## 
## 
## Feature  =  OTU_3 
## Start MetaLonDA 
## Visualizing Feature =  OTU_3
## Start Curve Fitting 
## Fitting: NB SS 
## Visualizing Splines of Feature =  OTU_3
## Calculate Area Under the Fitted Curves 
## Start Permutation 
##   |                                                                              |                                                                      |   0%  |                                                                              |====                                                                  |   5%  |                                                                              |=======                                                               |  10%  |                                                                              |==========                                                            |  15%  |                                                                              |==============                                                        |  20%  |                                                                              |==================                                                    |  25%  |                                                                              |=====================                                                 |  30%  |                                                                              |========================                                              |  35%  |                                                                              |============================                                          |  40%  |                                                                              |================================                                      |  45%  |                                                                              |===================================                                   |  50%  |                                                                              |======================================                                |  55%  |                                                                              |==========================================                            |  60%  |                                                                              |==============================================                        |  65%  |                                                                              |=================================================                     |  70%  |                                                                              |====================================================                  |  75%  |                                                                              |========================================================              |  80%  |                                                                              |============================================================          |  85%  |                                                                              |===============================================================       |  90%  |                                                                              |==================================================================    |  95%  |                                                                              |======================================================================| 100%
## p-value Adjustment Method =  BH 
## Visualizing Significant Intervals of Feature =  OTU_3
## 
## 
## Feature  =  OTU_4 
## Start MetaLonDA 
## Visualizing Feature =  OTU_4
## Start Curve Fitting 
## Fitting: NB SS 
## Visualizing Splines of Feature =  OTU_4
## Calculate Area Under the Fitted Curves 
## Start Permutation 
##   |                                                                              |                                                                      |   0%  |                                                                              |====                                                                  |   5%  |                                                                              |=======                                                               |  10%  |                                                                              |==========                                                            |  15%  |                                                                              |==============                                                        |  20%  |                                                                              |==================                                                    |  25%  |                                                                              |=====================                                                 |  30%  |                                                                              |========================                                              |  35%  |                                                                              |============================                                          |  40%  |                                                                              |================================                                      |  45%  |                                                                              |===================================                                   |  50%  |                                                                              |======================================                                |  55%  |                                                                              |==========================================                            |  60%  |                                                                              |==============================================                        |  65%  |                                                                              |=================================================                     |  70%  |                                                                              |====================================================                  |  75%  |                                                                              |========================================================              |  80%  |                                                                              |============================================================          |  85%  |                                                                              |===============================================================       |  90%  |                                                                              |==================================================================    |  95%  |                                                                              |======================================================================| 100%
## p-value Adjustment Method =  BH 
## Visualizing Significant Intervals of Feature =  OTU_4
## 
## 
## Feature  =  OTU_5 
## Start MetaLonDA 
## Visualizing Feature =  OTU_5
## Start Curve Fitting 
## Fitting: NB SS 
## Visualizing Splines of Feature =  OTU_5
## Calculate Area Under the Fitted Curves 
## Start Permutation 
##   |                                                                              |                                                                      |   0%  |                                                                              |====                                                                  |   5%  |                                                                              |=======                                                               |  10%  |                                                                              |==========                                                            |  15%  |                                                                              |==============                                                        |  20%  |                                                                              |==================                                                    |  25%  |                                                                              |=====================                                                 |  30%  |                                                                              |========================                                              |  35%  |                                                                              |============================                                          |  40%  |                                                                              |================================                                      |  45%  |                                                                              |===================================                                   |  50%  |                                                                              |======================================                                |  55%  |                                                                              |==========================================                            |  60%  |                                                                              |==============================================                        |  65%  |                                                                              |=================================================                     |  70%  |                                                                              |====================================================                  |  75%  |                                                                              |========================================================              |  80%  |                                                                              |============================================================          |  85%  |                                                                              |===============================================================       |  90%  |                                                                              |==================================================================    |  95%  |                                                                              |======================================================================| 100%
## p-value Adjustment Method =  BH 
## Visualizing Significant Intervals of Feature =  OTU_5
## 
## 
## Feature  =  OTU_6 
## Start MetaLonDA 
## Visualizing Feature =  OTU_6
## Start Curve Fitting 
## Fitting: NB SS 
## Visualizing Splines of Feature =  OTU_6
## Calculate Area Under the Fitted Curves 
## Start Permutation 
##   |                                                                              |                                                                      |   0%  |                                                                              |====                                                                  |   5%  |                                                                              |=======                                                               |  10%  |                                                                              |==========                                                            |  15%  |                                                                              |==============                                                        |  20%  |                                                                              |==================                                                    |  25%  |                                                                              |=====================                                                 |  30%  |                                                                              |========================                                              |  35%  |                                                                              |============================                                          |  40%  |                                                                              |================================                                      |  45%  |                                                                              |===================================                                   |  50%  |                                                                              |======================================                                |  55%  |                                                                              |==========================================                            |  60%  |                                                                              |==============================================                        |  65%  |                                                                              |=================================================                     |  70%  |                                                                              |====================================================                  |  75%  |                                                                              |========================================================              |  80%  |                                                                              |============================================================          |  85%  |                                                                              |===============================================================       |  90%  |                                                                              |==================================================================    |  95%  |                                                                              |======================================================================| 100%
## p-value Adjustment Method =  BH 
## Visualizing Significant Intervals of Feature =  OTU_6
## 
## 
## Feature  =  OTU_7 
## Start MetaLonDA 
## Visualizing Feature =  OTU_7
## Start Curve Fitting 
## Fitting: NB SS 
## Visualizing Splines of Feature =  OTU_7
## Calculate Area Under the Fitted Curves 
## Start Permutation 
##   |                                                                              |                                                                      |   0%  |                                                                              |====                                                                  |   5%  |                                                                              |=======                                                               |  10%  |                                                                              |==========                                                            |  15%  |                                                                              |==============                                                        |  20%  |                                                                              |==================                                                    |  25%  |                                                                              |=====================                                                 |  30%  |                                                                              |========================                                              |  35%  |                                                                              |============================                                          |  40%  |                                                                              |================================                                      |  45%  |                                                                              |===================================                                   |  50%  |                                                                              |======================================                                |  55%  |                                                                              |==========================================                            |  60%  |                                                                              |==============================================                        |  65%  |                                                                              |=================================================                     |  70%  |                                                                              |====================================================                  |  75%  |                                                                              |========================================================              |  80%  |                                                                              |============================================================          |  85%  |                                                                              |===============================================================       |  90%  |                                                                              |==================================================================    |  95%  |                                                                              |======================================================================| 100%
## p-value Adjustment Method =  BH 
## No Significant Intevals Found 
## 
## 
## Feature  =  OTU_8 
## Start MetaLonDA 
## Visualizing Feature =  OTU_8
## Start Curve Fitting 
## Fitting: NB SS 
## Visualizing Splines of Feature =  OTU_8
## Calculate Area Under the Fitted Curves 
## Start Permutation 
##   |                                                                              |                                                                      |   0%  |                                                                              |====                                                                  |   5%  |                                                                              |=======                                                               |  10%  |                                                                              |==========                                                            |  15%  |                                                                              |==============                                                        |  20%  |                                                                              |==================                                                    |  25%  |                                                                              |=====================                                                 |  30%  |                                                                              |========================                                              |  35%  |                                                                              |============================                                          |  40%  |                                                                              |================================                                      |  45%  |                                                                              |===================================                                   |  50%  |                                                                              |======================================                                |  55%  |                                                                              |==========================================                            |  60%  |                                                                              |==============================================                        |  65%  |                                                                              |=================================================                     |  70%  |                                                                              |====================================================                  |  75%  |                                                                              |========================================================              |  80%  |                                                                              |============================================================          |  85%  |                                                                              |===============================================================       |  90%  |                                                                              |==================================================================    |  95%  |                                                                              |======================================================================| 100%
## p-value Adjustment Method =  BH 
## No Significant Intevals Found

References

Metwally, Ahmed A., Jie Yang, Christian Ascoli, Yang Dai, Patricia W. Finn, and David L. Perkins. “MetaLonDA: a flexible R package for identifying time intervals of differentially abundant features in metagenomic longitudinal studies”, Microbiome, 2018.

Metwally, Ahmed A., Patricia W. Finn, Yang Dai, and David L. Perkins. “Detection of Differential Abundance Intervals in Longitudinal Metagenomic Data Using Negative Binomial Smoothing Spline ANOVA.” ACM BCB, 2017.

Bugs and Suggestions

MetaLonDA is under active research development. Please report any bugs/suggestions to Ahmed Metwally ().