170106 Updated Limma script - npslindstrom/DE-analysis GitHub Wiki

So after fiddling around with the limma-script I have managed to make one that outputs a neat file interpretable by excel or similar program. The version below compares the first two samples of the counts generated with tophat. Once we have a good counts-matrix generated with STAR the script can be run on that to do all the comparisons.

library(limma) library(edgeR)

data_orig = read.table("/glob/nilsl/lncRNA_proj/tophat_counts/count_table.txt", header = TRUE)

data = data_orig

data = data[,-5:-18]

group <- factor(c("SW620" ,"SW620" ,"SW480" ,"SW480"))

design = model.matrix(~ group)

dge <- DGEList(counts = data)

dge <- calcNormFactors(dge)

logCPM <- cpm(dge, log=TRUE, prior.count=3)

fit <- lmFit(logCPM, design)

fit <- eBayes(fit, trend=TRUE)

res_table = topTable(fit, number = nrow(fit), coef=ncol(design))

write.csv2(res_table, "SW620_vs_SW480.csv")