DESeq2 interaction design
1
0
Entering edit mode
lamia11me • 0
@121cda19
Last seen 20 months ago
United States

I trying to add some interactions to my DESeq2 design matrix. My 12 samples are divided into two batches. There are two strains. These samples are coming from 6 individuals, so it's also a paired experiment with two treatments. Please see the metadata for clarity. As mentioned in the vignette, I have put the ind.n variable in the metadata to make the design paired. The question I am interested in is "Is the treatment effect different across strains?" Following the examples provided in ?results, I believe the contrast name will be "strainsstrainA.conditionstreated". But I have more variables, so I wanted to make sure my design can correctly address the question and that it is taking batches and ind.n variables into account.

no_of_genes <- 10000              
no_of_samples <- 12               
dds <- makeExampleDESeqDataSet(m = no_of_samples, n = no_of_genes, betaSD = 1)
rawcounts <- counts(dds)
colnames(rawcounts) <- c(paste0("sample", 1:no_of_samples))
rownames(rawcounts) <- c(paste0("gene", 1:no_of_genes))

# Create metadata for the dataset
batches <- c("a","a","a","a","a","b","b","b","b","b","b","b")                 
conditions <- c("treated","untreated","treated","untreated","treated","untreated",
                       "treated","untreated","treated","untreated","treated","untreated")       #input
strains <- c("strainA","strainA","strainA","strainA","strainA","strainA",
             "strainB","strainB","strainB","strainB","strainB","strainB")        
animals <- factor(rep(1:6,each=2))                                            
ind.n <- factor(rep(rep(1:3,each=2),2))                                  
metadata <- data.frame(batches, strains, animals, ind.n, conditions)
rownames(metadata) <- c(paste0("sample", 1:no_of_samples))

# Create DESeq object
dds <- DESeqDataSetFromMatrix(countData = rawcounts, 
                              colData = metadata, design = ~ batches + 
                                strains:ind.n + strains + conditions +  
                                strains:conditions)

# Set levels
dds$strains<- relevel(dds$strains, ref = "strainB")
dds$conditions<- relevel(dds$conditions, ref = "untreated")

# Run analysis
dds <- DESeq(dds)
resultsNames(dds)

> resultsNames(dds)
[1] "Intercept"                        "batches_b_vs_a"                  
[3] "strains_strainA_vs_strainB"       "conditions_treated_vs_untreated" 
[5] "strainsstrainB.ind.n2"            "strainsstrainA.ind.n2"           
[7] "strainsstrainB.ind.n3"            "strainsstrainA.ind.n3"           
[9] "strainsstrainA.conditionstreated"

sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)
DESeq2 • 855 views
ADD COMMENT
0
Entering edit mode
@mikelove
Last seen 5 days ago
United States

For questions about statistical analysis plan, I recommend to work with a local statistician or someone familiar with linear models in R. I have to restrict my time on the support site to software related questions.

ADD COMMENT

Login before adding your answer.

Traffic: 652 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6