--- title: "An Introduction to the MetaLonDA Package" author: "Ahmed A. Metwally" date: "`r Sys.Date()`" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{MetaLonDA Package} %\VignetteEngine{knitr::rmarkdown} \usepackage[utf8]{inputenc} --- ## 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 ```{r} 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 ```{r} ## 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")) ``` 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 ```{r} ## 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")) ``` ## 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 (ametwall@stanford.edu).