| RemoveFactorsByANOVA | R Documentation |
RemoveFactorsByANOVA will remove variance from data using an ANOVA model.
RemoveFactorsByANOVA(
y = NULL,
sam = NULL,
fmod = NULL,
kmod = NULL,
output = c("y_norm", "y_lm", "anova_y", "anova_y_norm", "boxplot")[1],
remove_outliers = 0
)
y |
Data vector (or data matrix) to normalize (numeric + in same order as sam). |
sam |
data.frame containing the factors or numerical vars for ANOVA model. |
fmod |
Full model describing the experimental setting (provided as character string). |
kmod |
Reduced model describing all the biological factors to keep (provided as character string). |
output |
Should be |
remove_outliers |
Should be a numeric integer x (with $x=0$ : no effect; $x>=1$ remove all values which have error e with $e > abs(mean + x * sd)$ ). |
See examples.
Depends on output. Usually the normalized data vector (or matrix).
# set up sample information sam <- data.frame( "GT" = gl(4, 10), "TR" = rep(gl(2, 5), 4), "Batch" = sample(gl(2, 20)), "Order" = sample(seq(-1, 1, length.out = 40)) ) # set up artificial measurement data set.seed(1) # specify main effects m1 <- c(5, 6, 2, 9)[sam$GT] + c(-2, 2)[sam$TR] m2 <- c(5, -6, 2, 4)[sam$GT] + c(-2, 2)[sam$TR] # add run order bias and noise m1 <- m1 + c(-3, 3)[sam$Batch] + 3 * sam$Order + rnorm(nrow(sam), sd = 0.5) m2 <- m2 - 5 * sam$Order + rnorm(nrow(sam), sd = 0.8) dat <- data.frame(m1, m2) # apply function to remove variance # full model incorporating all relevant factors defined in sample table fmod <- "GT*TR+Batch+Order" # reduced model: factors to be kept from full model; everything elso will be removed from the data kmod <- "GT*TR" RemoveFactorsByANOVA(y = dat[, "m1"], sam = sam, fmod = fmod, kmod = kmod, output = "anova_y") RemoveFactorsByANOVA(y = dat[, "m1"], sam = sam, fmod = fmod, kmod = kmod, output = "anova_y_norm")