Hi there,
I'm trying to identfy the DEGs between treated samples and control samples.
Here is the design:
blk | ind | cnd | ind.n |
---|---|---|---|
Blk1 | 1 | Ctrl | 1 |
Blk1 | 1 | Treated | 1 |
Blk1 | 2 | Ctrl | 2 |
Blk1 | 2 | Treated | 2 |
Blk1 | 3 | Ctrl | 3 |
Blk1 | 3 | Treated | 3 |
Blk1 | 4 | Ctrl | 4 |
Blk1 | 4 | Treated | 4 |
Blk2 | 5 | Ctrl | 1 |
Blk2 | 5 | Treated | 1 |
Blk2 | 6 | Ctrl | 2 |
Blk2 | 6 | Treated | 2 |
Blk2 | 7 | Ctrl | 3 |
Blk2 | 7 | Treated | 3 |
Blk2 | 8 | Ctrl | 4 |
Blk2 | 8 | Treated | 4 |
After reading the DESeq2 manual [here] (https://bioconductor.org/packages/release/bioc/vignettes/DESeq2/inst/doc/DESeq2.html#group-specific-condition-effects-individuals-nested-within-groups), I wrote the code below for simulating this experiment.
I consider this experiment as individuals nested within blocks.
library(DESeq2)
coldata <- DataFrame(blk=factor(rep(c("Blk1","Blk2"),each=8)),
ind=factor(rep(1:8,each=2)),
#period = factor(rep(c(1, 2, 1, 3, ),each=2)),
cnd=factor(rep(c("Ctrl","Treated"),8)))
as.data.frame(coldata)
dds <- makeExampleDESeqDataSet(n=10000, m = nrow(coldata))
coldata$ind.n <- factor(rep(rep(1:4,each=2),2))
as.data.frame(coldata)
colnames(dds) <- paste(as.character(coldata$blk), as.character(coldata$ind),
as.character(coldata$cnd), sep="_")
colData(dds) = coldata
colData(dds)
#dds$blk = coldata$blk
#dds$cnd = coldata$cnd
design(dds) =~ blk + blk:ind.n + blk:cnd
dds <- DESeq(dds)
resultsNames(dds)
### Extract the DEG between treated vs control in block 1
res_blk1_t_vs_c <- results(dds, name=c("blkBlk1.cndTreated"))
plotCounts(dds, gene=which.min(res_blk1_t_vs_c$padj), intgroup=c("cnd", "blk"))
plotCounts(dds, gene=which.max(res_blk1_t_vs_c$padj), intgroup=c("cnd", "blk"))
### Extract the DEG between treated vs control in block 2
res_blk2_t_vs_c <- results(dds, name=c("blkBlk2.cndTreated"))
plotCounts(dds, gene=which.min(res_blk2_t_vs_c$padj), intgroup=c("cnd", "blk"))
plotCounts(dds, gene=which.max(res_blk2_t_vs_c$padj), intgroup=c("cnd", "blk"))
### test if the treatment effect is different across two blocks
res_blk <- results(dds, contrast=list("blkBlk2.cndTreated","blkBlk1.cndTreated"))
plotCounts(dds, gene=which.min(res_blk2_t_vs_c$padj), intgroup=c("cnd", "blk"))
plotCounts(dds, gene=which.max(res_blk2_t_vs_c$padj), intgroup=c("cnd", "blk"))
Here are my questions:
If the project goal is to see the effect of treatment on the gene expression using the whole dataset, what comparison would you suggest? Is the code I'm using appropriate?
Based on the DESeq2 manual, if I do the following:
1) extract the DEG between treated vs control in block 1 (c("blkBlk1.cndTreated")); 2)extract the DEG between treated vs control in block 2 (c("blkBlk2.cndTreated")); 3) see whether the treatment effect is different across two blocks. For a particular gene, if it was identified as DEG in 1) and 2) but not 3), then it means it's not block specific. Otherwise, it's block specific.
Is my understanding correct? Is there another way to identify DEG between treated vs treated taking block factor into consideration?
Thanks in advance.
I don't understand the difference between ind and ind.n. I suspect you don't need ind.n
Thanks for your replying. 'ind' means indivudla. I have 8 individual animals in the experiment. I adapoted the code here: https://bioconductor.org/packages/release/bioc/vignettes/DESeq2/inst/doc/DESeq2.html#group-specific-condition-effects-individuals-nested-within-groups