Entering edit mode
3.2 years ago
synat.keam
▴
120
Dear All experts,
Hope you are all well. I am doing hierachical clustering to see whether sample in each group is clustered together. I used DESeq2 model and my code chunk below to do the clustering. I am wondering if I wanted to filter say top 100 differentially expressed genes, where should I add to my existing code chunk. Looking forward to hearing from you soon. This is just example dataset.
Kind Regards,
Synat
## Heatmap
sampleDists <- dist(t(assay(vsd)))
library("RColorBrewer")
sampleDistMatrix <- as.matrix(sampleDists)
rownames(sampleDistMatrix) <- paste(vsd$Mouse, sep="-")
colnames(sampleDistMatrix) <- NULL
colors <- colorRampPalette( rev(brewer.pal(9, "Blues")))(255)
## annotation ============================
annotation.row <- data.frame(Treatment = factor(vsd@colData$Treatment,
levels = c("Radiotherapy", "Sham-radiotherapy")),
Group = factor(vsd@colData$Group,
levels = c("0Gy:0.1 day","0Gy:1 day","0Gy:4 days",
"0Gy:8 days", "2Gy×5:0.1 day", "2Gy×5:1 day",
"2Gy×5:4 days", "2Gy×5:8 days")))
## mapping =======================
rownames(annotation.row)<- rownames(sampleDistMatrix)
# plot the pheatmap ====================
library(pheatmap)
pheatmap(sampleDistMatrix,
clustering_distance_rows=sampleDists,
clustering_distance_cols=sampleDists,
annotation_row = annotation.row,
border_color = TRUE, cluster_cols = F)
Scaling RNA-Seq data before clustering?#
You would extract the DEGs from the results DESeq2 object (based on padj or logFC, or both) and then subset the
vsdobject with it, then scaling and plotting the heatmap.