Collapse Technical Replicates and Group-specific condition effects, individuals nested within groups
1
0
Entering edit mode
rbenel ▴ 40
@rbenel-13642
Last seen 20 months ago
Israel

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!!

deseq2 RNAseq model.matrix collapseTechnicalReplicates • 896 views
ADD COMMENT
0
Entering edit mode
@mikelove
Last seen 1 hour ago
United States

Theres no need to create a second dds. The one after collapsing is fine, and you can replace the design with:

design(dds) <- ...

ADD COMMENT
0
Entering edit mode

OK.

If I use design(dds) then the counts will still come from the collapseReplicates, correct?

ADD REPLY
1
Entering edit mode

collapseReplicates produces a DESeqDataSet, let's call it x. You can then just do:

design(x) <- ...
x <- DESeq(x)

You can call x whatever you like, including dds.

ADD REPLY

Login before adding your answer.

Traffic: 790 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