Example

How to run DESeq2 on a data matrix

# load DEseq2 package

library(DESeq2)

# read data set (tabulator separated text file)

mydata = read.table('data_table.tsv', header=TRUE)

# alternatively, generate a test data (data.frame table)

mydata = data.frame(

c1 = sample(100:200,10), c2 = sample(100:200,10), c3 = sample(100:200,10),

t1 = sample(1000:2000,10), t2 = sample(1000:2000,10), t3 = sample(1000:2000,10) )

rownames(mydata) <- letters[1:10]

# check content of data set "mydata"

> head(mydata) # show top lines

c1 c2 c3 t1 t2 t3

a 133 122 120 1919 1990 1228

b 118 178 170 1072 1699 1442

c 109 132 195 1576 1368 1201

d 100 141 139 1922 1795 1384

e 127 144 118 1868 1320 1815

f 133 122 188 1919 1990 1833

# add conditions to samplenames (columns): 3 control and 3 Treatment samples

conditions <- factor(c(rep("Control", 3), rep("Treatment", 3)))

sampleCondition <- data.frame(row.names=colnames(mydata), conditions)

sampleCondition # show metadata mapping

conditions

c1 Control

c2 Control

c3 Control

t1 Treatment

t2 Treatment

t3 Treatment

# convert data to dds object

dds=DESeqDataSetFromMatrix(countData=mydata,colData=sampleCondition,design=~conditions)

# Run DESeq2

dds <- DESeq(dds)

res <- results(dds)

res <- res[order(res$padj), ]

table(res$padj<0.05) # find number of "significant" peaks

write.csv(res, file="results_DESeq2.csv")