aboutsummaryrefslogtreecommitdiff
path: root/day2/ex3-R/script.R
diff options
context:
space:
mode:
Diffstat (limited to 'day2/ex3-R/script.R')
-rw-r--r--day2/ex3-R/script.R16
1 files changed, 16 insertions, 0 deletions
diff --git a/day2/ex3-R/script.R b/day2/ex3-R/script.R
new file mode 100644
index 0000000..fcbf6e1
--- /dev/null
+++ b/day2/ex3-R/script.R
@@ -0,0 +1,16 @@
+library(edgeR)
+
+# It's easier to read environment variables than parse command line arguments
+counts <- read.delim(Sys.getenv("counts"), row.names=1)
+out <- Sys.getenv("out")
+
+group <- rep(c("A", "B"), each = 2)
+design <- model.matrix(~group)
+dge <- DGEList(counts=counts)
+keep <- filterByExpr(dge, design)
+dge <- dge[keep,,keep.lib.sizes=FALSE]
+dge <- calcNormFactors(dge)
+logCPM <- cpm(dge, log=TRUE, prior.count=3)
+fit <- lmFit(logCPM, design)
+fit <- eBayes(fit, trend=TRUE)
+write.table(topTable(fit, coef=ncol(design)), file = out)