condition <- factor(c("control","treat","control","treat","control","treat"), levels = c("control","treat"))
countData <- dat[,1:6]
colData <- data.frame(row.names=colnames(dat), condition)
dds <- DESeqDataSetFromMatrix(countData, colData, design= ~ condition)
dds <- DESeq(dds)
contrast=c("condition","control","treat")
res = results(dds, contrast)
baseMeanA <- rowMeans(counts(dds, normalized=TRUE)[,colData(dds)$condition == "control"])
baseMeanB <- rowMeans(counts(dds, normalized=TRUE)[,colData(dds)$condition == "treat"])
res = cbind(baseMeanA, baseMeanB, as.data.frame(res))
res = cbind(sampleA="control", sampleB="treat", as.data.frame(res))
res$padj[is.na(res$padj)]<- 1
write.table(as.data.frame(res[order(res$pvalue),]), file='o', sep='\t', quote=FALSE)