Hi Michael,
I want to pass a corrected model matrix to DEseq
following the collapse of some technical replicates and I just wanted to make sure I am doing things in the correct order and grabbing the right data.
First I created an arbitrary dds
object with a design including only 2 of the 3 elements of my design. Then I collapsed the technical replicates. Then filtered the collapsed counts, followed by the creation of the nested model. Finally I re-created the DESeqDataSetFromMatrix
object and I hope, took the counts
and colData
form the correct objects?
##############################################
###create a dds object from transcript counts
#############################################
#Create a deseq object
dds <- DESeqDataSetFromMatrix(cts,
colData = finalQA,
design = ~ women + serum)
#################################
#Collapsing Technical Replicates
#################################
#we want to collapse technical replicates
collapseTrial <- collapseReplicates(dds, groupby = finalQA$name, finalQA$shortName)
#########################
#Filter the Deseq2 object
#########################
#filter any row less than 20 counts in at least two samples
filter <- rowSums(counts(collapseTrial) >= 20) >= 2
collapsedDDS <- collapseTrial[filter, ]
#now make a new item for the model matrix
collapsedDDS$nested <- factor(rep(rep(1:5, each = 4), 2))
#############
#the new model
#############
model <- model.matrix(~ infection + infection:nested + infection:serum, colData(collapsedDDS))
#Re-run the DESeqDataSetFromMatrix
#access counts and colData
collapsedDDS_nested <- DESeqDataSetFromMatrix(counts(collapsedDDS),
colData = colData(collapsedDDS),
design = model)
###########
#Run deseq
###########
deseq.dds2 <- DESeq(collapsedDDS_nested)
Thank You!!
OK.
If I use
design(dds)
then thecounts
will still come from thecollapseReplicates
, correct?collapseReplicates
produces a DESeqDataSet, let's call itx
. You can then just do:You can call
x
whatever you like, includingdds
.