# \donttest{
Y <- matrix(1:110, 10, 11)
condition <- c(rep(0, 5), rep(1, 6))
data <- data.frame(condition=condition)
## demonstrate formula interface and passing optional argument (gamma) to
## the scale model (clr)
res <- aldex(Y, ~condition, data, nsample=2000, scale=clr.sm, gamma=0.5)
## demonstrating how to write a custom scale model, I will write a model
## that generalizes total sum scaling (where we assume no change between
## conditions)
## Functions can include parameters X (model matrix), Y, and logComp.
## If included in the function definition, those parameters will be passed
## dynamically when aldex is running. Other optional parameters (gamma)
## can be passed as additional arguments to the aldex function
tss <- function(X, logComp, gamma=0.5) {
P <- nrow(X)
nsample <- dim(logComp)[3]
LambdaScale <- matrix(rnorm(P*nsample,0,gamma), P, nsample)
logScale <- t(X)%*% LambdaScale
return(logScale)
}
res <- aldex(Y, ~condition, data, nsample=2000, scale=tss, gamma=0.75)
# }
Run the code above in your browser using DataLab