Question: Collapse Replicates effect on heat map construction
0
15 days ago by
coyoung0
coyoung0 wrote:

Hello,

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

setwd('/Users/Corey/Desktop/DESeq2/Final_DESeq2/')

library('DESeq2')

nrow(cts)

ncol(cts)

ncol(colData)

nrow(colData)

rownames(cts) <- cts$Geneid cts$Geneid <- NULL

#library("BiocParallel")

#register(MulticoreParam(12))

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) resultsNames(ddsColl) res <- results(ddsColl, name="condition_MPT_vs_NT", lfcThreshold=0.585, alpha=0.05) res resOrder <- res[order(res$padj),]

write.csv(as.data.frame(resOrder), file='DESeqResults.csv')

summary(resOrder)

library('pheatmap')

#ddsColl

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

#dds

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

deseq2 • 59 views
modified 15 days ago by Michael Love21k • written 15 days ago by coyoung0
Answer: Collapse Replicates effect on heat map construction
0
15 days ago by
Michael Love21k
United States
Michael Love21k 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.

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.