# NOT RUN {
library(lfmm)
## An EWAS example with Y = methylation data
## and X = exposure
## Simulate the data
dat <- lfmm_sampler(n = 100,
p = 1000,
K = 3,
outlier.prop = 0.02,
cs = 0.1,
sigma = 0.2,
B.sd = 5,
B.mean = 0,
U.sd = 1.0,
V.sd = 1.0)
Y <- scale(dat$Y)
X <- scale(dat$X)
## Fit an LFMM with 2 latent factors
mod.lfmm <- lfmm_lasso(Y = Y,
X = X,
K = 3,
nozero.prop = 0.02)
## Manhattan plot of sparse effect sizes
effect <- mod.lfmm$B
causal <- dat$outlier
plot(effect,
pch = 19,
cex = .3,
xlab = "Probe",
col = "grey")
points(causal,
effect[causal],
col = "blue")
# }
Run the code above in your browser using DataLab