# NOT RUN {
#rm(list=ls())
nsims <- 2 #100
res <- numeric(nsims)
for(i in 1:nsims){
n <- 1000
nr=5
ni=50
r <- nr*ni
t <- matrix(rep(1:nr), ni, ncol=1, nrow=r)
sigma <- 0.5
b0 <- 1
#under the null:
b1 <- 0
y.tilde <- b0 + b1*t + rnorm(r, sd = sigma)
y <- t(matrix(rnorm(n*r, sd = sqrt(sigma*abs(y.tilde))), ncol=n, nrow=r) +
matrix(rep(y.tilde, n), ncol=n, nrow=r))
x <- matrix(1, ncol=1, nrow=r)
#run test
res_genes <- varcompseq(exprmat=y, covariates=x, variables2test=t, sample_group=rep(1:ni, each=nr),
which_test="asymptotic",
which_weights="none", preprocessed=TRUE)
mean(res_genes$pvals[, "rawPval"]>0.05)
quantile(res_genes$pvals[, "rawPval"])
res[i] <- mean(res_genes$pvals[, "rawPval"]<0.05)
cat(i,"\n")
}
mean(res)
# }
# NOT RUN {
b0 <- 1
b1 <- 0
y.tilde <- b0 + b1*t + rnorm(r, sd = sigma)
y <- t(matrix(rnorm(n*r, sd = sqrt(sigma*abs(y.tilde))), ncol=n, nrow=r) +
matrix(rep(y.tilde, n), ncol=n, nrow=r))
res_genes <- varcompseq(exprmat=y, covariates=x, variables2test=t, sample_group=rep(1:ni, each=nr),
which_weights="none", preprocessed=TRUE)
summary(res_genes$pvals)
# }
Run the code above in your browser using DataLab