getF | R Documentation |
For some data Y organized in a matrix, calculate a F-statitic per row comparing two nested models.
getF(fit, fit0, theData)
fit |
An object created with lmFit using the alternative model (the larger model). |
fit0 |
An object created with lmFit using the null model (the smaller model, nested in the larger one). |
theData |
The data used in the lmFit call. |
This function can also work with outputs from lm.
A data.frame with the F-statistics (fstat
), the degrees of
freedom for the nallternative model (df1
), the null model
(df0
), and the p-value given the F-distribution (f_pval
).
Leonardo Collado-Torres, Andrew E Jaffe
set.seed(20161005)
## From limma::limFit example page:
sd <- 0.3 * sqrt(4 / rchisq(100, df = 4))
y <- matrix(rnorm(100 * 6, sd = sd), 100, 6)
rownames(y) <- paste("Gene", seq_len(100))
y[seq_len(2), seq_len(3) + 3] <- y[seq_len(2), seq_len(3) + 3] + 4
## Define the alternative and null models
pheno <- data.frame(group = rep(c(0, 1), each = 3), RIN = runif(6) + 8)
mod <- model.matrix(~ pheno$group + pheno$RIN)
mod0 <- model.matrix(~ pheno$RIN)
## Fit the models
library("limma")
fit <- lmFit(y, mod)
fit0 <- lmFit(y, mod0)
## Calculate the F statistics for these nested models
finfo <- getF(fit, fit0, y)
head(finfo)
## You can then use p.adjust() for multiple testing corrections
qvals <- p.adjust(finfo$f_pval, "fdr")
summary(qvals)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.