I use DEseq2 to analyse the RNA-seq data out of an animal experiment (two conditions and two gender). The conditions include HS and Control and I am also interested in the condition effect in each in gender (Males or Females), and also sex effect in each condition
As the interaction terms seem complicated, I use the alternative grouping variable ~group
to compare specific group. However, there may be something wrong as I got exactly the same number of DEG (P<0.1) when calling for resconmale, ressexcontrol and ressex_HS (Please see scripts below).
Your correction and suggestions are very much appreciated!
Cheers, Wei
#import count file
countall<- read.table(file.choose(),header = F, row.names = 1)
countall <- as.matrix(countall)
#load libraries
library(DESeq2)
#Assign condition
condition <- factor(c(rep("Control",5),rep("HS",8),rep("Control",7),rep("HS",9)))
sex <- factor(c("female","male","female","male","male",
"male","male","female","female","female","female","male","female",
"female","female","female","female","female","male","female",
"female","female","male","female","male","female","female","male","female"))
#Create a data frame
coldata_all<- data.frame(condition=as.factor(condition),sex=as.factor(sex))
# Construct a DESeqDataSet
dds <- DESeqDataSetFromMatrix(countData=countall,colData=coldata_all, design=~sex+condition)
#combine the factors of interest into a single factor with all combinations of the original factors
dds$group <- factor(paste0(dds$sex, dds$condition))
#change the design to include just this factor, e.g. ~ group
design(dds) <- ~group
#run DEseq
dds <- DESeq(dds)
#Check available comparisons
resultsNames(dds)
#outputs:[1] "Intercept" "group_femaleHS_vs_femaleControl" "group_maleControl_vs_femaleControl" "group_maleHS_vs_femaleControl"
#The effect of condition (HS vs. Control) in female
rescon_female = results(dds,contrast = c("group","femaleHS","femaleControl"))
##The effect of condition (HS vs. Control) in male
rescon_male = results(dds,contrast = c("group","maleHS","maleControl"))
#the sex effect (male vs. female) in Control group
ressex_Control = results(dds,contrast = c("group","maleControl","femaleControl"))
#the sex effect (male vs. female) in HS group
ressex_HS = results(dds,contrast = c("group","maleHS","femaleHS"))
Thanks Kevin, outputs for each comparison beblow:
The follow up questions are: The overall comparison code is correct?
The call
ressex_Control
andressex_HS
seems giving me the same result table. Why?Thanks, W
Just note that, in the bottom table, you are actually showing
ressex_Control_sig
results, notressex_HS_sig
Thanks for the correction. BTW, are the codes above correct for each specific comparison?
Yes, they seem fine; although, you are not doing any log-fold change shrinkage step. You can check the DESeq2 vignette for details on that: http://bioconductor.org/packages/devel/bioc/vignettes/DESeq2/inst/doc/DESeq2.html