# NOT RUN {
library(lfmm)
## a GWAS example with Y = SNPs and X = phenotype
data(example.data)
Y <- example.data$genotype[, 1:10000]
X <- example.data$phenotype
## Fit an LFMM with K = 6 factors
mod.lfmm <- lfmm_ridge(Y = Y,
X = X,
K = 6)
## Perform association testing using the fitted model:
pv <- lfmm_test(Y = Y,
X = X,
lfmm = mod.lfmm,
calibrate = "gif")
## Manhattan plot with causal loci shown
pvalues <- pv$calibrated.pvalue
plot(-log10(pvalues), pch = 19,
cex = .2, col = "grey", xlab = "SNP")
points(example.data$causal.set[1:5],
-log10(pvalues)[example.data$causal.set[1:5]],
type = "h", col = "blue")
## An EWAS example with Y = methylation data and X = exposure
Y <- skin.exposure$beta.value
X <- as.numeric(skin.exposure$exposure)
## Fit an LFMM with 2 latent factors
mod.lfmm <- lfmm_ridge(Y = Y,
X = X,
K = 2)
## Perform association testing using the fitted model:
pv <- lfmm_test(Y = Y,
X = X,
lfmm = mod.lfmm,
calibrate = "gif")
## Manhattan plot with true associations shown
pvalues <- pv$calibrated.pvalue
plot(-log10(pvalues),
pch = 19,
cex = .3,
xlab = "Probe",
col = "grey")
causal.set <- seq(11, 1496, by = 80)
points(causal.set,
-log10(pvalues)[causal.set],
col = "blue")
# }
Run the code above in your browser using DataLab