DESeq2包:差异表达分析


 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)

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM