if (require("limma")) {
# create random data and design
set.seed(2014)
dat <- matrix(rnorm(1000), ncol=4)
dat[, 1:2] <- dat[, 1:2] + .5 # add an effect
rownames(dat) <- paste0("g", 1:nrow(dat))
des <- data.frame(treatment = c("a", "a", "b", "b"),
confounding = rnorm(4))
lfit <- lmFit(dat, model.matrix(~ treatment + confounding, des))
eb <- eBayes(lfit)
head(tidy(lfit))
head(tidy(eb))
if (require("ggplot2")) {
# the tidied form puts it in an ideal form for plotting
ggplot(tidy(lfit), aes(estimate)) + geom_histogram(binwidth=1) +
facet_wrap(~ term)
ggplot(tidy(eb), aes(p.value)) + geom_histogram(binwidth=.2) +
facet_wrap(~ term)
}
}
Run the code above in your browser using DataLab