Description Usage Arguments Value Examples
Microbiome data denoising framework (mbDenoise) with zero-inflated probabilistic PCA with Poisson (ZIPPCA-Poi) and negative-binomial model (ZIPPCA-NB), which can be used for downstream statistical analysis including ordination, compositional normalization, differential abundance analysis, etc. mbDenoise with ZIPPCA-NB model is recommended for empirical data analysis.
1 2 3 4 5 6 7 8 9 10 |
X |
matrix of observations. |
V |
vector of the sample covariate. |
family |
distribution of models. Two options are "poisson" and "negative.binomial". Defaults to "negative.binomial". |
n.factors |
the rank or number of factors, after dimensional reduction. Defaults to 2. |
rank |
logical, if TRUE, the rank or number of factors, is chosen from 1 to 5 by HIC (hybrid information criterion). Defaults to FALSE. |
trace |
logical, defaults to |
maxit |
maximum number of iterations within |
parallel |
logical, if TRUE, use parallel toolbox to accelerate. |
VLB |
variational lower bound of log likelihood |
lvs |
list of latent variables
|
params |
list of model parameters
|
Q |
the underlying composition of microbiome data |
muz |
the denoised counts of microbiome data |
hic |
the number of the rank selection, chosen by HIC type information criterion |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | n.n = 60
n.w = 100
n.factors = 2
set.seed(1)
si <- diag(n.factors)
me <- c(0,0)
f <- matrix(0,nrow = n.n, ncol = n.factors)
for(i in 1:n.n){
f[i,] <- rnorm(n.factors, mean = 0, sd = 1)
}
betaj <- matrix(0,nrow = n.w, ncol = n.factors)
for(j in 1:n.w){
betaj[j,] <- runif(n.factors,-3,3)
}
alpha <- runif(n.n,-5,5)
beta0 <- rep(0,n.w)
g <- rep(0,n.w*0.5*0.5)
gamma <- c(g,-g,rep(0,(n.w-n.w*0.5)))
X_cov<- c(rep(1,n.n/2),rep(0,n.n/2))
ll <- f %*% t(betaj) +matrix(alpha,n.n,n.w)+matrix(beta0,n.n,n.w,byrow=TRUE)
exp_mat <- exp(ll)
eta_mat <- matrix(0.25,n.n,n.w,byrow=TRUE)
z <- matrix(0,n.n,n.w,byrow = TRUE)
for(i in 1:n.n){
z[i,] <- rbinom(n.w, size=1, prob=eta_mat[i,])
}
sum <- rowSums((1-z)*exp_mat)
Qn_z <- (1-z)*exp_mat/sum
sum <- rowSums(exp_mat)
Qn <- exp_mat/sum
X <- matrix(0,n.n,n.w,byrow = TRUE)
for(i in 1:n.n){
for(j in 1:n.w){
X[i,j] <- rnbinom(n=1,size=10,mu=exp_mat[i,j])
}
}
X[z==1]=0
zerorow <- which(rowSums(X)==0)
if(length(zerorow) >0 ){
X <- X[-zerorow,];X_cov<-X_cov[-zerorow];f <- f[-zerorow,];
Qn <- Qn[-zerorow,];Qn_z <- Qn_z[-zerorow,];
}
zerocol <- which(colSums(X)==0)
if(length(zerocol) >0 ){
X <- X[,-zerocol];betaj <- t(t(betaj)[,-zerocol]);
Qn <- Qn[,-zerocol];Qn_z <- Qn_z[,-zerocol];
}
re_zinb_cov <- ZIPPCApn(X,X_cov)
re_zinb <- ZIPPCApn(X)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.