library(edgeR)

data = read.table("/data/images/proton/run125/www2/isoforms_tr3.counts.matrix", header=T, row.names=1, com='')
col_ordering = c(9,5,6)
rnaseqMatrix = data[,col_ordering]
rnaseqMatrix = round(rnaseqMatrix)
rnaseqMatrix = rnaseqMatrix[rowSums(rnaseqMatrix)>=2,]
conditions = factor(c(rep("GUT1", 1), rep("MAGsA", 2)))

exp_study = DGEList(counts=rnaseqMatrix, group=conditions)
exp_study = calcNormFactors(exp_study)
et = exactTest(exp_study, dispersion=0.1)
tTags = topTags(et,n=NULL)
write.table(tTags, file='isoforms_tr3.counts.matrix.GUT1_vs_MAGsA.edgeR.DE_results', sep='	', quote=F, row.names=T)
source("/data/results/tools/denovo/trinity/trinityrnaseq-2.0.6/Analysis/DifferentialExpression/R/rnaseq_plot_funcs.R")
pdf("isoforms_tr3.counts.matrix.GUT1_vs_MAGsA.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()
