Entering edit mode
coyoung
▴
10
@coyoung-17963
Last seen 4.9 years ago
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') cts <- read.csv(file='/Users/Corey/Desktop/DESeq2/Final_DESeq2/cts.csv') nrow(cts) ncol(cts) colData <- read.csv(file='colData.csv') 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()
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.