Hi
Firstly apologies if this has been answered before, please feel free to leave a link below. I'm having issues extracting results as I believe it doesn't really add up (but this is potentially because I don't fully understand what the function is doing). Here is my code below
#my dataset
Group Timepoint Participant_ID Participant.n
<fct> <fct> <fct> <fct>
1 Treatment Baseline 01 1
2 Treatment Followup 01 1
3 Treatment Baseline 02 2
4 Treatment Followup 02 2
5 Treatment Baseline 03 3
6 Treatment Followup 03 3
7 Treatment Baseline 04 4
8 Treatment Followup 04 4
9 Treatment Baseline 05 5
10 Treatment Followup 05 5
...
#if you want to replicate it
sampleinfo <- data.frame(
Group = rep(rep(c("Treatment", "Control"), times = c(10, 9)), each = 2),
Timepoint = rep(c("Baseline", "Followup"), times = 19),
Participant_ID = rep(paste0(sprintf("%02d", 1:19)), each = 2)
)
sampleinfo <- sampleinfo %>%
group_by(Group) %>%
mutate(Participant.n = as.integer(factor(Participant_ID)))
simple.model<- as.formula(~ Participant.n + Timepoint) #for now
ddsObj.raw <- DESeqDataSetFromTximport(txi = txi,
colData = sampleinfo,
design = simple.model)
model_matrix<-model.matrix(~ Group + Group:Participant.n + Group:Timepoint, sampleinfo)
correct_model_matrix <- model_matrix[, !colnames(model_matrix) %in% "GroupTreatment:Participant.n10"] #I have unbalanced groups
design(ddsObj.raw) <- correct_model_matrix
ddsObj <- DESeq(ddsObj.raw)
Here is where things get confusing:
results<-results(ddsObj, name = "GroupControl.Followup")
sum(results$padj < 0.05, na.rm = TRUE)
#2689 genes
results<-results(ddsObj, name = "GroupTreatment.Followup")
sum(results$padj < 0.05, na.rm = TRUE)
#352 genes
#this is what I'm mainly interested in (if group X and group Y differ at followup taking into account individual differences)
results<-results(ddsObj, contrast = list("GroupControl.TimepointT3", "GroupLowsug.TimepointT3"))
sum(results$padj < 0.05, na.rm = TRUE)
#21 genes
Surely this doesn't add up right? How can there only be 21 DEG between the two groups at followup when they both have so many DEG individually? Am I extracting the results incorrectly?