This is a test version of Biostars. For the public version, visit https://www.biostars.org.
DESeq2 multiple conditions, time points and sample types

I am working with the raw count data, and the metadata consists of three groups, A, B, and C. Each group has four-time points, 3h, 6h, 12h, and 18h, and two treatment and control conditions.

What I want is quite simple; I want to measure control vs. treatment from one group or within the group. For example, In A, there are two replicates for control and treatment for each time. I want to compare control vs. treatment to get an overall differential expression of genes across all time points in A only.

I hope I made it understandable. How do I design the DESeqDataSet?

enter image description here

deseq2 r edger

Can you provide a table with sample information, group, replicate and time point ?

You can create a new column where it's a combination of Group and Condition. For example, new column Class which will contains row as controlA, controlA, TreatedA, .... controlC. Then it's easy to make ddsobject

1 answer

You can create a new column where it's a combination of Group and Condition. For example, new column Class which will contains row as controlA, controlA, TreatedA, ...., controlC. Then it's easy to make dds object

#read the expression data in raw counts
readcounts <- read.table("expression_raw_counts.txt", header=TRUE, row.names = 1)

#read the sample information
sample_info <- read.table('sample_information.txt', sep='\t', header = TRUE, row.names = 1)

#Create a DESeq2 object named dds from the gene read count and sample information
dds <- DESeqDataSetFromMatrix(countData = readcounts,
                              colData = sample_info,
                              design = ~ Class)

#remove genes with 0 counts
keep_genes <- rowSums(counts(dds)) > 0
dds <- dds[ keep_genes, ]

#run deseq2
dds <- DESeq(dds, betaPrior=FALSE)

#generate results
res = results(dds, contrast = c("Class", "TreatedA", "controlA"))
write.table(res, "TreatedA_controlA.txt", sep='\t')

#run lfcShrink
res = lfcShrink(dds, contrast = c("Class", "TreatedA", "controlA"), res=res)
write.table(res, "TreatedA_controlA.lfc.txt", sep='\t')

I did this the same earlier, but is it the right way to do it?

If you are not looking at time points, there is no error in the flow

I would add time to the design, so the algorithm knows that that is a variable that should added to the model. But the rest can stay the same.

Log in to answer this question.