Introduction_of_lglasso_package

This package implements the algorithms proposed in Zhou et al. (2021), which aims to estimates the microbial interaction network based on Gaussian graphical model and irregularly-spaced longitudinal data. There are two related models in Zhou et al. (2021) which can handle two different questions. The first model is called homogeneous stationary Gaussian graphical model (SGGM) in which all the subjects share a same auto-correlation parameter \(\tau\). For homogeneous SGGM, an iterative graphical lasso algorithm is proposed to compute the \(l_1\) penalized maximum likelihood estimate (MLE) of the network. The second model is called heterogeneous SGGM in which each subject possesses his/her own auto-correlation parameter \(\tau_i\). For heterogeneous SGGM, given the complex form of its likelihood function, an expectation-maximization (EM) type algorithm is devised to compute the \(l_1\) penalized MLE of the network and \(\tau_i\)’s, which integrates the EM algorithm with conventional graphical lasso algorithm (Friedman (2019)) and therefore can be implemented very efficiently. For the details of the algorithms and the output of the packages, please see Zhou et al. (2021).

library(lglasso)

There are two main functions in this package. The first one is \(lglasso\) which can output a sparse network representing the precision matrix by maximizing the \(l_1\) penalized likelihood function. The second function if \(mle\), which can compute the maximum likelihood estimates of precision matrix and the correlation parameter \(\tau\) for a given network structure produced from function \(lglasso\).

library(matrixcalc)
library(fake)
library(CVXR)
library(expm)
library(purrr)
library(stors)
library(MASS)
library(devtools)
load_all()
p=50
m1=100
m2=0
m3=5
n=20
rho=0.8

Model 1: clustered data with no correlation structure

set.seed(5)
cc=matrix(rho,ncol = m3,nrow = m3)
diag(cc)=1
dd=simulate(n=n,p=p,m1=m1,m2=m2,m3=m3,cc=cc,homo=T)
ddata=dd$data
aa=lglasso(data=ddata,lambda = c(0.1,0.1),type="general",group = ddata[,2])
aa=lglasso(data=ddata,lambda = 0.1,type="general")
 cov2cor(aa$v)
#>           [,1]      [,2]      [,3]      [,4]      [,5]
#> [1,] 1.0000000 0.5039027 0.5114935 0.5129590 0.5123945
#> [2,] 0.5039027 1.0000000 0.5050763 0.5122512 0.5026856
#> [3,] 0.5114935 0.5050763 1.0000000 0.5216989 0.5061777
#> [4,] 0.5129590 0.5122512 0.5216989 1.0000000 0.5299371
#> [5,] 0.5123945 0.5026856 0.5061777 0.5299371 1.0000000

Model 2: longitudinal data with one-parameter structured correlation


 set.seed(5)
dd=simulate_long(n=n,p=p,m1=m1,tau=c(2,1))
ddata=dd$data
group=rep(c(1,2),71)
aa=lglasso(data=ddata,lambda = c(0.1,0.1),type="expFixed",expFix=1,group = group)
aa=lglasso(data=ddata,lambda = 0.1,,type="expFixed",expFix=1)
aa$tauhat
#> [1] 1.042969
cov2cor(aa$vList[[1]])
#>           [,1]      [,2]      [,3]      [,4]      [,5]
#> [1,] 1.0000000 0.9271306 0.6095173 0.5749827 0.3024617
#> [2,] 0.9271306 1.0000000 0.6574234 0.6201744 0.3262342
#> [3,] 0.6095173 0.6574234 1.0000000 0.9433410 0.4962315
#> [4,] 0.5749827 0.6201744 0.9433410 1.0000000 0.5260362
#> [5,] 0.3024617 0.3262342 0.4962315 0.5260362 1.0000000

Model 3: longitudinal data with two-parameter structured correlation


set.seed(5)
dd=simulate_long(n=n,p=p,m1=m1,tau=c(2,1))
ddata=dd$data
group=rep(c(1,2),71)
aa=lglasso(data=ddata,lambda = c(0.001,0.1),type="twoPara",group=group)
aa=lglasso(data=ddata,lambda = 0.001,type="twoPara")
aa$tauhat
#> [1] 1.497429 1.204115
cov2cor(aa$vList[[1]])
#>           [,1]      [,2]      [,3]      [,4]      [,5]
#> [1,] 1.0000000 0.8773989 0.4249223 0.3841668 0.1265450
#> [2,] 0.8773989 1.0000000 0.4842978 0.4378474 0.1442274
#> [3,] 0.4249223 0.4842978 1.0000000 0.9040871 0.2978073
#> [4,] 0.3841668 0.4378474 0.9040871 1.0000000 0.3294012
#> [5,] 0.1265450 0.1442274 0.2978073 0.3294012 1.0000000

[1] Zhou, J., Gui, J., Viles, W.D., Chen, H., Madan, J.C., Coker, M.O., Hoen, A.G., 2021a. Identifying Microbial Interaction Networks Based on Irregularly Spaced Longitudinal 16S rRNA sequence data. https://doi.org/10.1101/2021.11.26.470159

[2] Friedman J., Hastie T., Tibshirani R. (2019) Graphical Lasso: Estimation of Gaussian Graphical Models, Version: 1.11. https://CRAN.R-project.org/package=glasso.