1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| require(limma) f_DE_limma <- function(cts_bb, rowInfo, ControlN, TreatN, rm.NA=T, trend=T){ cts_b <- cts_bb[,c(ControlN, TreatN)] conditions <- c(rep("Control",length(ControlN)), rep("Treat",length(TreatN))) design <- model.matrix(~0+factor(conditions)) colnames(design) <- levels(factor(conditions)) rownames(design) <- colnames(cts_b) print(design) contrast.matrix <- makeContrasts('Treat-Control', levels = design) print(contrast.matrix) fit <- lmFit(cts_b, design) fit2 <- contrasts.fit(fit, contrast.matrix) fit2 <- eBayes(fit2, trend=trend) tempOutput <- topTable(fit2, coef=1, n=Inf) if(!is.null(rowInfo)){tempOutput <- cbind(rowInfo[rownames(tempOutput),], tempOutput)} if(rm.NA){tempOutput <- na.omit(tempOutput)} tempOutput }
data.exprs
Ct1 <- c('AF6.CEL', 'AF14.CEL') Tt1 <- c('AF15.CEL', 'AF16.CEL') f_DE_limma(data.exprs, NULL, Ct1, Tt1, F)
|