library(edgeR)

data = read.table("/data/images/proton/run125/www/genes2.counts.matrix2.noGUT1", header=T, row.names=1, com='')
col_ordering = c(3,5,8,9)
rnaseqMatrix = data[,col_ordering]
rnaseqMatrix = round(rnaseqMatrix)
rnaseqMatrix = rnaseqMatrix[rowSums(rnaseqMatrix)>=2,]
conditions = factor(c(rep("MAGsA", 2), rep("MAGsB", 2)))

exp_study = DGEList(counts=rnaseqMatrix, group=conditions)
exp_study = calcNormFactors(exp_study)
exp_study = estimateCommonDisp(exp_study)
exp_study = estimateTagwiseDisp(exp_study)
et = exactTest(exp_study)
tTags = topTags(et,n=NULL)
write.table(tTags, file='genes2.counts.matrix2.noGUT1.MAGsA_vs_MAGsB.edgeR.DE_results', sep='	', quote=F, row.names=T)
source("/data/results/tools/align/trinity/trinityrnaseq_r20140413p1/Analysis/DifferentialExpression/R/rnaseq_plot_funcs.R")
pdf("genes2.counts.matrix2.noGUT1.MAGsA_vs_MAGsB.edgeR.DE_results.MA_n_Volcano.pdf")
result_table = tTags$table
plot_MA_and_Volcano(result_table$logCPM, result_table$logFC, result_table$FDR)
dev.off()
