How to collapseReplicate in DESeq2
1
3
Entering edit mode
7.4 years ago
macmath ▴ 170

After going through the manual I couldn't proceed with collapse replicates

sampleFiles <- list.files(path = "./", pattern = ".counts")
sampleNames <- gsub(".counts", "", sampleFiles)
sampleCondition <- c(rep("KO1", 4),rep("KO2", 4),rep("KO3", 4), rep("WT1", 4),rep("WT2", 4),rep("WT3", 4))
sampleTable <- data.frame(sampleName = sampleNames, fileName = sampleFiles, condition = sampleCondition)
ddsHTSeq <- DESeqDataSetFromHTSeqCount(sampleTable = sampleTable,
                                       directory = directory,
                                       design = ~ condition)
treatments <- c("KO1", "KO2", "KO3", "WT1", "WT2", "WT3")
library("DESeq2")
ddsHTSeq <- DESeqDataSetFromHTSeqCount(sampleTable = sampleTable,design = ~ condition)
colData(ddsHTSeq)$condition <- factor(colData(ddsHTSeq)$condition,
                                      levels = treatments)
#Analysis using DESeq
dds <- DESeq(ddsHTSeq)
resultsNames(dds)
#Pre-filtering
dds <- dds[ rowSums(counts(dds)) > 1, ]
res <- results(dds)
#summarise some basic tallies
summary(res)

This was the example from collapseReplicates, I am not sure where should I apply this step and how should I proceed with my dataset

dds <- makeExampleDESeqDataSet(m=12)

# make data with two technical replicates for three samples
dds$sample <- factor(sample(paste0("sample",rep(1:9, c(2,1,1,2,1,1,2,1,1)))))
dds$run <- paste0("run",1:12)

ddsColl <- collapseReplicates(dds, dds$sample, dds$run)

# examine the colData and column names of the collapsed data
colData(ddsColl)
colnames(ddsColl)

# check that the sum of the counts for "sample1" is the same
# as the counts in the "sample1" column in ddsColl
matchFirstLevel <- dds$sample == levels(dds$sample)[1]
stopifnot(all(rowSums(counts(dds[,matchFirstLevel])) == counts(ddsColl[,1])))
RNA-Seq • 9.9k views
ADD COMMENT
0
Entering edit mode

Your code is a bit confusing because you call DESeqDataSetFromHTSeqCount twice with different parameters. Can you clean this up and post the output of colData(ddsHTSeq) ?

ADD REPLY
0
Entering edit mode

Please correct me if I am wrong in any point, if I need to make any changes

The output of colData(ddsHTSeq)

DataFrame with 24 rows and 1 column
              condition
               <factor>
    AdipoKO1a       KO1
    AdipoKO1b       KO1
    AdipoKO1c       KO1
    AdipoKO1d       KO1
    AdipoKO2a       KO2
    ...             ...
    AdipoWT2d       WT2
    AdipoWT3a       WT3
    AdipoWT3b       WT3
    AdipoWT3c       WT3
    AdipoWT3d       WT3
ADD REPLY
9
Entering edit mode
7.4 years ago

In order to use collapseReplicates, you need a colData like this :

         condition   sample         run
1          KO      KO1        AdipoKO1a
2          KO      KO1        AdipoKO1b
3          KO      KO1        AdipoKO1c
4          KO      KO1        AdipoKO12
5          KO      KO2        AdipoKO2a
6          KO      KO2        AdipoKO2b
...

Then you will collapse your "runs" (technical replicates) at the level of your samples (biological replicates) :

ddsColl <- collapseReplicates(ddsHTSeq, ddsHTSeq$sample, ddsHTSeq$run)
ADD COMMENT
0
Entering edit mode

Thank you very much Carlo Yague for your help and suggestion. It worked absolutely fine.

Could you suggest me regarding Time point analysis how should I proceed and what should be the design? Should I collapse replicates during that process. Waiting anxiously for anyones help!!!

ADD REPLY
1
Entering edit mode

I have moved the reaction of Carlo to an answer so you can accept it to mark this question as solved.

Could you suggest me regarding Time point analysis how should I proceed and what should be the design? Should I collapse replicates during that process. Waiting anxiously for anyones help!!!

This sounds like a separate question and as such should get a separate thread. Also note that Bioconductor Support might be the most appropriate place for these questions (although you are obviously free to ask on Biostars. Just pick one and one only for your question.)

ADD REPLY
1
Entering edit mode

Should you collapse replicates ? Probably yes (for technical replicates).

How should be the design ? Look here for examples of time course analysis in DESeq2.

Hope this helps. If you need a more elaborated answer, create a new question with all the details, as suggested by WouterDeCoster.

ADD REPLY

Login before adding your answer.

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