# NOT RUN {
library(lfmm)
## Simulation of 1000 genotypes for 100 individuals (y)
u <- matrix(rnorm(300, sd = 1), nrow = 100, ncol = 3)
v <- matrix(rnorm(3000, sd = 3), nrow = 3, ncol = 1000)
w <- u %*% v
y <- matrix(rbinom(100000, size = 2,
prob = 1/(1 + exp(-0.3 * (w
+ rnorm(100000, sd = 2))))),
nrow = 100,
ncol = 1000)
#PCA of genotypes, 2 main axes of variation (K = 2)
plot(prcomp(y))
## Simulation of 1000 phenotypes (x)
## Only the last 10 genotypes have significant effect sizes (b)
b <- matrix(c(rep(0, 990), rep(6000, 10)))
x <- y%*%b + rnorm(100, sd = 100)
## Compute effect sizes using lfmm_ridge
mod <- lfmm_ridge(Y = y,
X = x,
K = 2)
x.pred <- predict_lfmm(Y = y,
X = x,
fdr.level = 0.25,
mod)
x.pred$candidates
##Compare simulated and predicted/fitted phenotypes
plot(x - mean(x), x.pred$pred,
pch = 19, col = "grey",
xlab = "Observed phenotypes (centered)",
ylab = "Predicted from PRS")
abline(0,1)
abline(lm(x.pred$pred ~ scale(x, scale = FALSE)), col = 2)
# }
Run the code above in your browser using DataLab