1 Usage: Rcript *.R input output 2 3 library(DESeq2) 4 5 count <- read.table(input, header=T, sep="\t", row.names=1, comment.char="", check.names=F) 6 countData <- count[apply(count, 1, sum) > 0 , ] ##过滤表达量 7 colData <- data.frame(row.names = colnames(countData), 8 condition = factor(c(1, 2, 3)) ##condition分组 9 ) 10 11 dds <- DESeqDataSetFromMatrix(countData = countData, colData = colData, design = ~ condition) 12 13 dds <- DESeq(dds,betaPrior=FALSE,test="LRT", reduced=~1) ##差异表达量计算 14 cnt <- as.data.frame(counts(dds, normalized=TRUE)) ##表达量归一化 15 16 17 18 res <- as.data.frame(results(dds)) ##其它值pvalue等 19 res <- cbind(cnt, res) 20 res$type <- "Not DEG" ##添加type列 21 res$type[res$pvalue < 0.05 & res$log2FoldChange >= 1 ] <- "Up" 22 res$type[res$pvalue < 0.05 & res$log2FoldChange <= -1] <- "Down" 23 24 diff_file <- paste(output, "/diff.xls", sep="") 25 write.table(res, diff_file, sep="\t", quote=F, col.names = NA)