# set number of genes (p) and samples (n)
p <- 10
n <- 1000
# sample cis-effects
beta <- abs(rnorm(p))
# sample trans-effects
Theta <- matrix(sample(c(-1,1), p^2, replace=TRUE, prob=c(0.2, 0.8)), ncol=p) *
matrix(runif(p^2), ncol=p) / 4
diag(Theta) <- 1
# sample error variances
Sigma <- diag(rchisq(p, df=1)/5 + 0.5)
# sample DNA copy number data
X <- matrix(runif(n*p, min=-2, max=2), ncol=p)
# sample gene expression data
Y <- t(apply(X, 1, function(Y, beta){ Y * beta }, beta=beta)) %*% t(solve(Theta)) +
rmvnorm(n, sigma=solve(Theta) %*% Sigma %*% t(solve(Theta)))
# fit model
pFit <- pathway1sample(Y, X, lambda1=1, verbose=TRUE)
# compare fit to "truth" for cis-effects
plot(pFit@Cis ~ beta, pch=20)
# compare fit to "truth" for trans-effects
penFits <- c(pFit@Trans[upper.tri(Theta)], pFit@Trans[lower.tri(Theta)])
truth <- c(Theta[upper.tri(Theta)], Theta[lower.tri(Theta)])
plot(penFits ~ truth, pch=20)
Run the code above in your browser using DataLab