diff 01_deseq2_analysis.Rmd @ 1:32210899a3dd draft

planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
author mingchen0919
date Sun, 30 Dec 2018 12:45:56 -0500
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/01_deseq2_analysis.Rmd	Sun Dec 30 12:45:56 2018 -0500
@@ -0,0 +1,44 @@
+---
+title: 'DESeq2 analysis'
+output:
+    html_document:
+      highlight: pygments
+---
+
+```{r setup, include=FALSE, warning=FALSE, message=FALSE}
+knitr::opts_chunk$set(error = TRUE, echo = FALSE)
+```
+
+
+```{r echo=FALSE}
+# import count data
+count_data = read.csv(opt$X_A, row.names = 1, header = TRUE)
+# import column data
+coldata = read.csv(opt$X_B, row.names = 1, header = TRUE)[colnames(count_data),,drop=FALSE]
+```
+
+```{r echo=FALSE}
+dds = DESeqDataSetFromMatrix(countData = count_data,
+                             colData = coldata,
+                             design = formula(opt$X_C))
+dds = DESeq(dds, test = opt$X_G, fitType = opt$X_H)
+## Differential expression test results
+res = results(dds, contrast = c(opt$X_D, opt$X_E, opt$X_F), alpha = opt$X_I)
+res
+```
+
+
+```{r echo=FALSE}
+# save all padj sorted res to tool output directory
+padj_sorted_res = res[order(res$padj), ]
+write.table(padj_sorted_res,
+            file = paste0(opt$X_d, '/padj-sorted-genes.txt'),
+            quote = FALSE)
+
+# save significant genes to a file in tool output directory
+sig_res = res[(res$padj < opt$X_I) & !is.na(res$padj), ]
+sig_res_sorted = sig_res[order(sig_res$padj), ]
+write.table(sig_res_sorted, 
+            file = paste0(opt$X_d, '/padj-sorted-significant-genes.txt'), 
+            quote = FALSE)
+```