Question: Collapse Replicates effect on heat map construction
gravatar for coyoung
10 weeks ago by
coyoung0 wrote:


I cannot seem to figure out why my heat map does not group my samples by condition when I use collapse replicate function. The only thing that is changed is dds --> ddsColl and vstdds --> vstddsColl. Any help would be appreciated. 

### DESeq2 Analysis on Personal ###



cts <- read.csv(file='/Users/Corey/Desktop/DESeq2/Final_DESeq2/cts.csv')



colData <- read.csv(file='colData.csv')



rownames(cts) <- cts$Geneid

cts$Geneid <- NULL



dds <- DESeqDataSetFromMatrix(countData=cts, colData=colData, design= ~ patient + condition)

keep <- rowSums(counts(dds) >= 10) >= 5

dds <- dds[keep,]

dds$condition <- relevel(dds$condition, ref='NT')

# micheal said it doesnt matter what the refernce is b/c the comparision between the sample remains the same

ddsColl <- collapseReplicates(dds, dds$id)

ddsColl <- DESeq(ddsColl)

# Does ddsColl throw off heatmap generation

dds <- DESeq(dds)


res <- results(ddsColl, name="condition_MPT_vs_NT", lfcThreshold=0.585, alpha=0.05)


resOrder <- res[order(res$padj),]

write.csv(, file='DESeqResults.csv')




pdf('heatmap_top100.pdf', height=10, )
select <- order(rowMeans(counts(ddsColl,normalized=TRUE)), decreasing=TRUE)[1:100]
df <-[,c("condition","patient")])
pheatmap(assay(vstddsColl)[select,], cluster_rows=FALSE,show_rownames=FALSE,cluster_cols=FALSE, annotation_col=df)


pdf('heatmaptop100.pdf', height=10, )
select <- order(rowMeans(counts(dds,normalized=TRUE)), decreasing=TRUE)[1:100]
df <-[,c("condition","patient")])
pheatmap(assay(vstdds)[select,], cluster_rows=FALSE,show_rownames=FALSE,cluster_cols=FALSE, annotation_col=df)


deseq2 • 82 views
ADD COMMENTlink modified 10 weeks ago by Michael Love22k • written 10 weeks ago by coyoung0
Answer: Collapse Replicates effect on heat map construction
gravatar for Michael Love
10 weeks ago by
Michael Love22k
United States
Michael Love22k wrote:

pheatmap groups samples by distance. Take a look at the help pages in the pheatmap package. I don’t understand how this has anything to do with collapseReplicates. These operations aren’t repeated. If you collapse technical replicates, pheatmap doesn’t “know” about this, it only sees the collapsed samples you provide to it.

ADD COMMENTlink written 10 weeks ago by Michael Love22k

Before Collapse Replicates

After CollapseReplicates

As noted before the only changes were the dds to ddsColl objects. It seems to now group by patients rather than condition. I will also look at help pages of pheatmap also but any other information you could provide would be greatly appreciated. 

ADD REPLYlink modified 10 weeks ago • written 10 weeks ago by coyoung0
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 378 users visited in the last hour